Possibilité de monitorer un service en regardant dans les processes.

This commit is contained in:
Pierre-Elliott Bécue 2014-10-29 00:14:40 +01:00
parent 34876f3b55
commit 705a9cb101

View file

@ -22,12 +22,25 @@ def service(group=None, **kw):
if group == None or has(group):
name = kw.get('name', group)
init = kw.get('init', name)
pidp = kw.get('pidp', "/var/run/%s.pid" % kw.get('pidf', name))
pid = kw.get("pidp", "")
matching = kw.get("matching", False)
if pid:
pidp = "with pidfile %s" % (pid,)
elif matching:
pidp = ""
else:
pidp = "with pidfile /var/run/%s.pid" % kw.get('pidf', name)
if matching:
matchingp = 'matching "%s"' % (name)
else:
matchingp = ''
start_cmd = kw.get('start_cmd', '/etc/init.d/%s start' % init)
stop_cmd = kw.get('stop_cmd', '/etc/init.d/%s stop' % init)
print ('''# %(name)s
check process %(name)s with pidfile %(pidp)s
start program = "%(start_cmd)s"
print ("""# %(name)s
check process %(name)s %(pidp)s""" % locals())
if matchingp:
print " %s" % (matchingp,)
print (''' start program = "%(start_cmd)s"
stop program = "%(stop_cmd)s"''' % locals())
max_restart = kw.get('max_restart', 5)
@ -230,7 +243,7 @@ service("pgsql-server",
extra=["if failed port 5432 timeout 30 seconds then restart"])
service("identd",
name="oidentd")
name="oidentd", matching=True)
service("postfix",
pidp="/var/spool/postfix/pid/master.pid",