File: //lib/python2.7/site-packages/lap/check-agents.py
import re
import sys
import yaml
import psutil
import ConfigParser
def checkagents(parse):
w_process = parse
count = 0
dict_count = {}
for proc in psutil.process_iter():
if proc.name == "mrq-worker":
if len(proc.cmdline) == 8:
param_proc = proc.cmdline[7]
if w_process in param_proc:
count_proc = proc.cmdline[6]
count += 1
else:
count_proc = 0
count -= 1
dict_count[w_process] = count
for key, value in dict_count.iteritems():
if value == -1:
check = 2
txt = "CRITICAL - No process %s in execution" % w_process
return check, txt
sys.exit(0)
elif int(value) < int(count_proc):
check = 1
txt = "WARNING - Worker %s with %s process in execution %s" % (w_process, value, count_proc)
return check, txt
sys.exit(0)
else:
check = 0
txt = "OK - Worker %s process is in normally execution" % w_process
return check, txt
def __run__(params):
parse = params.get("worker")
ch, t = checkagents(parse)
return [ch, t]