From 1f8e6efe8ca2be5d9cb9be3d1a4e18b659157c2d Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sat, 12 Oct 2019 11:21:47 +0200 Subject: [PATCH] Add --enable-plugin options from the command line --- docs/aoa/sensors.rst | 3 +++ docs/cmds.rst | 4 ++++ docs/config.rst | 2 +- docs/man/glances.1 | 12 ++++++++++-- glances/main.py | 12 ++++++++++-- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/docs/aoa/sensors.rst b/docs/aoa/sensors.rst index 6f697dc4..9aca0b5d 100644 --- a/docs/aoa/sensors.rst +++ b/docs/aoa/sensors.rst @@ -15,3 +15,6 @@ There is no alert on this information. .. note:: Limit values and sensors alias names can be defined in the configuration file under the ``[sensors]`` section. + +.. note:: + This plugin is disabled by default in the configuration file. diff --git a/docs/cmds.rst b/docs/cmds.rst index 3b85cc28..a4c88179 100644 --- a/docs/cmds.rst +++ b/docs/cmds.rst @@ -30,6 +30,10 @@ Command-Line Options disable PLUGIN (comma separed list) +.. option:: --enable-plugin PLUGIN + + enable PLUGIN (comma separed list) + .. option:: --stdout PLUGINS_STATS display stats to stdout (comma separated list of plugins/plugins.attribute) diff --git a/docs/config.rst b/docs/config.rst index 60edfbfe..875a2b35 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -48,7 +48,7 @@ have a section. Below an example for the CPU plugin: .. code-block:: ini [cpu] - disable=false + disable=False user_careful=50 user_warning=70 user_critical=90 diff --git a/docs/man/glances.1 b/docs/man/glances.1 index 290f76da..6789fcc3 100644 --- a/docs/man/glances.1 +++ b/docs/man/glances.1 @@ -1,6 +1,6 @@ .\" Man page generated from reStructuredText. . -.TH "GLANCES" "1" "Oct 07, 2019" "3.1.3_BETA" "Glances" +.TH "GLANCES" "1" "Oct 12, 2019" "3.1.3_BETA" "Glances" .SH NAME glances \- An eye on your system . @@ -78,6 +78,11 @@ disable PLUGIN (comma separed list) .UNINDENT .INDENT 0.0 .TP +.B \-\-enable\-plugin PLUGIN +enable PLUGIN (comma separed list) +.UNINDENT +.INDENT 0.0 +.TP .B \-\-stdout PLUGINS_STATS display stats to stdout (comma separated list of plugins/plugins.attribute) .UNINDENT @@ -389,6 +394,9 @@ Sort processes by I/O rate .B \fBI\fP Show/hide IP module .TP +.B \fBk\fP +Show/hide TCP connections +.TP .B \fBl\fP Show/hide log messages .TP @@ -569,7 +577,7 @@ have a section. Below an example for the CPU plugin: .nf .ft C [cpu] -disable=false +disable=False user_careful=50 user_warning=70 user_critical=90 diff --git a/glances/main.py b/glances/main.py index 18bc71ff..53ca7782 100644 --- a/glances/main.py +++ b/glances/main.py @@ -98,8 +98,11 @@ Examples of use: Display CSV stats to stdout (all stats in one line): $ glances --stdout-csv now,cpu.user,mem.used,load - Disable some plugins (any modes): + Disable some plugins (comma separated list): $ glances --disable-plugin network,ports + + Enable some plugins (comma separated list): + $ glances --enable-plugin sensors """ def __init__(self): @@ -126,8 +129,10 @@ Examples of use: action='store_true', default=False, dest='modules_list', help='display modules (plugins & exports) list and exit') - parser.add_argument('--disable-plugin', dest='disable_plugin', + parser.add_argument('--disable-plugin', '--disable-plugins', dest='disable_plugin', help='disable plugin (comma separed list)') + parser.add_argument('--enable-plugin', '--enable-plugins', dest='enable_plugin', + help='enable plugin (comma separed list)') parser.add_argument('--disable-process', action='store_true', default=False, dest='disable_process', help='disable process module') # Enable or disable option @@ -277,6 +282,9 @@ Examples of use: if args.disable_plugin is not None: for p in args.disable_plugin.split(','): disable(args, p) + if args.enable_plugin is not None: + for p in args.enable_plugin.split(','): + enable(args, p) # Exporters activation if args.export is not None: