File: //usr/lib/python2.7/site-packages/lap/nagios_plugins.py
#!/usr/bin/python
import sys, os
import commands
def __run__(params):
try:
cmd = params.get('cmd')
if os.path.isdir("/usr/lib/nagios/plugins/"):
path = '/usr/lib/nagios/plugins/'
elif os.path.isdir("/usr/lib64/nagios/plugins/"):
path = '/usr/lib64/nagios/plugins/'
else:
return [ 1, 'WARNING: Plugin %s or nagios plugins package is not installed' % plugin ]
output = commands.getoutput('%s/%s' % ( path, cmd ))
if 'OK' in output:
return [ 0, "%s" % output ]
elif 'WAR' in output:
return [ 1, "%s" % output ]
else:
return [ 2, "%s" % output ]
except Exception, e:
return [2, 'CRITICAL: {0}'.format(str(e))]