Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMART is not displayed on a web page but available in a container through smartctl #2916

Open
v-bulynkin opened this issue Aug 11, 2024 · 9 comments

Comments

@v-bulynkin
Copy link

v-bulynkin commented Aug 11, 2024

Hello dear sir,

I'm trying to display the SMART information from Docker container. What I've done:

  1. Enabled SMART plugin by disable=False in glances.conf.
  2. Added the following options to the Glances service in docker-compose.yml:
    privileged: true
    devices:
      - /dev/nvme0n1:/dev/nvme0n1

After that:

  1. "SMART disks" on a web page is empty
  2. docker exec glances glances --stdout smart is empty too:
2024-08-11 10:06:13,778 -- INFO -- Start Glances 4.2.0_beta04
2024-08-11 10:06:13,778 -- INFO -- CPython 3.12.3 (/venv/bin/python3) and psutil 6.0.0 detected
2024-08-11 10:06:13,783 -- INFO -- Read configuration file '/etc/glances/glances.conf'
2024-08-11 10:06:13,908 -- INFO -- Start GlancesStandalone mode
2024-08-11 10:06:14,080 -- INFO -- Export process filter is set to: .*
2024-08-11 10:06:14,531 -- INFO -- Stdout mode is ON, following stats will be displayed: smart
smart: []
smart: []
  1. docker exec glances smartctl -a /dev/nvme0n1 works well:
smartctl 7.4 2023-08-01 r5530 [x86_64-linux-6.8.0-39-generic] (local build)
Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Number:                       Samsung SSD 980 PRO 1TB
Serial Number:                      XXXXXXXXXXXXXXX
Firmware Version:                   5B2QGXA7
PCI Vendor/Subsystem ID:            0x144d
IEEE OUI Identifier:                0x002538
Total NVM Capacity:                 1,000,204,886,016 [1.00 TB]
Unallocated NVM Capacity:           0
Controller ID:                      6
NVMe Version:                       1.3
Number of Namespaces:               1
Namespace 1 Size/Capacity:          1,000,204,886,016 [1.00 TB]
Namespace 1 Utilization:            115,592,560,640 [115 GB]
Namespace 1 Formatted LBA Size:     512
Namespace 1 IEEE EUI-64:            002538 b531a5b590
Local Time is:                      Sun Aug 11 09:58:14 2024 UTC
Firmware Updates (0x16):            3 Slots, no Reset required
Optional Admin Commands (0x0017):   Security Format Frmw_DL Self_Test
Optional NVM Commands (0x0057):     Comp Wr_Unc DS_Mngmt Sav/Sel_Feat Timestmp
Log Page Attributes (0x0f):         S/H_per_NS Cmd_Eff_Lg Ext_Get_Lg Telmtry_Lg
Maximum Data Transfer Size:         128 Pages
Warning  Comp. Temp. Threshold:     82 Celsius
Critical Comp. Temp. Threshold:     85 Celsius

Supported Power States
St Op     Max   Active     Idle   RL RT WL WT  Ent_Lat  Ex_Lat
 0 +     8.49W       -        -    0  0  0  0        0       0
 1 +     4.48W       -        -    1  1  1  1        0     200
 2 +     3.18W       -        -    2  2  2  2        0    1000
 3 -   0.0400W       -        -    3  3  3  3     2000    1200
 4 -   0.0050W       -        -    4  4  4  4      500    9500

Supported LBA Sizes (NSID 0x1)
Id Fmt  Data  Metadt  Rel_Perf
 0 +     512       0         0

=== START OF SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

SMART/Health Information (NVMe Log 0x02)
Critical Warning:                   0x00
Temperature:                        56 Celsius
Available Spare:                    100%
Available Spare Threshold:          10%
Percentage Used:                    0%
Data Units Read:                    140,764 [72.0 GB]
Data Units Written:                 516,631 [264 GB]
Host Read Commands:                 1,953,083
Host Write Commands:                5,805,489
Controller Busy Time:               82
Power Cycles:                       32
Power On Hours:                     15
Unsafe Shutdowns:                   11
Media and Data Integrity Errors:    0
Error Information Log Entries:      0
Warning  Comp. Temperature Time:    0
Critical Comp. Temperature Time:    0
Temperature Sensor 1:               56 Celsius
Temperature Sensor 2:               61 Celsius

Error Information (NVMe Log 0x01, 16 of 64 entries)
No Errors Logged

Read Self-test Log failed: Invalid Field in Command (0x002)

Why the SMART plugin can't show the information? Does it support NVMe drives?

@nicolargo
Copy link
Owner

Hi @v-bulynkin

the Smart plugin is disable by default in the Glances configuration file.

