mirror of https://github.com/nicolargo/glances.git
Enhancement Request: .conf parameter for AMP #1690
This commit is contained in:
parent
219c4de08f
commit
05897a61dd
|
|
@ -572,8 +572,9 @@ countmax=20
|
|||
|
||||
[amp_conntrack]
|
||||
# Use comma separated for multiple commands (no space around the comma)
|
||||
# If the regex key is not defined, the AMP will be executed every refresh second
|
||||
# and the process count will not be displayed (countmin and countmax will be ignore)
|
||||
enable=false
|
||||
regex=\/sbin\/init
|
||||
refresh=30
|
||||
one_line=false
|
||||
command=sysctl net.netfilter.nf_conntrack_count;sysctl net.netfilter.nf_conntrack_max
|
||||
|
|
|
|||
|
|
@ -49,6 +49,20 @@ less than countmin):
|
|||
|
||||
.. image:: ../_static/amp-python-warning.png
|
||||
|
||||
If the regex option is not defined, the AMP will be executed every refresh
|
||||
time and the process count will not be displayed (countmin and countmax will
|
||||
be ignored).
|
||||
|
||||
For example:
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
[amp_conntrack]
|
||||
enable=false
|
||||
refresh=30
|
||||
one_line=false
|
||||
command=sysctl net.netfilter.nf_conntrack_count;sysctl net.netfilter.nf_conntrack_max
|
||||
|
||||
User defined AMP
|
||||
----------------
|
||||
|
||||
|
|
|
|||
|
|
@ -99,12 +99,11 @@ class GlancesAmp(object):
|
|||
logger.debug("AMP - {}: Can not find section {} in the configuration file".format(self.NAME, self.amp_name))
|
||||
return False
|
||||
|
||||
# enable, regex and refresh are mandatories
|
||||
# if not configured then AMP is disabled
|
||||
if self.enable():
|
||||
for k in ['regex', 'refresh']:
|
||||
# Refresh option is mandatory
|
||||
for k in ['refresh']:
|
||||
if k not in self.configs:
|
||||
logger.warning("AMP - {}: Can not find configuration key {} in section {}".format(self.NAME, k, self.amp_name))
|
||||
logger.warning("AMP - {}: Can not find configuration key {} in section {} (the AMP will be disabled)".format(self.NAME, k, self.amp_name))
|
||||
self.configs['enable'] = 'false'
|
||||
else:
|
||||
logger.debug("AMP - {} is disabled".format(self.NAME))
|
||||
|
|
|
|||
|
|
@ -112,6 +112,14 @@ class AmpsList(object):
|
|||
if not v.enable():
|
||||
# Do not update if the enable tag is set
|
||||
continue
|
||||
|
||||
if v.regex() is None:
|
||||
# If there is no regex, execute anyway (see issue #1690)
|
||||
v.set_count(0)
|
||||
# Call the AMP update method
|
||||
thread = threading.Thread(target=v.update_wrapper, args=[[]])
|
||||
thread.start()
|
||||
continue
|
||||
|
||||
amps_list = self._build_amps_list(v, processlist)
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,9 @@ class Plugin(GlancesPlugin):
|
|||
'timer': v.time_until_refresh(),
|
||||
'count': v.count(),
|
||||
'countmin': v.count_min(),
|
||||
'countmax': v.count_max()})
|
||||
'countmax': v.count_max(),
|
||||
'regex': v.regex() is not None},
|
||||
)
|
||||
else:
|
||||
# Not available in SNMP mode
|
||||
pass
|
||||
|
|
@ -103,7 +105,7 @@ class Plugin(GlancesPlugin):
|
|||
# Display AMP
|
||||
first_column = '{}'.format(m['name'])
|
||||
first_column_style = self.get_alert(m['count'], m['countmin'], m['countmax'])
|
||||
second_column = '{}'.format(m['count'])
|
||||
second_column = '{}'.format(m['count'] if m['regex'] else '')
|
||||
for l in m['result'].split('\n'):
|
||||
# Display first column with the process name...
|
||||
msg = '{:<16} '.format(first_column)
|
||||
|
|
|
|||
Loading…
Reference in New Issue