aranemac / munin-smart-nvme Goto Github PK
View Code? Open in Web Editor NEWConverts smartctl output for NVMe drives to old format (readable for munin smart_ plugin)
License: MIT License
Converts smartctl output for NVMe drives to old format (readable for munin smart_ plugin)
License: MIT License
If the raw data doesn't fit into an 32bit-integer, negative values were printed.
Fixed.
Thank you for this very useful converter!
In using it on a number of different NVMe drives, I noticed that it breaks on any that don't work "automatically" with smartctl
(e.g. the ones that need a special "-d" parameter). This is caused by the "overwrite all arguments" code, which is broken and unnecessary.
Here is a short fix that allows all arguments to be passed correctly, as configured by munin
(and it also fixes the potential buffer overflow with the naked strcat
):
--- smartctlcvt.cc 2024-01-07 00:22:06.099416365 +0100
+++ smartctlcvt-fixed.cc 2024-01-07 00:48:12.905155998 +0100
@@ -23,9 +23,13 @@
char *pT;
FILE *cmd;
- // overwriting all arguments passed by plugin, except drive
- char smartarg[100] = "smartctl -A ";
- strcat( smartarg, argv[ argc-1 ] );
+ // reconstruct all arguments passed by plugin
+ const int MAXARG = 100;
+ char smartarg[MAXARG] = "smartctl";
+ for ( int i = 1; i < argc; i++ ) {
+ strncat( smartarg, " ", MAXARG - strlen(smartarg) - 1 );
+ strncat( smartarg, argv[i], MAXARG - strlen(smartarg) - strlen(argv[i]) );
+ }
int on = 0;
int n = 0;
This works nicely on my system with 10+ devices, some connected directly, others via USB.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.