You can enable by editing your glances.conf file (/etc/glances/glances.conf inside the container):

[smart]
# Documentation: https://glances.readthedocs.io/en/latest/aoa/smart.html
# This plugin is disabled by default
disable=True

or via the command line:

docker exec glances glances --enable-plugin smart

Keep us inform.

@v-bulynkin
Copy link
Author

v-bulynkin commented Aug 11, 2024

I wrote that I enabled it in the first message:

  1. Enabled SMART plugin by disable=False in glances.conf.

I mount the glances.conf file in docker-compose.yml the following way:

    volumes:
      - ./glances/glances.conf:/etc/glances/glances.conf

Is it not enough?

@RazCrimson
Copy link
Collaborator

@v-bulynkin
That should be enough, but glances looks for paths in multiple locations. So if possible, could you just give the command line variant a try, so that atleast it works when enabled explicitly?

docker exec glances glances --enable-plugin smart

If that works, then could you just try running glances in debug mode (-d flag) and check the start of the logs?

Should be present at ~/.local/share/glances/glances.log inside the container

@v-bulynkin
Copy link
Author

v-bulynkin commented Aug 12, 2024

I have this configuration now in docker-compose.yml:

  glances:
    image: nicolargo/glances:dev
    container_name: glances
    hostname: example.com
    restart: unless-stopped
    pid: host
    privileged: true
    devices:
      - "/dev/nvme0"
    environment:
      GLANCES_OPT: "-w -d --enable-plugin smart"
    volumes:
      - ./glances/glances.conf:/etc/glances/glances.conf
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /etc/os-release:/etc/os-release:ro
    labels:
      - "traefik.enable=true"
      - "traefik.http.services.glances.loadbalancer.server.port=61208"
      - "traefik.http.routers.glances.rule=Host(`example.com`) && (PathPrefix(`/mon/`) || Path(`/mon`))"
      - "traefik.http.routers.glances.tls.certresolver=le"
      - "traefik.http.routers.glances.entrypoints=websecure"

In logs:
docker logs glances >& glances.log
cat glances.log |grep smart

2024-08-12 14:18:26,406 -- DEBUG -- Init smart plugin
2024-08-12 14:18:26,406 -- DEBUG -- Load section smart in Glances configuration file
2024-08-12 14:18:26,406 -- DEBUG -- Load limit: smart_disable = ['False']
2024-08-12 14:18:26,406 -- DEBUG -- Plugin smart started in 0.006852 seconds
2024-08-12 14:18:26,499 -- DEBUG -- Active plugins list: ['containers', 'uptime', 'help', 'ports', 'now', 'network', 'amps', 'percpu', 'quicklook', 'smart', 'wifi', 'load', 'processcount', 'alert', 'fs', 'core', 'cpu', 'psutilversion', 'mem', 'diskio', 'memswap', 'sensors', 'version', 'folders', 'gpu', 'processlist', 'system']
2024-08-12 14:18:26,823 -- DEBUG -- PluginModel glances.plugins.smart update return [] in 0.216957 seconds
2024-08-12 14:18:41,452 -- DEBUG -- PluginModel glances.plugins.smart update return [] in 0.235986 seconds
2024-08-12 14:18:53,826 -- DEBUG -- PluginModel glances.plugins.smart update return [] in 0.217937 seconds
2024-08-12 14:19:04,340 -- DEBUG -- PluginModel glances.plugins.smart update return [] in 0.210826 seconds
2024-08-12 14:19:15,909 -- DEBUG -- PluginModel glances.plugins.smart update return [] in 0.22168 seconds
2024-08-12 14:19:26,381 -- DEBUG -- PluginModel glances.plugins.smart update return [] in 0.226953 seconds
2024-08-12 14:19:36,934 -- DEBUG -- PluginModel glances.plugins.smart update return [] in 0.220929 seconds

@nicolargo
Copy link
Owner

It's perhaps an issue concerning the read rights on the /dev/nvme0n1 file. Inside your container, glances user should be allowed to read this file.

I have the same issue on my laptop (running Glances not from a container):

  1. glances

No smart info displayed

  1. sudo glances

image

@nicolargo
Copy link
Owner

Note for Glances developer.

A mode exist to run PySmart in sudo:

