Quellcode durchsuchen

naf: Added "ops"

Signed-off-by: Sven Velt <sven@velt.de>
Sven Velt vor 14 Jahren
Ursprung
Commit
b87107d163
2 geänderte Dateien mit 30 neuen und 6 gelöschten Zeilen
  1. 22 1
      check_naf.py
  2. 8 5
      monitoringplugin.py

+ 22 - 1
check_naf.py

@@ -62,6 +62,10 @@ class CheckNAF(SNMPMonitoringPlugin):
 
 			'NVRAM_Status': '.1.3.6.1.4.1.789.1.2.5.1.0',
 
+			'OPs_NFS': ['.1.3.6.1.4.1.789.1.2.2.27.0', '.1.3.6.1.4.1.789.1.2.2.6.0', '.1.3.6.1.4.1.789.1.2.2.5.0',],
+			'OPs_CIFS': ['.1.3.6.1.4.1.789.1.2.2.28.0','.1.3.6.1.4.1.789.1.2.2.8.0', '.1.3.6.1.4.1.789.1.2.2.7.0',],
+			'OPs_HTTP': ['.1.3.6.1.4.1.789.1.2.2.29.0','.1.3.6.1.4.1.789.1.2.2.10.0', '.1.3.6.1.4.1.789.1.2.2.9.0',],
+
 			'Model': '.1.3.6.1.4.1.789.1.1.5.0',
 			'ONTAP_Version': '.1.3.6.1.4.1.789.1.1.2.0',
 
@@ -222,7 +226,7 @@ class CheckNAF(SNMPMonitoringPlugin):
 		ec_size_human = self.value_to_human_binary(ec_size, unit='B')
 
 		output = 'Cache size %s, cache usage %5.2f%%, total hits %5.2f%% ' % (ec_size_human, ec_usage, ec_hitpct)
-		returncode = 0
+		returncode = self.RETURNCODE['OK']
 		perfdata = []
 		perfdata.append({'label':'nacache_usage', 'value':float('%5.2f' % ec_usage), 'unit':'%'})
 		perfdata.append({'label':'nacache_hits', 'value':ec_hits, 'unit':'c'})
@@ -268,6 +272,21 @@ class CheckNAF(SNMPMonitoringPlugin):
 		return self.remember_check('nvram', returncode, output)
 
 
+	def check_ops(self):
+		ops_nfs = self.SNMPGET(self.OID['OPs_NFS'])
+		ops_cifs = self.SNMPGET(self.OID['OPs_CIFS'])
+		ops_http = self.SNMPGET(self.OID['OPs_HTTP'])
+
+		output = 'Total ops statistics'
+		returncode = self.RETURNCODE['OK']
+		perfdata = []
+		perfdata.append({'label':'naops_nfs', 'value':ops_nfs, 'unit':'c'})
+		perfdata.append({'label':'naops_cifs', 'value':ops_cifs, 'unit':'c'})
+		perfdata.append({'label':'naops_http', 'value':ops_http, 'unit':'c'})
+
+		return self.remember_check('ops', returncode, output, perfdata=perfdata)
+
+
 	def check_version(self):
 		model = self.SNMPGET(self.OID['Model'])
 		ontapversion = self.SNMPGET(self.OID['ONTAP_Version'])
@@ -456,6 +475,8 @@ def main():
 			result = plugin.check_extcache_info()
 		elif check == 'nvram':
 			result = plugin.check_nvram()
+		elif check == 'ops':
+			result = plugin.check_ops()
 		elif check == 'version':
 			result = plugin.check_version()
 		elif check == 'vol_data':

+ 8 - 5
monitoringplugin.py

@@ -467,22 +467,25 @@ class SNMPMonitoringPlugin(MonitoringPlugin):
 
 
 	def SNMPGET(self, baseoid, idx=None, exitonerror=True):
-		if type(baseoid) in (list, tuple) and idx != None:
-			idx = str(idx)
+		if type(baseoid) in (list, tuple):
+			if idx not in ['', None]:
+				idx = '.' + str(idx)
+			else:
+				idx = ''
 
 			if self.options.snmpversion in [1, '1']:
-				value_low = long(self.SNMPGET_wrapper(baseoid[1] + '.' + idx, exitonerror=exitonerror))
+				value_low = long(self.SNMPGET_wrapper(baseoid[1] +  idx, exitonerror=exitonerror))
 				if value_low < 0L:
 					value_low += 2 ** 32
 
-				value_hi = long(self.SNMPGET_wrapper(baseoid[2] + '.' + idx, exitonerror=exitonerror))
+				value_hi = long(self.SNMPGET_wrapper(baseoid[2] + idx, exitonerror=exitonerror))
 				if value_hi < 0L:
 					value_hi += 2 ** 32
 
 				return value_hi * 2L ** 32L + value_low
 
 			elif self.options.snmpversion in [2, 3, '2', '2c', '3']:
-				return long(self.SNMPGET_wrapper(baseoid[0] + '.' + idx, exitonerror=exitonerror))
+				return long(self.SNMPGET_wrapper(baseoid[0] + idx, exitonerror=exitonerror))
 
 		elif type(baseoid) in (str, ) and idx != None:
 			return self.SNMPGET_wrapper(baseoid + str(idx), exitonerror=exitonerror)