Possibilité de monitorer un service en regardant dans les processes.
This commit is contained in:
parent
34876f3b55
commit
705a9cb101
1 changed files with 18 additions and 5 deletions
|
@ -22,12 +22,25 @@ def service(group=None, **kw):
|
||||||
if group == None or has(group):
|
if group == None or has(group):
|
||||||
name = kw.get('name', group)
|
name = kw.get('name', group)
|
||||||
init = kw.get('init', name)
|
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)
|
start_cmd = kw.get('start_cmd', '/etc/init.d/%s start' % init)
|
||||||
stop_cmd = kw.get('stop_cmd', '/etc/init.d/%s stop' % init)
|
stop_cmd = kw.get('stop_cmd', '/etc/init.d/%s stop' % init)
|
||||||
print ('''# %(name)s
|
print ("""# %(name)s
|
||||||
check process %(name)s with pidfile %(pidp)s
|
check process %(name)s %(pidp)s""" % locals())
|
||||||
start program = "%(start_cmd)s"
|
if matchingp:
|
||||||
|
print " %s" % (matchingp,)
|
||||||
|
print (''' start program = "%(start_cmd)s"
|
||||||
stop program = "%(stop_cmd)s"''' % locals())
|
stop program = "%(stop_cmd)s"''' % locals())
|
||||||
|
|
||||||
max_restart = kw.get('max_restart', 5)
|
max_restart = kw.get('max_restart', 5)
|
||||||
|
@ -230,7 +243,7 @@ service("pgsql-server",
|
||||||
extra=["if failed port 5432 timeout 30 seconds then restart"])
|
extra=["if failed port 5432 timeout 30 seconds then restart"])
|
||||||
|
|
||||||
service("identd",
|
service("identd",
|
||||||
name="oidentd")
|
name="oidentd", matching=True)
|
||||||
|
|
||||||
service("postfix",
|
service("postfix",
|
||||||
pidp="/var/spool/postfix/pid/master.pid",
|
pidp="/var/spool/postfix/pid/master.pid",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue