Correct issue with Alias in sensors

This commit is contained in:
nicolargo 2024-04-27 16:28:38 +02:00
parent e4a6638c30
commit 81668fc947
3 changed files with 9 additions and 9 deletions

View File

@ -335,8 +335,10 @@ port=7634
disable=False
# By default refresh every refresh time * 2
#refresh=6
# Hide some sensors
#hide=ambient
# Hide some sensors (comma separated list of regexp)
hide=unknown.*
# Show only the following sensors (comma separated list of regexp)
#show=CPU.*
# Sensors core thresholds (in Celsius...)
# Default values are grabbed from the system
#temperature_core_careful=45

View File

@ -2,7 +2,7 @@
#
# This file is part of Glances.
#
# SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com>
# SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com>
#
# SPDX-License-Identifier: LGPL-3.0-only
#
@ -908,7 +908,7 @@ class GlancesPluginModel(object):
def read_alias(self):
if self.plugin_name + '_' + 'alias' in self._limits:
return {i.split(':')[0]: i.split(':')[1] for i in self._limits[self.plugin_name + '_' + 'alias'][0].split(',')}
return {i.split(':')[0].lower(): i.split(':')[1] for i in self._limits[self.plugin_name + '_' + 'alias']}
else:
return dict()

View File

@ -56,6 +56,7 @@ fields_description = {
},
}
class PluginModel(GlancesPluginModel):
"""Glances sensors plugin.
@ -155,13 +156,10 @@ class PluginModel(GlancesPluginModel):
# Global change on stats
self.stats = self.get_init_value()
for stat in stats:
# Do not take hide stat into account
# Hide sensors configured in the hide ou show configuration key
if not self.is_display(stat["label"].lower()):
continue
# Set the alias for each stat
# alias = self.has_alias(stat["label"].lower())
# if alias:
# stat["label"] = alias
# Set alias for sensors
stat["label"] = self.__get_alias(stat)
# Update the stats
self.stats.append(stat)