mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
change yunohost check process
This commit is contained in:
parent
bf65f93f8e
commit
85f2706ea6
2 changed files with 26 additions and 11 deletions
|
@ -436,7 +436,7 @@ monitor:
|
||||||
-c:
|
-c:
|
||||||
full: --check
|
full: --check
|
||||||
help: Check process
|
help: Check process
|
||||||
metavar: PORT
|
action: store_true
|
||||||
-i:
|
-i:
|
||||||
full: --info
|
full: --info
|
||||||
help: Process info
|
help: Process info
|
||||||
|
|
|
@ -29,6 +29,17 @@ import psutil
|
||||||
from urllib import urlopen
|
from urllib import urlopen
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from yunohost import YunoHostError, win_msg, colorize, validate, get_required_args
|
from yunohost import YunoHostError, win_msg, colorize, validate, get_required_args
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
try:
|
||||||
|
import yaml
|
||||||
|
except ImportError:
|
||||||
|
sys.stderr.write('Error: Yunohost CLI Require yaml lib\n')
|
||||||
|
sys.stderr.write('apt-get install python-yaml\n')
|
||||||
|
sys.exit(1)
|
||||||
|
import json
|
||||||
|
if not __debug__:
|
||||||
|
import traceback
|
||||||
|
|
||||||
s = xmlrpclib.ServerProxy('http://127.0.0.1:61209')
|
s = xmlrpclib.ServerProxy('http://127.0.0.1:61209')
|
||||||
|
|
||||||
|
@ -73,17 +84,21 @@ 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):
|
||||||
ip = public()['Public IP']
|
with open('process.yml', 'r') as f:
|
||||||
output = os.system('/usr/lib/nagios/plugins/check_tcp -H localhost -p' + args + ' > /dev/null')
|
process = yaml.load(f)
|
||||||
if output == 0:
|
|
||||||
output = os.system('/usr/lib/nagios/plugins/check_tcp -H ' + ip + ' -p' + args + ' > /dev/null')
|
for i in process:
|
||||||
if output == 0:
|
cmd = process[i]['command']
|
||||||
return { 'Port' : args + " " + _("is open") }
|
if cmd == 'service':
|
||||||
|
status = os.system("service " + i + " status")
|
||||||
else:
|
else:
|
||||||
return { 'Warning' : args + " " + _("is closed in your box") }
|
status = os.system(cmd)
|
||||||
|
if status == 0:
|
||||||
|
return { i + " " + _("is up") }
|
||||||
else:
|
else:
|
||||||
raise YunoHostError(1, args + " " + _("is closed") )
|
raise YunoHostError(1, i + " " + _("is down") )
|
||||||
|
|
||||||
|
|
||||||
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):
|
||||||
|
@ -137,7 +152,7 @@ def monitor_info(memory=False, cpu=False, disk=False, ifconfig=False, uptime=Fal
|
||||||
else:
|
else:
|
||||||
raise YunoHostError(1, _('No arguments provided'))
|
raise YunoHostError(1, _('No arguments provided'))
|
||||||
|
|
||||||
def monitor_process(enable=None, disable=None, start=None, stop=None, check=None, info=False):
|
def monitor_process(enable=None, disable=None, start=None, stop=None, check=False, info=False):
|
||||||
"""
|
"""
|
||||||
Check Process
|
Check Process
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue