summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLorenz <12514511+RincewindsHat@users.noreply.github.com>2023-03-11 09:27:43 (GMT)
committerGitHub <noreply@github.com>2023-03-11 09:27:43 (GMT)
commit357787868b5201ec3e874e7a225b1c944cbbdb4d (patch)
treeb15068501b8f115269b6e5d52a6fb5e3308aa87e /lib
parent269718094177fb8a7e3d3005d1310495009fe8c4 (diff)
parent3e7da5f970d73df91fad32f4dce259d30cdbbd65 (diff)
downloadmonitoring-plugins-357787868b5201ec3e874e7a225b1c944cbbdb4d.tar.gz
Merge pull request #1801 from KriSchu/feature_check_disk_add_ignore_missing_option
check_disk: add ignore-missing option to return OK for missing fs
Diffstat (limited to 'lib')
-rw-r--r--lib/utils_disk.c19
-rw-r--r--lib/utils_disk.h1
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index 4f16068..468769b 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -47,9 +47,10 @@ np_add_parameter(struct parameter_list **list, const char *name)
47 struct parameter_list *current = *list; 47 struct parameter_list *current = *list;
48 struct parameter_list *new_path; 48 struct parameter_list *new_path;
49 new_path = (struct parameter_list *) malloc (sizeof *new_path); 49 new_path = (struct parameter_list *) malloc (sizeof *new_path);
50 new_path->name = (char *) name; 50 new_path->name = (char *) malloc(strlen(name) + 1);
51 new_path->best_match = NULL; 51 new_path->best_match = NULL;
52 new_path->name_next = NULL; 52 new_path->name_next = NULL;
53 new_path->name_prev = NULL;
53 new_path->freespace_bytes = NULL; 54 new_path->freespace_bytes = NULL;
54 new_path->freespace_units = NULL; 55 new_path->freespace_units = NULL;
55 new_path->freespace_percent = NULL; 56 new_path->freespace_percent = NULL;
@@ -75,13 +76,17 @@ np_add_parameter(struct parameter_list **list, const char *name)
75 new_path->dused_inodes_percent = 0; 76 new_path->dused_inodes_percent = 0;
76 new_path->dfree_inodes_percent = 0; 77 new_path->dfree_inodes_percent = 0;
77 78
79 strcpy(new_path->name, name);
80
78 if (current == NULL) { 81 if (current == NULL) {
79 *list = new_path; 82 *list = new_path;
83 new_path->name_prev = NULL;
80 } else { 84 } else {
81 while (current->name_next) { 85 while (current->name_next) {
82 current = current->name_next; 86 current = current->name_next;
83 } 87 }
84 current->name_next = new_path; 88 current->name_next = new_path;
89 new_path->name_prev = current;
85 } 90 }
86 return new_path; 91 return new_path;
87} 92}
@@ -90,6 +95,9 @@ np_add_parameter(struct parameter_list **list, const char *name)
90struct parameter_list * 95struct parameter_list *
91np_del_parameter(struct parameter_list *item, struct parameter_list *prev) 96np_del_parameter(struct parameter_list *item, struct parameter_list *prev)
92{ 97{
98 if (item == NULL) {
99 return NULL;
100 }
93 struct parameter_list *next; 101 struct parameter_list *next;
94 102
95 if (item->name_next) 103 if (item->name_next)
@@ -97,10 +105,17 @@ np_del_parameter(struct parameter_list *item, struct parameter_list *prev)
97 else 105 else
98 next = NULL; 106 next = NULL;
99 107
100 free(item); 108 if (next)
109 next->name_prev = prev;
110
101 if (prev) 111 if (prev)
102 prev->name_next = next; 112 prev->name_next = next;
103 113
114 if (item->name) {
115 free(item->name);
116 }
117 free(item);
118
104 return next; 119 return next;
105} 120}
106 121
diff --git a/lib/utils_disk.h b/lib/utils_disk.h
index bf52e4c..3b5a45f 100644
--- a/lib/utils_disk.h
+++ b/lib/utils_disk.h
@@ -24,6 +24,7 @@ struct parameter_list
24 char *group; 24 char *group;
25 struct mount_entry *best_match; 25 struct mount_entry *best_match;
26 struct parameter_list *name_next; 26 struct parameter_list *name_next;
27 struct parameter_list *name_prev;
27 uintmax_t total, available, available_to_root, used, 28 uintmax_t total, available, available_to_root, used,
28 inodes_free, inodes_free_to_root, inodes_used, inodes_total; 29 inodes_free, inodes_free_to_root, inodes_used, inodes_total;
29 double dfree_pct, dused_pct; 30 double dfree_pct, dused_pct;