Skip to content

Conversation

@crazy-max
Copy link
Member

This PR includes two changes:


First one to check if disk is a valid device. In one case I have, smartctl -i /dev/zd336 fails and returns:

smartctl 7.3 2022-02-28 r5338 [x86_64-linux-6.8.12-13-pve] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

/dev/zd96: Unable to detect device type
Please specify device type with the -d option.

Use smartctl -h to get a usage summary

We should check if smartctl succeeds.


And last one strips spaces for model name returned otherwise the poller fails to parse hddtemp from unix_agent module:

#### Load poller module unix-agent ####
  
LibreNMS UNIX Agent: execution time: 705ms
hddtemp: 
Processes: 
Sensors: -/dev/nvme0n1: SamsungSSD970PRO512GB: Cur 34, Low: 24, Low Warn: , Warn: , High: 54  
+25 °C  
25 °C  
25 °C  
25 °C  
Exception: ValueError "0" is not a valid backing value for enum LibreNMS\Enum\Sensor @ /opt/librenms/includes/polling/functions.inc.php:140
#0 /opt/librenms/includes/polling/functions.inc.php(140): LibreNMS\Enum\Sensor::from()
#1 /opt/librenms/includes/polling/unix-agent.inc.php(215): record_sensor_data()
#2 /opt/librenms/LibreNMS/Modules/LegacyModule.php(112): include('...')
#3 /opt/librenms/app/Jobs/PollDevice.php(139): LibreNMS\Modules\LegacyModule->poll()
#4 /opt/librenms/app/Jobs/PollDevice.php(63): App\Jobs\PollDevice->pollModules()
#5 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\Jobs\PollDevice->handle()
#6 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#7 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(96): Illuminate\Container\Util::unwrapIfClosure()
#8 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod()
#9 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\Container\BoundMethod::call()
#10 /opt/librenms/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(132): Illuminate\Container\Container->call()
#11 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(169): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}()
#12 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(126): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#13 /opt/librenms/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(136): Illuminate\Pipeline\Pipeline->then()
#14 /opt/librenms/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(125): Illuminate\Bus\Dispatcher->dispatchNow()
#15 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(169): Illuminate\Queue\CallQueuedHandler->Illuminate\Queue\{closure}()
#16 /opt/librenms/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(126): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#17 /opt/librenms/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(120): Illuminate\Pipeline\Pipeline->then()
#18 /opt/librenms/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(68): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware()
#19 /opt/librenms/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(102): Illuminate\Queue\CallQueuedHandler->call()
#20 /opt/librenms/vendor/laravel/framework/src/Illuminate/Queue/SyncQueue.php(130): Illuminate\Queue\Jobs\Job->fire()
#21 /opt/librenms/vendor/laravel/framework/src/Illuminate/Queue/SyncQueue.php(110): Illuminate\Queue\SyncQueue->executeJob()
#22 /opt/librenms/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(250): Illuminate\Queue\SyncQueue->push()
#23 /opt/librenms/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(234): Illuminate\Bus\Dispatcher->pushCommandToQueue()
#24 /opt/librenms/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(101): Illuminate\Bus\Dispatcher->dispatchToQueue()
#25 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php(76): Illuminate\Bus\Dispatcher->dispatchSync()
#26 /opt/librenms/app/Console/Commands/DevicePoll.php(79): App\Jobs\PollDevice::dispatchSync()
#27 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\Console\Commands\DevicePoll->handle()
#28 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#29 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(96): Illuminate\Container\Util::unwrapIfClosure()
#30 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod()
#31 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\Container\BoundMethod::call()
#32 /opt/librenms/vendor/laravel/framework/src/Illuminate/Console/Command.php(209): Illuminate\Container\Container->call()
#33 /opt/librenms/vendor/symfony/console/Command/Command.php(318): Illuminate\Console\Command->execute()
#34 /opt/librenms/vendor/laravel/framework/src/Illuminate/Console/Command.php(178): Symfony\Component\Console\Command\Command->run()
#35 /opt/librenms/vendor/symfony/console/Application.php(1092): Illuminate\Console\Command->run()
#36 /opt/librenms/vendor/symfony/console/Application.php(341): Symfony\Component\Console\Application->doRunCommand()
#37 /opt/librenms/vendor/symfony/console/Application.php(192): Symfony\Component\Console\Application->doRun()
#38 /opt/librenms/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(197): Symfony\Component\Console\Application->run()
#39 /opt/librenms/lnms(37): Illuminate\Foundation\Console\Kernel->handle()
#40 {main}

For example it currently returns:

|/dev/sda|Samsung SSD 870 QVO 4TB|25|C|

But should be:

|/dev/sda|SamsungSSD870QVO4TB|25|C|

cc @jasoncheng7115

@crazy-max crazy-max requested a review from murrant August 21, 2025 19:56
@jasoncheng7115
Copy link
Contributor

Thanks @crazy-max.

I did some testing, and the format is correct, and no unexpected zdX entries appear. However, I noticed that the temperature reading of one of the NVMe SSDs is incorrect, so I may need to look into the cause further.

root@host-108:/tmp# smartctl -a /dev/nvme0n1
smartctl 7.4 2024-10-15 r5620 [x86_64-linux-6.14.8-2-pve] (local build)
Copyright (C) 2002-23, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Number:                       Samsung SSD 970 EVO Plus 2TB
Serial Number:                      S4J4NX0T209320J
Firmware Version:                   2B2QEXM7
PCI Vendor/Subsystem ID:            0x144d
IEEE OUI Identifier:                0x002538
Total NVM Capacity:                 2,000,398,934,016 [2.00 TB]
Unallocated NVM Capacity:           0
Controller ID:                      4
NVMe Version:                       1.3
Number of Namespaces:               1
Namespace 1 Size/Capacity:          2,000,398,934,016 [2.00 TB]
Namespace 1 Utilization:            383,897,243,648 [383 GB]
Namespace 1 Formatted LBA Size:     512
Namespace 1 IEEE EUI-64:            002538 5221b027be
Local Time is:                      Thu Sep 11 20:55:37 2025 CST
Firmware Updates (0x16):            3 Slots, no Reset required
Optional Admin Commands (0x0017):   Security Format Frmw_DL Self_Test
Optional NVM Commands (0x005f):     Comp Wr_Unc DS_Mngmt Wr_Zero Sav/Sel_Feat Timestmp
Log Page Attributes (0x03):         S/H_per_NS Cmd_Eff_Lg
Maximum Data Transfer Size:         512 Pages
Warning  Comp. Temp. Threshold:     85 Celsius
Critical Comp. Temp. Threshold:     85 Celsius

The extracted temperature shows as 123 °C. I’ll investigate the issue further and submit a separate PR once I’ve identified the cause.

root@host-108:/tmp# ./hddtemp2.sh 
<<<hddtemp>>>
|/dev/sda|INTELSSDSC2KG480G8|38|C||/dev/nvme0n1|||C||/dev/nvme0n1|SamsungSSD970EVOPlus2TB|123|C|

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants