diff options
author | Nicolas Hennion <nicolas@nicolargo.com> | 2014-03-28 13:48:53 +0100 |
---|---|---|
committer | Nicolas Hennion <nicolas@nicolargo.com> | 2014-03-28 13:48:53 +0100 |
commit | c00f48d5d503f722a593a83b44ccac400daeb586 (patch) | |
tree | 3bdd7457e2c14e506d86269399540527dd4d0fe4 | |
parent | 43885f8c3ffb4bf095cb6c7e109acf96f99937f7 (diff) |
Enable/disable for optionnal plugins
-rw-r--r-- | conf/glances.conf | 4 | ||||
-rw-r--r-- | glances/core/glances_main.py | 42 | ||||
-rw-r--r-- | glances/outputs/glances_curses.py | 21 | ||||
-rw-r--r-- | glances/plugins/glances_alert.py | 4 | ||||
-rw-r--r-- | glances/plugins/glances_diskio.py | 7 | ||||
-rw-r--r-- | glances/plugins/glances_fs.py | 6 | ||||
-rw-r--r-- | glances/plugins/glances_help.py | 12 | ||||
-rw-r--r-- | glances/plugins/glances_network.py | 4 | ||||
-rw-r--r-- | glances/plugins/glances_sensors.py | 4 |
9 files changed, 49 insertions, 55 deletions
diff --git a/conf/glances.conf b/conf/glances.conf index ab306d3d..cf3417f2 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -50,11 +50,11 @@ critical=90 [network] # Define the list of hidden network interfaces (comma separeted) -#hide=lo +hide=lo [diskio] # Define the list of hidden disks (comma separeted) -#hide=sda2,sda5 +hide=sda2,sda5 [fs] # Default limits for free filesytem space in % diff --git a/glances/core/glances_main.py b/glances/core/glances_main.py index 5940339e..a13c12ac 100644 --- a/glances/core/glances_main.py +++ b/glances/core/glances_main.py @@ -44,12 +44,12 @@ class GlancesMain(object): # Default network bitrate is display in bit per second network_bytepersec_tag = False # Display (or not) module - diskio_tag = True - fs_tag = True - hddtemp_flag = True - network_tag = True + # diskio_tag = True + # fs_tag = True + # hddtemp_flag = True + # network_tag = True + # sensors_tag = True process_tag = True - sensors_tag = True # Display property use_bold = True percpu_tag = False @@ -120,27 +120,27 @@ class GlancesMain(object): # Disable DiskIO module self.parser.add_argument('--disable_diskio', help=_('disable disk I/O module'), - action='store_false') - # Disable HDD temperature module - self.parser.add_argument('--disable_hddtemp', - help=_('disable HDD temperature module'), - action='store_false') + action='store_true') # Disable mount module - self.parser.add_argument('--disable_mount', - help=_('disable mount module'), - action='store_false') + self.parser.add_argument('--disable_fs', + help=_('disable file system (mount) module'), + action='store_true') # Disable network module self.parser.add_argument('--disable_network', help=_('disable network module'), - action='store_false') + action='store_true') # Enable sensors module self.parser.add_argument('--disable_sensors', help=_('disable sensors module'), - action='store_false') + action='store_true') # Disable process module self.parser.add_argument('--disable_process', help=_('disable process module'), - action='store_false') + action='store_true') + # Disable log module + self.parser.add_argument('--disable_log', + help=_('disable log module'), + action='store_true') # Bold attribute for Curse display (not supported by all terminal) self.parser.add_argument('-z', '--no_bold', @@ -202,12 +202,12 @@ class GlancesMain(object): # !!! To be refactor to use directly the args list in the code if (args.time is not None): self.refresh_time = args.time self.network_bytepersec_tag = args.byte - self.diskio_tag = args.disable_diskio - self.fs_tag = args.disable_mount - self.hddtemp_flag = args.disable_hddtemp - self.network_tag = args.disable_network + # self.diskio_tag = args.disable_diskio + # self.fs_tag = args.disable_mount + # self.hddtemp_flag = args.disable_hddtemp + # self.network_tag = args.disable_network self.process_tag = args.disable_process - self.sensors_tag = args.disable_sensors and is_Linux # and sensors_lib_tag + # self.sensors_tag = args.disable_sensors and is_Linux # and sensors_lib_tag self.use_bold = args.no_bold self.percpu_tag = args.percpu if (args.config is not None): diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index e4a879c6..31db75c9 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -189,35 +189,33 @@ class glancesCurses: elif self.pressedkey == ord('c'): # 'c' > Sort processes by CPU usage self.args.process_sorted_by = 'cpu_percent' - elif self.pressedkey == ord('d') and diskio_tag: + elif self.pressedkey == ord('d'): # 'd' > Show/hide disk I/O stats - self.diskio_tag = not self.diskio_tag - elif self.pressedkey == ord('f') and fs_tag: + self.args.disable_diskio = not self.args.disable_diskio + elif self.pressedkey == ord('f'): # 'f' > Show/hide fs stats - self.fs_tag = not self.fs_tag + self.args.disable_fs = not self.args.disable_fs elif self.pressedkey == ord('h'): # 'h' > Show/hide help self.args.help_tag = not self.args.help_tag elif self.pressedkey == ord('i'): - # elif self.pressedkey == ord('i') and psutil_get_io_counter_tag: - # !!! Manage IORate (non existing) on Mac OS # 'i' > Sort processes by IO rate (not available on OS X) self.args.process_sorted_by = 'io_counters' elif self.pressedkey == ord('l'): # 'l' > Show/hide log messages - self.log_tag = not self.log_tag + self.args.disable_log = not self.args.disable_log elif self.pressedkey == ord('m'): # 'm' > Sort processes by MEM usage self.args.process_sorted_by = 'memory_percent' - elif self.pressedkey == ord('n') and network_tag: + elif self.pressedkey == ord('n'): # 'n' > Show/hide network stats - self.network_tag = not self.network_tag + self.args.disable_network = not self.args.disable_network elif self.pressedkey == ord('p'): # 'p' > Sort processes by name self.args.process_sorted_by = 'name' elif self.pressedkey == ord('s'): # 's' > Show/hide sensors stats (Linux-only) - self.sensors_tag = not self.sensors_tag + self.args.disable_sensors = not self.args.disable_sensors elif self.pressedkey == ord('t'): # 't' > View network traffic as combination self.network_stats_combined = not self.network_stats_combined @@ -230,9 +228,6 @@ class glancesCurses: elif self.pressedkey == ord('x'): # 'x' > Delete finished warning and critical logs glances_logs.clean(critical=True) - elif self.pressedkey == ord('y'): - # 'y' > Show/hide hddtemp stats - self.hddtemp_tag = not self.hddtemp_tag # Return the key code return self.pressedkey diff --git a/glances/plugins/glances_alert.py b/glances/plugins/glances_alert.py index 9dc14cf8..fb4bfedd 100644 --- a/glances/plugins/glances_alert.py +++ b/glances/plugins/glances_alert.py @@ -60,6 +60,10 @@ class Plugin(GlancesPlugin): # Init the return message ret = [] + # Only process if display plugin enable... + if (args.disable_log): + return ret + # Build the string message # Header if (self.stats == []): diff --git a/glances/plugins/glances_diskio.py b/glances/plugins/glances_diskio.py index c3978589..8c139c97 100644 --- a/glances/plugins/glances_diskio.py +++ b/glances/plugins/glances_diskio.py @@ -108,14 +108,11 @@ class Plugin(GlancesPlugin): Return the dict to display in the curse interface """ - #!!! TODO: Add alert on disk IO - #!!! TODO: manage the hide tag for disk IO list - # Init the return message ret = [] - # Only process if stats exist... - if (self.stats == []): + # Only process if stats exist and display plugin enable... + if ((self.stats == []) or (args.disable_diskio)): return ret # Build the string message diff --git a/glances/plugins/glances_fs.py b/glances/plugins/glances_fs.py index 79ff6e93..898ff5dd 100644 --- a/glances/plugins/glances_fs.py +++ b/glances/plugins/glances_fs.py @@ -111,13 +111,13 @@ class Plugin(GlancesPlugin): # Init the return message ret = [] - # Only process if stats exist... - if (self.stats == []): + # Only process if stats exist and display plugin enable... + if ((self.stats == []) or (args.disable_fs)): return ret # Build the string message # Header - msg = "{0:8}".format(_("MOUNT")) + msg = "{0:8}".format(_("FILE SYS")) ret.append(self.curse_add_line(msg, "TITLE")) msg = " {0:>6}".format(_("Used")) ret.append(self.curse_add_line(msg)) diff --git a/glances/plugins/glances_help.py b/glances/plugins/glances_help.py index f0fa4314..6c2efa06 100644 --- a/glances/plugins/glances_help.py +++ b/glances/plugins/glances_help.py @@ -73,7 +73,7 @@ class Plugin(GlancesPlugin): ret.append(self.curse_new_line()) msg = msg_col.format(_("a"), _("Sort processes automatically")) ret.append(self.curse_add_line(msg)) - msg = msg_col2.format(_("l"), _("Show/hide logs")) + msg = msg_col2.format(_("l"), _("Show/hide logs (alerts)")) ret.append(self.curse_add_line(msg)) ret.append(self.curse_new_line()) msg = msg_col.format(_("c"), _("Sort processes by CPU%")) @@ -83,12 +83,12 @@ class Plugin(GlancesPlugin): ret.append(self.curse_new_line()) msg = msg_col.format(_("m"), _("Sort processes by MEM%")) ret.append(self.curse_add_line(msg)) - msg = msg_col2.format(_("w"), _("Delete warning logs")) + msg = msg_col2.format(_("w"), _("Delete warning alerts")) ret.append(self.curse_add_line(msg)) ret.append(self.curse_new_line()) msg = msg_col.format(_("p"), _("Sort processes by name")) ret.append(self.curse_add_line(msg)) - msg = msg_col2.format(_("x"), _("Delete warning and critical logs")) + msg = msg_col2.format(_("x"), _("Delete warning and critical alerts")) ret.append(self.curse_add_line(msg)) ret.append(self.curse_new_line()) msg = msg_col.format(_("i"), _("Sort processes by I/O rate")) @@ -113,12 +113,10 @@ class Plugin(GlancesPlugin): ret.append(self.curse_new_line()) msg = msg_col.format(_("s"), _("Show/hide sensors stats")) ret.append(self.curse_add_line(msg)) - msg = msg_col2.format(_("z"), _("Show/hide processes list")) + msg = msg_col2.format(_("z"), _("Disable all processes stats")) ret.append(self.curse_add_line(msg)) ret.append(self.curse_new_line()) - msg = msg_col.format(_("y"), _("Show/hide hddtemp stats")) - ret.append(self.curse_add_line(msg)) - msg = msg_col2.format(_("q"), _("Quit (Esc and Ctrl-C also work)")) + msg = msg_col.format(_("q"), _("Quit (Esc and Ctrl-C also work)")) ret.append(self.curse_add_line(msg)) # Return the message with decoration diff --git a/glances/plugins/glances_network.py b/glances/plugins/glances_network.py index ae89a954..f56ec531 100644 --- a/glances/plugins/glances_network.py +++ b/glances/plugins/glances_network.py @@ -113,8 +113,8 @@ class Plugin(GlancesPlugin): # Init the return message ret = [] - # Only process if stats exist... - if (self.stats == []): + # Only process if stats exist and display plugin enable... + if ((self.stats == []) or (args.disable_network)): return ret # Build the string message diff --git a/glances/plugins/glances_sensors.py b/glances/plugins/glances_sensors.py index 9d8140b9..195f9341 100644 --- a/glances/plugins/glances_sensors.py +++ b/glances/plugins/glances_sensors.py @@ -118,8 +118,8 @@ class Plugin(GlancesPlugin): # Init the return message ret = [] - # Only process if stats exist... - if self.stats == []: + # Only process if stats exist and display plugin enable... + if ((self.stats == []) or (args.disable_sensors)): return ret # Build the string message |