munin-monitoring / contrib

Contributed stuff for munin (plugins, tools, etc...)
http://munin-monitoring.org
1.05k stars 678 forks source link

nvme: Could not recognise output from 'nvme list' #1386

Closed kalvdans closed 5 months ago

kalvdans commented 1 year ago

Output from sudo nvme list

Node                  SN                   Model                                    Namespace Usage                      Format           FW Rev  
--------------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1          Y532XXXXXXXXXXXXX    M.2 (P80) 3TE6                           1           1.92  TB /   1.92  TB    512   B +  0 B   V22620  

Tried with the latest master, 515630509de388ddcfbe022f4a4b1d196cd17859

Ubuntu 22.04.2 LTS

nRaecheR commented 10 months ago

With Ubuntu 23.10 the nvme program was updated to vesion 2.5. With the former 2.0 version the nvme plugin worked as expected on my servers, with 2.5 the output has been modified again.

Node                  Generic               SN                   Model                                    Namespace  Usage                      Format           FW Rev  
--------------------- --------------------- -------------------- ---------------------------------------- ---------- -------------------------- ---------------- --------
/dev/nvme1n1          /dev/ng1n1            S6P7NF0WXXXXXXX      Samsung SSD 970 EVO Plus 1TB             0x1        645.73  GB /   1.00  TB    512   B +  0 B   4B2QEXM7
/dev/nvme0n1          /dev/ng0n1            S5GXNF0NXXXXXXX      Samsung SSD 980 PRO 1TB                  0x1        176.91  GB /   1.00  TB    512   B +  0 B   5B2QGXA7

The difference seems to be the 0x prefix in the Namespace ID (was 1 with 2.0)

Version information :

nvme version 2.5 (git 2.5) libnvme version 1.5 (git 1.5)

solsticedhiver commented 10 months ago

Here is a patch with a quick fix:

--- nvme    2023-10-23 23:21:44.809427365 +0200
+++ nvme    2023-10-23 23:20:27.773618724 +0200
@@ -146,25 +146,26 @@
 }

 sub nvme_list {
-    # Node             SN                   Model                                    Namespace Usage                      Format           FW Rev
-    # ---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
-    # /dev/nvme1n1     S464NB0K601188N      Samsung SSD 970 EVO 2TB                  1         695.50  GB /   2.00  TB    512   B +  0 B   1B2QEXE7
+    # Node                  Generic               SN                   Model                                    Namespace  Usage                      Format           FW Rev  
+    # --------------------- --------------------- -------------------- ---------------------------------------- ---------- -------------------------- ---------------- --------
+    # /dev/nvme1n1          /dev/ng1n1            S464NB0K601188N      Samsung SSD 970 EVO 2TB                  0x1        695.50  GB /  2.00  TB     512   B +  0 B   1B2QEXE7
     my %devices;

     my $recognised_output;
     my $lineno = 0;
     for (run_nvme('list')) {
         ++$lineno;
-        if (m:^Node\s+SN\s+Model\s+Namespace Usage:) {
+        if (m:^Node\s+Generic\s+SN\s+Model\s+Namespace\s+Usage:) {
             ++$recognised_output;
-        } elsif (m:^(/\S+)\s+(\S+)\s+(\S.*\S)\s{3,}(\d+)\s+(\S+\s+.B)\s+/\s+(\S+\s+.B):) {
+        } elsif (m:^(/\S+)\s+(\S+)\s+(\S+)\s+(\S.*\S)\s{3,}0x(\d+)\s+(\S+\s+.B)\s+/\s+(\S+\s+.B):) {
             $devices{'SN_'.$2} = {
                 device    => $1,
-                sn        => $2,
-                model     => $3,
-                namespace => $4,
-                usage     => human_to_bytes($5),
-                capacity  => human_to_bytes($6),
+       generic   => $2,
+                sn        => $3,
+                model     => $4,
+                namespace => $5,
+                usage     => human_to_bytes($6),
+                capacity  => human_to_bytes($7),
             };
         } elsif ($lineno > 2) {
             # could not parse device information
ap-wtioit commented 5 months ago

@nRaecheR the namespace column with prefix 0x should be fixed with https://github.com/munin-monitoring/contrib/pull/1423