summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--conf/glances.conf11
-rw-r--r--docs/aoa/network.rst35
-rw-r--r--glances/config.py10
-rw-r--r--glances/plugins/glances_network.py24
5 files changed, 71 insertions, 10 deletions
diff --git a/NEWS b/NEWS
index d79fbeeb..2dc96899 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Enhancements and news features:
* Add ZeroMQ exporter (issue #939)
* Add CouchDB exporter (issue #928)
* Add hotspot Wifi informations (issue #937)
+ * Add default interface speed and automatic rate thresolds (issue #718)
* Highlight max stats in the processes list (issue #878)
* Docker alerts and actions (issue #875)
* Glances API returns the processes PPID (issue #926)
diff --git a/conf/glances.conf b/conf/glances.conf
index 57b048f5..990da6ec 100644
--- a/conf/glances.conf
+++ b/conf/glances.conf
@@ -96,11 +96,20 @@ careful=50
warning=70
critical=90
-#[network]
+[network]
+# Default bitrate thresholds in % of the network interface speed
+# Default values if not defined: 70/80/90
+rx_careful=70
+rx_warning=80
+rx_critical=90
+tx_careful=70
+tx_warning=80
+tx_critical=90
# Define the list of hidden network interfaces (comma-separated regexp)
#hide=docker.*,lo
# WLAN 0 alias
#wlan0_alias=Wireless IF
+# It is possible to overwrite the bitrate thresholds per interface
# WLAN 0 Default limits (in bits per second aka bps) for interface bitrate
#wlan0_rx_careful=4000000
#wlan0_rx_warning=5000000
diff --git a/docs/aoa/network.rst b/docs/aoa/network.rst
index 09c25792..c27aba50 100644
--- a/docs/aoa/network.rst
+++ b/docs/aoa/network.rst
@@ -8,16 +8,20 @@ Network
Glances displays the network interface bit rate. The unit is adapted
dynamically (bit/s, kbit/s, Mbit/s, etc).
-Alerts are only set if the maximum speed per network interface is
-available (see sample in the configuration file).
+If the interface speed is detected (not on all systems), the defaults
+thresholds are applied (70% for careful, 80% warning and 90% critical).
+It is possible to define this percents thresholds form the configuration
+file. It is also possible to define per interface bit rate thresholds.
+In this case thresholds values are define in bps.
-It's also possible to define:
+Additionally, you can define:
- a list of network interfaces to hide
- per-interface limit values
- aliases for interface name
-in the ``[network]`` section of the configuration file.
+The configuration should be done in the ``[network]`` section of the
+Glances configuration file.
For example, if you want to hide the loopback interface (lo) and all the
virtual docker interface (docker0, docker1, ...):
@@ -25,4 +29,25 @@ virtual docker interface (docker0, docker1, ...):
.. code-block:: ini
[network]
- hide=lo,docker.*
+ # Default bitrate thresholds in % of the network interface speed
+ # Default values if not defined: 70/80/90
+ rx_careful=70
+ rx_warning=80
+ rx_critical=90
+ tx_careful=70
+ tx_warning=80
+ tx_critical=90
+ # Define the list of hidden network interfaces (comma-separated regexp)
+ hide=docker.*,lo
+ # WLAN 0 alias
+ wlan0_alias=Wireless IF
+ # It is possible to overwrite the bitrate thresholds per interface
+ # WLAN 0 Default limits (in bits per second aka bps) for interface bitrate
+ wlan0_rx_careful=4000000
+ wlan0_rx_warning=5000000
+ wlan0_rx_critical=6000000
+ wlan0_rx_log=True
+ wlan0_tx_careful=700000
+ wlan0_tx_warning=900000
+ wlan0_tx_critical=1000000
+ wlan0_tx_log=True
diff --git a/glances/config.py b/glances/config.py
index 309e257d..77375ad0 100644
--- a/glances/config.py
+++ b/glances/config.py
@@ -172,6 +172,16 @@ class Config(object):
self.set_default('memswap', 'warning', '70')
self.set_default('memswap', 'critical', '90')
+ # NETWORK
+ if not self.parser.has_section('network'):
+ self.parser.add_section('network')
+ self.set_default('network', 'rx_careful', '70')
+ self.set_default('network', 'rx_warning', '80')
+ self.set_default('network', 'rx_critical', '90')
+ self.set_default('network', 'tx_careful', '70')
+ self.set_default('network', 'tx_warning', '80')
+ self.set_default('network', 'tx_critical', '90')
+
# FS
if not self.parser.has_section('fs'):
self.parser.add_section('fs')
diff --git a/glances/plugins/glances_network.py b/glances/plugins/glances_network.py
index e2393f21..7b8c5e1d 100644
--- a/glances/plugins/glances_network.py
+++ b/glances/plugins/glances_network.py
@@ -22,6 +22,7 @@
import base64
import operator
+from glances.logger import logger
from glances.timer import getTimeSinceLastUpdate
from glances.plugins.glances_plugin import GlancesPlugin
@@ -240,10 +241,25 @@ class Plugin(GlancesPlugin):
# Alert
for i in self.stats:
ifrealname = i['interface_name'].split(':')[0]
- self.views[i[self.get_key()]]['rx']['decoration'] = self.get_alert(int(i['rx'] // i['time_since_update'] * 8),
- header=ifrealname + '_rx')
- self.views[i[self.get_key()]]['tx']['decoration'] = self.get_alert(int(i['tx'] // i['time_since_update'] * 8),
- header=ifrealname + '_tx')
+ # Convert rate in bps ( to be able to compare to interface speed)
+ bps_rx = int(i['rx'] // i['time_since_update'] * 8)
+ bps_tx = int(i['tx'] // i['time_since_update'] * 8)
+ # Decorate the bitrate with the configuration file thresolds
+ alert_rx = self.get_alert(bps_rx, header=ifrealname + '_rx')
+ alert_tx = self.get_alert(bps_tx, header=ifrealname + '_tx')
+ # If nothing is define in the configuration file...
+ # ... then use the interface speed (not available on all systems)
+ if alert_rx == 'DEFAULT' and 'speed' in i and i['speed'] != 0:
+ alert_rx = self.get_alert(current=bps_rx,
+ maximum=i['speed'],
+ header='rx')
+ if alert_tx == 'DEFAULT' and 'speed' in i and i['speed'] != 0:
+ alert_tx = self.get_alert(current=bps_tx,
+ maximum=i['speed'],
+ header='tx')
+ # then decorates
+ self.views[i[self.get_key()]]['rx']['decoration'] = alert_rx
+ self.views[i[self.get_key()]]['tx']['decoration'] = alert_tx
def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""