From 6973edd2c55a19cfdeeaae8e4bdb6bb336ce1b89 Mon Sep 17 00:00:00 2001 From: Nicolargo Date: Sun, 11 Jan 2015 22:05:30 +0100 Subject: [PATCH] Alarm for DiskIO plugin --- NEWS | 3 ++- conf/glances-test.conf | 14 ++++++++++++-- glances/plugins/glances_diskio.py | 20 ++++++++++++++------ glances/plugins/glances_network.py | 7 ++++--- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index ff3fc4b7..b2c1d556 100644 --- a/NEWS +++ b/NEWS @@ -14,7 +14,8 @@ Enhancements and news features: * The Web inteface is now based on BootStarp / RWD grid (issue #417, #366 and #461) Thanks to Nicolas Hart @nclsHart * Add the RAID plugin (issue #447) * Add the Docker plugin (issue #440) - * It is possible to define (through teh configuration file) if an alarm should be logged or not (using the _log option) (issue #437) + * It is possible, through the configuration file, to define if an alarm should be logged or not (using the _log option) (issue #437) + * You can now set alarm for Disk IO Bugs corrected: diff --git a/conf/glances-test.conf b/conf/glances-test.conf index e850a0f5..6e4444bf 100644 --- a/conf/glances-test.conf +++ b/conf/glances-test.conf @@ -56,7 +56,7 @@ critical=90 # Define the list of hidden network interfaces (comma separeted) hide=lo # WLAN0 alias name -#wlan0_alias=Wireless +wlan0_alias=Wireless # WLAN0 Default limits (in bits per second aka bps) for interface bitrate wlan0_rx_careful=4000000 wlan0_rx_warning=5000000 @@ -69,9 +69,19 @@ wlan0_tx_log=True [diskio] # Define the list of hidden disks (comma separeted) -hide=sda2,sda5 +hide=sda5 # Alias for sda1 #sda1_alias=IntDisk +# SDA1 limits (in bytes per second aka Bps) for interface bitrate +sda2_rx_careful=150000000 +sda2_rx_warning=180000000 +sda2_rx_critical=200000000 +#sda2_rx_log=True +sda2_tx_careful=150000000 +sda2_tx_warning=180000000 +sda2_tx_critical=200000000 +#sda2_tx_log=True + [fs] # Default limits for free filesytem space in % diff --git a/glances/plugins/glances_diskio.py b/glances/plugins/glances_diskio.py index 0cf68bec..5291c64d 100644 --- a/glances/plugins/glances_diskio.py +++ b/glances/plugins/glances_diskio.py @@ -43,7 +43,8 @@ class Plugin(GlancesPlugin): def __init__(self, args=None): """Init the plugin.""" - GlancesPlugin.__init__(self, args=args, items_history_list=items_history_list) + GlancesPlugin.__init__( + self, args=args, items_history_list=items_history_list) # We want to display the stat in the curse interface self.display_curse = True @@ -146,9 +147,10 @@ class Plugin(GlancesPlugin): if self.is_hide(i['disk_name']): continue # Is there an alias for the disk name ? + disk_real_name = i['disk_name'] disk_name = self.has_alias(i['disk_name']) if disk_name is None: - disk_name = i['disk_name'] + disk_name = disk_real_name # New line ret.append(self.curse_new_line()) if len(disk_name) > 9: @@ -156,11 +158,17 @@ class Plugin(GlancesPlugin): disk_name = '_' + disk_name[-8:] msg = '{0:9}'.format(disk_name) ret.append(self.curse_add_line(msg)) - txps = self.auto_unit(int(i['read_bytes'] // i['time_since_update'])) - rxps = self.auto_unit(int(i['write_bytes'] // i['time_since_update'])) + txps = self.auto_unit( + int(i['read_bytes'] // i['time_since_update'])) + rxps = self.auto_unit( + int(i['write_bytes'] // i['time_since_update'])) msg = '{0:>7}'.format(txps) - ret.append(self.curse_add_line(msg)) + ret.append(self.curse_add_line(msg, + self.get_alert(int(i['read_bytes'] // i['time_since_update']), + header=disk_real_name + '_rx'))) msg = '{0:>7}'.format(rxps) - ret.append(self.curse_add_line(msg)) + ret.append(self.curse_add_line(msg, + self.get_alert(int(i['write_bytes'] // i['time_since_update']), + header=disk_real_name + '_tx'))) return ret diff --git a/glances/plugins/glances_network.py b/glances/plugins/glances_network.py index 9ef8bc89..0b9dda94 100644 --- a/glances/plugins/glances_network.py +++ b/glances/plugins/glances_network.py @@ -236,9 +236,10 @@ class Plugin(GlancesPlugin): continue # Format stats # Is there an alias for the interface name ? + ifrealname = i['interface_name'].split(':')[0] ifname = self.has_alias(i['interface_name']) if ifname is None: - ifname = i['interface_name'].split(':')[0] + ifname = ifrealname if len(ifname) > ifname_max_width: # Cut interface name if it is too long ifname = '_' + ifname[-ifname_max_width + 1:] @@ -277,10 +278,10 @@ class Plugin(GlancesPlugin): msg = '{0:>7}'.format(rx) ret.append(self.curse_add_line( msg, self.get_alert(int(i['rx'] // i['time_since_update'] * 8), - header=ifname + '_rx'))) + header=ifrealname + '_rx'))) msg = '{0:>7}'.format(tx) ret.append(self.curse_add_line( msg, self.get_alert(int(i['tx'] // i['time_since_update'] * 8), - header=ifname + '_tx'))) + header=ifrealname + '_tx'))) return ret