check process ok

This commit is contained in:
Adrien Beudin 2013-10-01 12:44:39 +02:00
parent 17ca215e3b
commit 21877f6e7b
2 changed files with 14 additions and 13 deletions

View file

@ -1,4 +1,4 @@
glances: glances:
command: service status: service
tahoe-lafs: tahoe-lafs:
command: ps aux | grep tahoe |grep -v grep status: ps aux | grep tahoe |grep -v grep

View file

@ -84,22 +84,23 @@ def process_stop(args):
else: else:
raise YunoHostError(1, 'Stop : ' + args.title() + " " + _("failure")) raise YunoHostError(1, 'Stop : ' + args.title() + " " + _("failure"))
def process_check(args): def process_check(args):
with open('process.yml', 'r') as f: with open('process.yml', 'r') as f:
process = yaml.load(f) processes = yaml.load(f)
for i in process: result = {}
cmd = process[i]['command'] for process, commands in processes.items():
if cmd == 'service': if commands['status'] == 'service':
status = os.system("service " + i + " status") cmd = "service " + process + " status"
else: else:
status = os.system(cmd) cmd = commands['status']
if status == 0:
return { i + " " + _("is up") }
else:
raise YunoHostError(1, i + " " + _("is down") )
if os.system(cmd + " > /dev/null 2>&1") == 0:
result.update({ process : _('Running') })
else:
result.update({ process : _('Down') })
return { 'Status' : result }
def monitor_info(memory=False, cpu=False, disk=False, ifconfig=False, uptime=False, public=False): def monitor_info(memory=False, cpu=False, disk=False, ifconfig=False, uptime=False, public=False):
""" """