mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Split monitor unit argument into separate arguments
This commit is contained in:
parent
ae1689e471
commit
0f2f59daf3
3 changed files with 72 additions and 44 deletions
|
@ -57,9 +57,9 @@ Specifications
|
||||||
|
|
||||||
### Monitoring
|
### Monitoring
|
||||||
|
|
||||||
yunohost monitor disk [-u {io,filesystem}] [-m]
|
yunohost monitor disk [-h] [-m MOUNTPOINT] [-t] [-f]
|
||||||
yunohost monitor network [-u {usage,infos}]
|
yunohost monitor network [-h] [-u] [-i]
|
||||||
yunohost monitor system [-u {memory,cpu,process,uptime,infos}]
|
yunohost monitor system [-h] [-m] [-u] [-i] [-p] [-c]
|
||||||
yunohost monitor process [-h] [-e PROCESS] [-d PROCESS]
|
yunohost monitor process [-h] [-e PROCESS] [-d PROCESS]
|
||||||
[--stop PROCESS] [-c PORT] [-i]
|
[--stop PROCESS] [-c PORT] [-i]
|
||||||
[--start PROCESS]
|
[--start PROCESS]
|
||||||
|
|
|
@ -428,40 +428,74 @@ monitor:
|
||||||
disk:
|
disk:
|
||||||
action_help: Monitor disk space and usage
|
action_help: Monitor disk space and usage
|
||||||
arguments:
|
arguments:
|
||||||
-u:
|
-f:
|
||||||
full: --unit
|
full: --filesystem
|
||||||
help: Unit to monitor
|
help: Show filesystem disk space
|
||||||
choices:
|
action: append_const
|
||||||
- io
|
const: filesystem
|
||||||
- filesystem
|
dest: units
|
||||||
|
-t:
|
||||||
|
full: --io
|
||||||
|
help: Show I/O throughput
|
||||||
|
action: append_const
|
||||||
|
const: io
|
||||||
|
dest: units
|
||||||
-m:
|
-m:
|
||||||
full: --mountpoint
|
full: --mountpoint
|
||||||
help: Device mountpoint
|
help: Monitor only the device mounted on MOUNTPOINT
|
||||||
|
action: store
|
||||||
|
|
||||||
### monitor_network()
|
### monitor_network()
|
||||||
network:
|
network:
|
||||||
action_help: Monitor network interfaces
|
action_help: Monitor network interfaces
|
||||||
arguments:
|
arguments:
|
||||||
-u:
|
-u:
|
||||||
full: --unit
|
full: --usage
|
||||||
help: Unit to monitor
|
help: Show interfaces bit rates
|
||||||
choices:
|
action: append_const
|
||||||
- usage
|
const: usage
|
||||||
- infos
|
dest: units
|
||||||
|
-i:
|
||||||
|
full: --infos
|
||||||
|
help: Show network informations
|
||||||
|
action: append_const
|
||||||
|
const: infos
|
||||||
|
dest: units
|
||||||
|
|
||||||
### monitor_system()
|
### monitor_system()
|
||||||
system:
|
system:
|
||||||
action_help: Monitor system informations and usage
|
action_help: Monitor system informations and usage
|
||||||
arguments:
|
arguments:
|
||||||
|
-m:
|
||||||
|
full: --memory
|
||||||
|
help: Show memory usage
|
||||||
|
action: append_const
|
||||||
|
const: memory
|
||||||
|
dest: units
|
||||||
|
-c:
|
||||||
|
full: --cpu
|
||||||
|
help: Show CPU usage and load
|
||||||
|
action: append_const
|
||||||
|
const: cpu
|
||||||
|
dest: units
|
||||||
|
-p:
|
||||||
|
full: --process
|
||||||
|
help: Show processes summary
|
||||||
|
action: append_const
|
||||||
|
const: process
|
||||||
|
dest: units
|
||||||
-u:
|
-u:
|
||||||
full: --unit
|
full: --uptime
|
||||||
help: Unit to monitor
|
help: Show the system uptime
|
||||||
choices:
|
action: append_const
|
||||||
- memory
|
const: uptime
|
||||||
- cpu
|
dest: units
|
||||||
- process
|
-i:
|
||||||
- uptime
|
full: --infos
|
||||||
- infos
|
help: Show system informations
|
||||||
|
action: append_const
|
||||||
|
const: infos
|
||||||
|
dest: units
|
||||||
|
|
||||||
process:
|
process:
|
||||||
action_help: Check Process
|
action_help: Check Process
|
||||||
|
|
|
@ -96,12 +96,12 @@ def process_check(args):
|
||||||
return { 'Status' : result }
|
return { 'Status' : result }
|
||||||
|
|
||||||
|
|
||||||
def monitor_disk(unit=None, mountpoint=None):
|
def monitor_disk(units=None, mountpoint=None):
|
||||||
"""
|
"""
|
||||||
Monitor disk space and usage
|
Monitor disk space and usage
|
||||||
|
|
||||||
Keyword argument:
|
Keyword argument:
|
||||||
unit -- Unit to monitor
|
units -- Unit(s) to monitor
|
||||||
mountpoint -- Device mountpoint
|
mountpoint -- Device mountpoint
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -109,10 +109,8 @@ def monitor_disk(unit=None, mountpoint=None):
|
||||||
result_dname = None
|
result_dname = None
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
if unit is None:
|
if units is None:
|
||||||
units = ['io', 'filesystem']
|
units = ['io', 'filesystem']
|
||||||
else:
|
|
||||||
units = [unit]
|
|
||||||
|
|
||||||
# Get mounted block devices
|
# Get mounted block devices
|
||||||
devices = {}
|
devices = {}
|
||||||
|
@ -122,7 +120,7 @@ def monitor_disk(unit=None, mountpoint=None):
|
||||||
if m and (mountpoint is None or m.group(2) == mountpoint):
|
if m and (mountpoint is None or m.group(2) == mountpoint):
|
||||||
(dn, dm) = (m.group(1), m.group(2))
|
(dn, dm) = (m.group(1), m.group(2))
|
||||||
devices[dn] = dm
|
devices[dn] = dm
|
||||||
result[dn] = {} if unit is None else []
|
result[dn] = {} if len(units) > 1 else []
|
||||||
result_dname = dn if mountpoint is not None else None
|
result_dname = dn if mountpoint is not None else None
|
||||||
if len(devices) == 0:
|
if len(devices) == 0:
|
||||||
raise YunoHostError(1, _("Unknown mountpoint '%s'") % mountpoint)
|
raise YunoHostError(1, _("Unknown mountpoint '%s'") % mountpoint)
|
||||||
|
@ -134,7 +132,7 @@ def monitor_disk(unit=None, mountpoint=None):
|
||||||
dname = d['disk_name']
|
dname = d['disk_name']
|
||||||
if dname in devices.keys():
|
if dname in devices.keys():
|
||||||
del d['disk_name']
|
del d['disk_name']
|
||||||
if unit is None:
|
if len(units) > 1:
|
||||||
result[dname][u] = d
|
result[dname][u] = d
|
||||||
else:
|
else:
|
||||||
d['mnt_point'] = devices[dname]
|
d['mnt_point'] = devices[dname]
|
||||||
|
@ -147,7 +145,7 @@ def monitor_disk(unit=None, mountpoint=None):
|
||||||
if dm != dmount:
|
if dm != dmount:
|
||||||
continue
|
continue
|
||||||
del d['device_name']
|
del d['device_name']
|
||||||
if unit is None:
|
if len(units) > 1:
|
||||||
result[dn][u] = d
|
result[dn][u] = d
|
||||||
else:
|
else:
|
||||||
result[dn] = d
|
result[dn] = d
|
||||||
|
@ -159,21 +157,19 @@ def monitor_disk(unit=None, mountpoint=None):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def monitor_network(unit=None):
|
def monitor_network(units=None):
|
||||||
"""
|
"""
|
||||||
Monitor network interfaces
|
Monitor network interfaces
|
||||||
|
|
||||||
Keyword argument:
|
Keyword argument:
|
||||||
unit -- Unit to monitor
|
units -- Unit(s) to monitor
|
||||||
|
|
||||||
"""
|
"""
|
||||||
glances = _get_glances_api()
|
glances = _get_glances_api()
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
if unit is None:
|
if units is None:
|
||||||
units = ['usage', 'infos']
|
units = ['usage', 'infos']
|
||||||
else:
|
|
||||||
units = [unit]
|
|
||||||
|
|
||||||
# Get network devices and their addresses
|
# Get network devices and their addresses
|
||||||
devices = {}
|
devices = {}
|
||||||
|
@ -219,25 +215,23 @@ def monitor_network(unit=None):
|
||||||
raise YunoHostError(1, _("Unknown unit '%s'") % u)
|
raise YunoHostError(1, _("Unknown unit '%s'") % u)
|
||||||
|
|
||||||
if len(units) == 1:
|
if len(units) == 1:
|
||||||
return result[unit]
|
return result[units[0]]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def monitor_system(unit=None):
|
def monitor_system(units=None):
|
||||||
"""
|
"""
|
||||||
Monitor system informations and usage
|
Monitor system informations and usage
|
||||||
|
|
||||||
Keyword argument:
|
Keyword argument:
|
||||||
unit -- Unit to monitor
|
units -- Unit(s) to monitor
|
||||||
|
|
||||||
"""
|
"""
|
||||||
glances = _get_glances_api()
|
glances = _get_glances_api()
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
if unit is None:
|
if units is None:
|
||||||
units = ['memory', 'cpu', 'process', 'uptime', 'infos']
|
units = ['memory', 'cpu', 'process', 'uptime', 'infos']
|
||||||
else:
|
|
||||||
units = [unit]
|
|
||||||
|
|
||||||
# Retrieve monitoring for unit(s)
|
# Retrieve monitoring for unit(s)
|
||||||
for u in units:
|
for u in units:
|
||||||
|
@ -260,8 +254,8 @@ def monitor_system(unit=None):
|
||||||
else:
|
else:
|
||||||
raise YunoHostError(1, _("Unknown unit '%s'") % u)
|
raise YunoHostError(1, _("Unknown unit '%s'") % u)
|
||||||
|
|
||||||
if len(units) == 1 and type(result[unit]) is not str:
|
if len(units) == 1 and type(result[units[0]]) is not str:
|
||||||
return result[unit]
|
return result[units[0]]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue