-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Milestone
Description
Check the bug
#2904
#3419
#3423
Describe the bug
Glances stops exporting data to influxdb2 if smart plugin is enabled.
docker logs glances:
Exception in thread Thread-390 (update):
Traceback (most recent call last):
File "/usr/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File "/usr/lib/python3.12/threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "/app/glances/exports/export.py", line 292, in update
export_names, export_values = self.build_export(all_stats[plugin])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/glances/exports/export.py", line 336, in build_export
item_names, item_values = self.build_export(item)
^^^^^^^^^^^^^^^^^^^^^^^
File "/app/glances/exports/export.py", line 314, in build_export
for key, value in sorted(stats.items()):
^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'int' and 'str'
To Reproduce
Steps to reproduce the behavior:
- docker-compose.yaml:
services:
glances:
image: nicolargo/glances:ubuntu-latest-full
container_name: glances
restart: always
pid: "host"
network_mode: "host"
read_only: true
privileged: false
cap_add:
- SYS_RAWIO
devices:
- "/dev/sda"
- "/dev/sdb"
volumes:
- "/:/rootfs:ro"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./glances.conf:/etc/glances/glances.conf"
- "/etc/os-release:/etc/os-release:ro"
tmpfs:
- /tmp
environment:
- TZ=XXXXXX
- GLANCES_OPT=-d --enable-plugin smart --export influxdb2
- PYTHONPYCACHEPREFIX=/tmp/py_caches
depends_on:
- influxdb
runtime: nvidia
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
- glances.conf only has influxdb2 configuration. Behavior occurs both with smart enabled or disabled via glances.conf.
Environment (please complete the following information)
- Operating System (lsb_release -a or OS name/version): Ubuntu Server 24.04.3 LTS
- Glances & psutil versions:
Glances version: 4.5.0.5
Glances API version: 4
PsUtil version: 7.1.1
Log file: /tmp/glances-root.log
- How do you install Glances (Pypi package, script, package manager, source): docker (compose)
Additional context
docker exec glances tail -f /tmp/glances-root.log:
2026-02-19 17:04:18,487 -- DEBUG -- Active plugins list: ['smart', 'mem', 'version', 'network', 'programlist', 'uptime', 'containers', 'load', 'gpu', 'sensors', 'ports', 'quicklook', 'percpu', 'diskio', 'processcount', 'memswap', 'cpu', 'alert', 'system', 'help', 'folders', 'fs', 'core', 'amps', 'psutilversion', 'ip', 'now', 'processlist', 'wifi']
2026-02-19 17:04:20,174 -- DEBUG -- SmartPlugin glances.plugins.smart update return
[
{
"DeviceName": "<sda>",
5: {
"name": "Reallocated_Sector_Ct",
"key": "Reallocated_Sector_Ct",
"flags": 51,
"raw": "0",
"value": "100",
"worst": 100,
"threshold": 10,
"type": "Pre-fail",
"updated": "Always",
"when_failed": "-",
},
...
Possible Fix
Could the device stats dict be modified here to work with the logic in GlancesExport.build_export?
glances/glances/plugins/smart/__init__.py
Lines 125 to 137 in 6fc42a1
| def _process_standard_attributes(device_stats, attributes, hide_attributes): | |
| """Process standard SMART attributes and add them to device_stats.""" | |
| for attribute in attributes: | |
| if attribute is None or attribute.name in hide_attributes: | |
| continue | |
| attrib_dict = convert_attribute_to_dict(attribute) | |
| num = attrib_dict.pop('num', None) | |
| if num is None: | |
| logger.debug(f'Smart plugin error - Skip attribute with no num: {attribute}') | |
| continue | |
| device_stats[num] = attrib_dict |
and
glances/glances/plugins/smart/__init__.py
Lines 140 to 159 in 6fc42a1
| def _process_nvme_attributes(device_stats, if_attributes, hide_attributes): | |
| """Process NVMe-specific attributes and add them to device_stats.""" | |
| if not isinstance(if_attributes, NvmeAttributes): | |
| return | |
| for idx, (attr, value) in enumerate(vars(if_attributes).items(), start=1): | |
| attrib_dict = convert_nvme_attribute_to_dict(attr, value) | |
| if attrib_dict['name'] in hide_attributes: | |
| continue | |
| # Verify the value is serializable to prevent rendering errors | |
| if value is not None: | |
| try: | |
| str(value) | |
| except Exception: | |
| logger.debug(f'Unable to serialize attribute {attr} from NVME') | |
| attrib_dict['value'] = None | |
| attrib_dict['raw'] = None | |
| device_stats[idx] = attrib_dict |
It seems a bit difficult to fix this without changing the data model. I'm happy to look into this further, but just sharing in case this isn't a known issue.
Reactions are currently unavailable