>>> from pySMART import DeviceList
>>> from pySMART import Device
>>> sda = Device('/dev/sda')
>>> sda
<UNKNOWN INTERFACE device on /dev/sda mod:None sn:None>
>>> devlist = DeviceList()
>>> devlist
<DeviceList contents:
>
>>> from pySMART import SMARTCTL
>>> SMARTCTL.sudo = True
>>> sda = Device('/dev/sda')
>>> sda
[sudo] password for user:
<SAT device on /dev/sda mod:ST10000DM0004-1ZC101 sn:ZA20VNPT>
>>> devlist = DeviceList()
>>> devlist
<DeviceList contents:
<NVME device on /dev/nvme0 mod:Sabrent Rocket 4.0 1TB sn:03850709185D88300410>
<NVME device on /dev/nvme1 mod:Samsung SSD 970 EVO Plus 2TB sn:S59CNM0RB05028D>
<NVME device on /dev/nvme2 mod:Samsung SSD 970 EVO Plus 2TB sn:S59CNM0RB05113H>
<SAT device on /dev/sda mod:ST10000DM0004-1ZC101 sn:ZA20VNPT>
<SAT device on /dev/sdb mod:ST10000DM0004-1ZC101 sn:ZA22W366>
<SAT device on /dev/sdc mod:ST10000DM0004-1ZC101 sn:ZA22SPLG>
<SAT device on /dev/sdd mod:ST10000DM0004-1ZC101 sn:ZA2215HL>

But password should be enter...

...
[sudo] password for user:
...

or sudoers file configure correctly...

@zatricky
Copy link

zatricky commented Aug 20, 2024

I'm running glances (not the current version) on a Fedora server as root and seeing similar output - just formatted slightly differently. I'll try testing a newer version:

root@host1:~# glances --version
Glances version:	4.0.5
Glances API version:	4
PsUtil version:		5.9.8
Log file:		/root/.local/share/glances/glances.log
root@host1:~# glances --enable-plugin smart -d --stdout smart
smart: {}
smart: {}
^Croot@host1:~# 
root@host1:~# grep smart ~/.local/share/glances/glances.log
2024-08-20 10:41:28,273 -- DEBUG -- Init smart plugin
2024-08-20 10:41:28,273 -- DEBUG -- Load section smart in ['/root/.config/glances/glances.conf', '/etc/glances/glances.conf', '/usr/share/doc/glances/glances.conf']
2024-08-20 10:41:28,273 -- DEBUG -- Load limit: smart_disable = ['False']
2024-08-20 10:41:28,273 -- DEBUG -- Plugin smart started in 0.001074 seconds
2024-08-20 10:41:28,277 -- DEBUG -- Active plugins list: ['alert', 'amps', 'containers', 'core', 'cpu', 'diskio', 'folders', 'fs', 'gpu', 'help', 'ip', 'load', 'mem', 'memswap', 'network', 'now', 'percpu', 'ports', 'processcount', 'processlist', 'psutilversion', 'quicklook', 'sensors', 'smart', 'system', 'uptime', 'version']
2024-08-20 10:41:28,297 -- DEBUG -- PluginModel glances.plugins.smart update return {} in 5e-06 seconds
2024-08-20 10:41:28,479 -- INFO -- Stdout mode is ON, following stats will be displayed: smart
2024-08-20 10:41:48,568 -- DEBUG -- PluginModel glances.plugins.smart update return {} in 2.4e-05 seconds
2024-08-20 10:41:49,779 -- DEBUG -- Stop the smart plugin

Testing pySMART directly:

root@host1:~# python3
Python 3.12.4 (main, Jun  7 2024, 00:00:00) [GCC 14.1.1 20240607 (Red Hat 14.1.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pySMART import DeviceList
>>> from pySMART import Device
>>> sda = Device('/dev/sda')
>>> sda
<SAT device on /dev/sda mod:Samsung SSD 870 EVO 1TB sn:<serial>>
>>> devlist = DeviceList()
>>> devlist
<DeviceList contents:
<SAT device on /dev/sda mod:Samsung SSD 870 EVO 1TB sn:<serial>>
<SAT device on /dev/sdb mod:WDC WD140EFGX-68B0GN0 sn:<serial>>
<SAT device on /dev/sdc mod:WDC WD140EFGX-68B0GN0 sn:<serial>>
<SAT device on /dev/sdd mod:WDC WD140EFGX-68B0GN0 sn:<serial>>
<SAT device on /dev/sde mod:WDC WD140EFGX-68B0GN0 sn:<serial>>
<SAT device on /dev/sdf mod:WDC WD140EFGX-68B0GN0 sn:<serial>>
... long list of devices
>
>>>

I figured there might be some SELinux interference but there are no log entries from setroubleshootd corresponding with the time this is being tested. Also of course, executing pySMART directly does seem to work.

@zatricky
Copy link

Running the current version I get good output:

root@host1:~# ~/.local/bin/glances --version
Glances version:	4.1.2
Glances API version:	4
PsUtil version:		5.9.8
Log file:		/root/.local/share/glances/glances.log

Copy link

This issue is stale because it has been open for 3 months with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants