瀏覽代碼

Small collected fixes and improvments

Signed-off-by: Sven Velt <sven@velt.de>
Sven Velt 14 年之前
父節點
當前提交
634f1c5703
共有 2 個文件被更改,包括 12 次插入4 次删除
  1. 11 3
      check_naf.py
  2. 1 1
      monitoringplugin.py

+ 11 - 3
check_naf.py

@@ -124,6 +124,7 @@ class CheckNAF(SNMPMonitoringPlugin):
 			if di_spare > 1:
 				output += 's'
 		else:
+			target = 'failed' # Set to defined value
 			returncode = self.value_wc_to_returncode(di_failed, warn, crit)
 			if returncode == 0:
 				output = 'No failed disks'
@@ -199,8 +200,6 @@ class CheckNAF(SNMPMonitoringPlugin):
 		status = self.Status2String['df_FS_Status'].get(self.SNMPGET(self.OID['df_FS_Status'] + "." + idx))
 		fstype = self.Status2String['df_FS_Type'].get(self.SNMPGET(self.OID['df_FS_Type'] + "." + idx))
 
-		# print [mountedon, status, fstype]
-
 		fs_pctused = float(fs_used) / float(fs_total) * 100.0
 
 		warn = self.range_dehumanize(warn, fs_total)
@@ -322,12 +321,21 @@ def main():
 	while len(checks):
 		check = checks.pop()
 
+		target = None
+		arguments = None
+		if ':' in check:
+			target = ':'.join(check.split(':')[1:])
+			check = check.split(':')[0]
+			if ':' in target:
+				arguments = ':'.join(target.split(':')[1:])
+				target = target.split(':')[0]
+
 		if check == 'global':
 			result = plugin.check_global()
 		elif check == 'cpu':
 			result = plugin.check_cpu()
 		elif check == 'disk':
-			result = plugin.check_disk(target='spare')
+			result = plugin.check_disk(target=target)
 		elif check == 'nvram':
 			result = plugin.check_nvram()
 		elif check == 'version':

+ 1 - 1
monitoringplugin.py

@@ -150,7 +150,7 @@ class MonitoringPlugin(object):
 			perfdata += str(unit).lstrip().rstrip()
 		for key in ['warn', 'crit', 'min', 'max']:
 			perfdata += ';'
-			if key in kwargs:
+			if key in kwargs and kwargs[key]!=None:
 				perfdata += str(kwargs[key])
 
 		return perfdata