Sfoglia il codice sorgente

Fix segfault when --inode-perfdata used without inode thresholds

madlohe 6 anni fa
parent
commit
8ee87c8566
1 ha cambiato i file con 14 aggiunte e 2 eliminazioni
  1. 14 2
      plugins/check_disk.c

+ 14 - 2
plugins/check_disk.c

@@ -225,6 +225,7 @@ main (int argc, char **argv)
   char *flag_header = NULL;
   char *flag_header = NULL;
   char *label_name;
   char *label_name;
   char *inode_label_name, *raw_used_inodes_name, *raw_free_inodes_name;
   char *inode_label_name, *raw_used_inodes_name, *raw_free_inodes_name;
+  int print_inode_perfdata_warning, print_inode_perfdata_critical;
   double inode_space_pct;
   double inode_space_pct;
   double warning_high_tide;
   double warning_high_tide;
   double critical_high_tide;
   double critical_high_tide;
@@ -514,11 +515,22 @@ main (int argc, char **argv)
             inode_label_name = calloc(strlen(label_name) + 1 + 14, 1);
             inode_label_name = calloc(strlen(label_name) + 1 + 14, 1);
             inode_label_name = strcat(inode_label_name, label_name);
             inode_label_name = strcat(inode_label_name, label_name);
             inode_label_name = strcat(inode_label_name, "_inode_percent");
             inode_label_name = strcat(inode_label_name, "_inode_percent");
+
+            print_inode_perfdata_warning = FALSE;
+            if (path->freeinodes_percent != NULL && path->freeinodes_percent->warning != NULL) {
+              print_inode_perfdata_warning = TRUE;
+            }
+
+            print_inode_perfdata_critical = FALSE;
+            if (path->freeinodes_percent != NULL && path->freeinodes_percent->critical != NULL) {
+              print_inode_perfdata_critical = TRUE;
+            }
+
             xasprintf (&perf, "%s %s", perf,
             xasprintf (&perf, "%s %s", perf,
                        perfdata (inode_label_name,
                        perfdata (inode_label_name,
                                   path->dused_inodes_percent, "%",
                                   path->dused_inodes_percent, "%",
-                                  (path->freeinodes_percent != NULL ? TRUE : FALSE), path->freeinodes_percent->warning->end,
-                                  (path->freeinodes_percent != NULL ? TRUE : FALSE), path->freeinodes_percent->critical->end,
+                                  print_inode_perfdata_warning, (print_inode_perfdata_warning ? path->freeinodes_percent->warning->end : 0),
+                                  print_inode_perfdata_critical, (print_inode_perfdata_critical ? path->freeinodes_percent->critical->end : 0),
                                   TRUE, 0,
                                   TRUE, 0,
                                   TRUE, 100));
                                   TRUE, 100));