import subprocess
def __run__(params):
try:
proc_name = params.get("proc_name")
p = subprocess.Popen(["ps", "-ely"], stdout=subprocess.PIPE)
out, err = p.communicate()
if (proc_name in out):
return [0,'OK: Process %s is running!' % proc_name]
else:
return [2, 'CRITICAL: Process %s is not running, check the service!' % proc_name]
except Exception, e:
return [2, 'CRITICAL: {0}'.format(str(e))]