mirror of
https://github.com/nicolargo/glances.git
synced 2026-03-13 11:28:12 -04:00
Get system sensors temperatures thresholds #1864
This commit is contained in:
@@ -263,10 +263,10 @@ disable=False
|
||||
# Hide some sensors
|
||||
#hide=ambient
|
||||
# Sensors core thresholds (in Celsius...)
|
||||
# Default values if not defined: 60/70/80
|
||||
temperature_core_careful=60
|
||||
temperature_core_warning=70
|
||||
temperature_core_critical=80
|
||||
# Default values are grabbed from the system
|
||||
#temperature_core_careful=60
|
||||
#temperature_core_warning=70
|
||||
#temperature_core_critical=80
|
||||
# Temperatures threshold in °C for hddtemp
|
||||
# Default values if not defined: 45/52/60
|
||||
temperature_hdd_careful=45
|
||||
|
||||
@@ -603,7 +603,7 @@ class GlancesPlugin(object):
|
||||
return self.get_refresh()
|
||||
|
||||
def set_limits(self, item, value):
|
||||
"""Return the limits object."""
|
||||
"""Set the limits object."""
|
||||
self._limits['{}_{}'.format(self.plugin_name, item)] = value
|
||||
|
||||
def get_limits(self, item=None):
|
||||
@@ -763,6 +763,13 @@ class GlancesPlugin(object):
|
||||
action_key=action_key,
|
||||
log=True)
|
||||
|
||||
def is_limit(self, criticity, stat_name=""):
|
||||
"""Return true if the criticity limit exist for the given stat_name"""
|
||||
if stat_name == "":
|
||||
return self.plugin_name + '_' + criticity in self._limits
|
||||
else:
|
||||
return stat_name + '_' + criticity in self._limits
|
||||
|
||||
def get_limit(self, criticity, stat_name=""):
|
||||
"""Return the limit value for the alert."""
|
||||
# Get the limit for stat + header
|
||||
|
||||
@@ -166,9 +166,6 @@ class Plugin(GlancesPlugin):
|
||||
|
||||
def update_views(self):
|
||||
"""Update stats views."""
|
||||
# @TODO: manage limits coming from system here for temperature_core
|
||||
# ...
|
||||
|
||||
# Call the father's method
|
||||
super(Plugin, self).update_views()
|
||||
|
||||
@@ -177,12 +174,26 @@ class Plugin(GlancesPlugin):
|
||||
for i in self.stats:
|
||||
if not i['value']:
|
||||
continue
|
||||
if i['type'] == 'battery':
|
||||
self.views[i[self.get_key()]]['value']['decoration'] = self.get_alert(current=100 - i['value'],
|
||||
header=i['type'])
|
||||
# Alert processing
|
||||
if i['type'] == 'temperature_core' and not self.is_limit('critical', stat_name=i['type']):
|
||||
if i['critical'] is None:
|
||||
alert = 'DEFAULT'
|
||||
elif i['value'] >= i['critical']:
|
||||
alert = 'CRITICAL'
|
||||
elif i['warning'] is None:
|
||||
alert = 'DEFAULT'
|
||||
elif i['value'] >= i['warning']:
|
||||
alert = 'WARNING'
|
||||
else:
|
||||
alert = 'OK'
|
||||
elif i['type'] == 'battery':
|
||||
alert = self.get_alert(current=100 - i['value'],
|
||||
header=i['type'])
|
||||
else:
|
||||
self.views[i[self.get_key()]]['value']['decoration'] = self.get_alert(current=i['value'],
|
||||
header=i['type'])
|
||||
alert = self.get_alert(current=i['value'],
|
||||
header=i['type'])
|
||||
# Set the alert in the view
|
||||
self.views[i[self.get_key()]]['value']['decoration'] = alert
|
||||
|
||||
def msg_curse(self, args=None, max_width=None):
|
||||
"""Return the dict to display in the curse interface."""
|
||||
@@ -316,8 +327,10 @@ class GlancesGrabSensors(object):
|
||||
sensors_current['label'] = feature.label
|
||||
# Sensors value, limit and unit
|
||||
sensors_current['value'] = int(getattr(feature, 'current', 0) if getattr(feature, 'current', 0) else 0)
|
||||
sensors_current['warning'] = int(getattr(feature, 'high', 0) if getattr(feature, 'high', 0) else 0)
|
||||
sensors_current['critical'] = int(getattr(feature, 'critical', 0) if getattr(feature, 'critical', 0) else 0)
|
||||
warning = getattr(feature, 'high', None)
|
||||
sensors_current['warning'] = int(warning) if warning is not None else None
|
||||
critical = getattr(feature, 'critical', None)
|
||||
sensors_current['critical'] = int(critical) if critical is not None else None
|
||||
sensors_current['unit'] = type
|
||||
# Add sensor to the list
|
||||
ret.append(sensors_current)
|
||||
|
||||
Reference in New Issue
Block a user