Add test-status to have a custom status check for service like postfix and yunohost-firewall

This commit is contained in:
Alexandre Aubin 2019-11-05 21:47:33 +01:00
parent 08c23599e2
commit d879d27208
2 changed files with 7 additions and 0 deletions

View file

@ -10,6 +10,7 @@ dovecot:
log: [/var/log/mail.log,/var/log/mail.err]
postfix:
log: [/var/log/mail.log,/var/log/mail.err]
test-status: systemctl show postfix@- | grep -q "^SubState=running"
rspamd:
log: /var/log/rspamd/rspamd.log
redis-server:
@ -29,6 +30,7 @@ yunohost-api:
log: /var/log/yunohost/yunohost-api.log
yunohost-firewall:
need_lock: true
test-status: iptables -S | grep "^-A INPUT" | grep " --dport" | grep -q ACCEPT
nslcd:
log: /var/log/syslog
glances: null

View file

@ -330,6 +330,11 @@ def service_status(names=[]):
else:
result[name]['active_at'] = "unknown"
# 'test-status' is an optional field to test the status of the service using a custom command
if "test-status" in services[name]:
status = os.system(services[name]["test-status"])
result[name]["status"] = "running" if status == 0 else "failed"
if len(names) == 1:
return result[names[0]]
return result