Git Product home page Git Product logo

munin-smart-nvme's People

Contributors

aranemac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

munin-smart-nvme's Issues

Losing passed arguments breaks support for many NVMe drives

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.