diff options
author | Nicolargo <nicolas@nicolargo.com> | 2014-05-26 12:56:40 +0200 |
---|---|---|
committer | Nicolargo <nicolas@nicolargo.com> | 2014-05-26 12:56:40 +0200 |
commit | 5961a947dbad5e73032a177d24d90be84f0303c3 (patch) | |
tree | 06fbd8678cca9d1379695348f754e3c2c9507c9e | |
parent | 87258ebf95c413eb2d89258dbb9c406b6d2891d5 (diff) |
Reactive limits for sensors
-rw-r--r-- | conf/glances-monitor.conf | 22 | ||||
-rw-r--r-- | conf/glances.conf | 22 | ||||
-rw-r--r-- | glances/plugins/glances_sensors.py | 22 |
3 files changed, 42 insertions, 24 deletions
diff --git a/conf/glances-monitor.conf b/conf/glances-monitor.conf index ef9ad2cd..a696149c 100644 --- a/conf/glances-monitor.conf +++ b/conf/glances-monitor.conf @@ -63,19 +63,21 @@ careful=50 warning=70 critical=90 -[temperature] -# Temperatures in °C for sensors +[sensors] +# Sensors core limits # Default values if not defined: 60/70/80 -careful=60 -warning=70 -critical=80 - -[hddtemperature] +temperature_core_careful=60 +temperature_core_warning=70 +temperature_core_critical=80 # Temperatures in °C for hddtemp # Default values if not defined: 45/52/60 -careful=45 -warning=52 -critical=60 +temperature_hdd_careful=45 +temperature_hdd_warning=52 +temperature_hdd_critical=60 +# Batterie % limits +batterie_careful=80 +batterie_warning=90 +batterie_critical=95 [processlist] # Limit values for CPU/MEM per process in % diff --git a/conf/glances.conf b/conf/glances.conf index cf3417f2..08c01923 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -63,19 +63,21 @@ careful=50 warning=70 critical=90 -[temperature] -# Temperatures in °C for sensors +[sensors] +# Sensors core limits # Default values if not defined: 60/70/80 -careful=60 -warning=70 -critical=80 - -[hddtemperature] +temperature_core_careful=60 +temperature_core_warning=70 +temperature_core_critical=80 # Temperatures in °C for hddtemp # Default values if not defined: 45/52/60 -careful=45 -warning=52 -critical=60 +temperature_hdd_careful=45 +temperature_hdd_warning=52 +temperature_hdd_critical=60 +# Batterie % limits +batterie_careful=80 +batterie_warning=90 +batterie_critical=95 [processlist] # Limit values for CPU/MEM per process in % diff --git a/glances/plugins/glances_sensors.py b/glances/plugins/glances_sensors.py index 8f754543..9b72eac0 100644 --- a/glances/plugins/glances_sensors.py +++ b/glances/plugins/glances_sensors.py @@ -80,12 +80,12 @@ class Plugin(GlancesPlugin): if self.get_input() == 'local': # Update stats using the standard system lib - self.stats = self.glancesgrabsensors.get() + self.stats = self.__set_type(self.glancesgrabsensors.get(), 'temperature_core') # Append HDD temperature - hddtemp = self.hddtemp_plugin.update() + hddtemp = self.__set_type(self.hddtemp_plugin.update(), 'temperature_hdd') self.stats.extend(hddtemp) # Append Batteries % - batpercent = self.batpercent_plugin.update() + batpercent = self.__set_type(self.batpercent_plugin.update(), 'batterie') self.stats.extend(batpercent) elif self.get_input() == 'snmp': # Update stats using SNMP @@ -94,6 +94,17 @@ class Plugin(GlancesPlugin): return self.stats + def __set_type(self, stats, sensor_type): + """ + 3 types of stats is possible in the Sensors plugins: + - Core temperature + - HDD temperature + - Batterie capacity + """ + for i in stats: + i.update({ 'type': sensor_type }) + return stats + def msg_curse(self, args=None): """ Return the dict to display in the curse interface @@ -121,7 +132,10 @@ class Plugin(GlancesPlugin): msg = "{0:18}".format(item['label'][:18]) ret.append(self.curse_add_line(msg)) msg = "{0:>5}".format(item['value']) - ret.append(self.curse_add_line(msg)) + if item['type'] == 'batterie': + ret.append(self.curse_add_line(msg, self.get_alert(100 - item['value'], header=item['type']))) + else: + ret.append(self.curse_add_line(msg, self.get_alert(item['value'], header=item['type']))) return ret |