New command line syntax
Signed-off-by: Sven Velt <sven@velt.de>
This commit is contained in:
parent
7a1e5339a9
commit
4e909d694f
87
check_naf.py
87
check_naf.py
|
@ -305,63 +305,68 @@ class CheckNAF(SNMPMonitoringPlugin):
|
||||||
def main():
|
def main():
|
||||||
plugin = CheckNAF(pluginname='check_naf', tagforstatusline='NAF', description=u'Monitoring NetApp™ FAS systems', version='0.9')
|
plugin = CheckNAF(pluginname='check_naf', tagforstatusline='NAF', description=u'Monitoring NetApp™ FAS systems', version='0.9')
|
||||||
|
|
||||||
plugin.add_cmdlineoption('', '--check', 'check', 'check or list of checks', default='')
|
plugin.add_cmdlineoption('', '--check', 'check', 'OBSOLETE - use new syntax!', default='')
|
||||||
plugin.add_cmdlineoption('', '--target', 'target', 'target or list of targets', default='')
|
plugin.add_cmdlineoption('', '--target', 'target', 'OBSOLETE - use new syntax!', default='')
|
||||||
plugin.add_cmdlineoption('-w', '', 'warn', 'warning thresold or a list of it', default='')
|
plugin.add_cmdlineoption('-w', '', 'warn', 'OBSOLETE - use new syntax!', default='')
|
||||||
plugin.add_cmdlineoption('-c', '', 'crit', 'warning thresold or a list of it', default='')
|
plugin.add_cmdlineoption('-c', '', 'crit', 'OBSOLETE - use new syntax!', default='')
|
||||||
plugin.parse_cmdlineoptions()
|
plugin.parse_cmdlineoptions()
|
||||||
|
|
||||||
plugin.prepare_snmp()
|
plugin.prepare_snmp()
|
||||||
|
|
||||||
if ',' in plugin.options.check:
|
if plugin.options.check or plugin.options.target:
|
||||||
checks = plugin.options.check.split(',')
|
import sys
|
||||||
checks.reverse()
|
arguments = plugin.options.check
|
||||||
else:
|
for s in [plugin.options.target, plugin.options.warn, plugin.options.crit]:
|
||||||
checks = [plugin.options.check,]
|
arguments += ':' + s
|
||||||
|
plugin.back2nagios(3, 'Obsolete syntax - please use new syntax: "%s %s"' % (sys.argv[0], arguments))
|
||||||
|
|
||||||
if ',' in plugin.options.target:
|
|
||||||
targets = plugin.options.target.split(',')
|
|
||||||
else:
|
|
||||||
targets = [plugin.options.target,]
|
|
||||||
|
|
||||||
while len(checks):
|
checks = []
|
||||||
check = checks.pop()
|
|
||||||
|
|
||||||
target = None
|
for quad in plugin.args:
|
||||||
arguments = None
|
quad = quad.split(':')
|
||||||
if ':' in check:
|
quad = (quad + ['', '', ''])[:4] # Fix length to 4, fill with ''
|
||||||
target = ':'.join(check.split(':')[1:])
|
|
||||||
check = check.split(':')[0]
|
# Convert list of checks to list
|
||||||
if ':' in target:
|
if ',' in quad[0]:
|
||||||
arguments = ':'.join(target.split(':')[1:])
|
quad[0] = quad[0].split(',')
|
||||||
target = target.split(':')[0]
|
else:
|
||||||
|
quad[0] = [quad[0],]
|
||||||
|
|
||||||
|
# Convert list of targets to list
|
||||||
|
if ',' in quad[1]:
|
||||||
|
quad[1] = quad[1].split(',')
|
||||||
|
else:
|
||||||
|
quad[1] = [quad[1],]
|
||||||
|
|
||||||
|
for target in quad[1]:
|
||||||
|
for check in quad[0]:
|
||||||
|
checks.append(tuple([check, target, quad[2], quad[3]]))
|
||||||
|
|
||||||
|
if len(checks) == 0:
|
||||||
|
plugin.back2nagios(3, 'No check specified!')
|
||||||
|
|
||||||
|
for quad in checks:
|
||||||
|
(check, target, warn, crit) = tuple(quad)
|
||||||
|
|
||||||
if check == 'global':
|
if check == 'global':
|
||||||
result = plugin.check_global()
|
result = plugin.check_global()
|
||||||
elif check == 'cpu':
|
elif check == 'cpu':
|
||||||
result = plugin.check_cpu()
|
result = plugin.check_cpu(warn=warn, crit=crit)
|
||||||
elif check == 'disk':
|
elif check == 'disk':
|
||||||
result = plugin.check_disk(target=target)
|
result = plugin.check_disk(target=target, warn=warn, crit=crit)
|
||||||
elif check == 'nvram':
|
elif check == 'nvram':
|
||||||
result = plugin.check_nvram()
|
result = plugin.check_nvram()
|
||||||
elif check == 'version':
|
elif check == 'version':
|
||||||
result = plugin.check_version()
|
result = plugin.check_version()
|
||||||
|
elif check == 'vol_data':
|
||||||
elif check.startswith('vol_'):
|
result = plugin.check_vol_data(volume=target, warn=warn, crit=crit)
|
||||||
combinedchecks = [check,]
|
elif check == 'vol_snap':
|
||||||
while len(checks) > 0 and checks[0].startswith('vol_'):
|
result = plugin.check_vol_snap(volume=target, warn=warn, crit=crit)
|
||||||
combinedchecks.append(checks.pop())
|
elif check =='vol_inode':
|
||||||
|
result = plugin.check_vol_inode(volume=target, warn=warn, crit=crit)
|
||||||
for target in targets:
|
elif check =='vol_files':
|
||||||
for check in combinedchecks:
|
result = plugin.check_vol_files(volume=target, warn=warn, crit=crit)
|
||||||
if check == 'vol_data':
|
|
||||||
result = plugin.check_vol_data(target, plugin.options.warn, plugin.options.crit)
|
|
||||||
elif check == 'vol_snap':
|
|
||||||
result = plugin.check_vol_snap(target, plugin.options.warn, plugin.options.crit)
|
|
||||||
elif check =='vol_inode':
|
|
||||||
result = plugin.check_vol_inode(target, plugin.options.warn, plugin.options.crit)
|
|
||||||
elif check =='vol_files':
|
|
||||||
result = plugin.check_vol_files(target, plugin.options.warn, plugin.options.crit)
|
|
||||||
|
|
||||||
# from pprint import pprint
|
# from pprint import pprint
|
||||||
# pprint(plugin.dump_brain())
|
# pprint(plugin.dump_brain())
|
||||||
|
|
Loading…
Reference in a new issue