summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-03-10 21:57:31 +0100
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-03-10 21:57:31 +0100
commit1584eb6a62f3ce546f886c2568dc967e33897f6b (patch)
tree2094a218a01026d611c078d4f24e1ab622013bda
parent14671421030843ed15816162245a0ef348db3315 (diff)
downloadmonitoring-plugins-1584eb6a62f3ce546f886c2568dc967e33897f6b.tar.gz
check_cluster: clang-format
-rw-r--r--plugins/check_cluster.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/plugins/check_cluster.c b/plugins/check_cluster.c
index b40c38c7..d6c4b1c5 100644
--- a/plugins/check_cluster.c
+++ b/plugins/check_cluster.c
@@ -72,13 +72,15 @@ int main(int argc, char **argv) {
72 /* Parse extra opts if any */ 72 /* Parse extra opts if any */
73 argv = np_extra_opts(&argc, argv, progname); 73 argv = np_extra_opts(&argc, argv, progname);
74 74
75 if (process_arguments(argc, argv) == ERROR) 75 if (process_arguments(argc, argv) == ERROR) {
76 usage(_("Could not parse arguments")); 76 usage(_("Could not parse arguments"));
77 }
77 78
78 /* Initialize the thresholds */ 79 /* Initialize the thresholds */
79 set_thresholds(&thresholds, warn_threshold, crit_threshold); 80 set_thresholds(&thresholds, warn_threshold, crit_threshold);
80 if (verbose) 81 if (verbose) {
81 print_thresholds("check_cluster", thresholds); 82 print_thresholds("check_cluster", thresholds);
83 }
82 84
83 /* check the data values */ 85 /* check the data values */
84 for (ptr = strtok(data_vals, ","); ptr != NULL; ptr = strtok(NULL, ",")) { 86 for (ptr = strtok(data_vals, ","); ptr != NULL; ptr = strtok(NULL, ",")) {
@@ -145,15 +147,17 @@ int process_arguments(int argc, char **argv) {
145 {"help", no_argument, 0, 'H'}, {0, 0, 0, 0}}; 147 {"help", no_argument, 0, 'H'}, {0, 0, 0, 0}};
146 148
147 /* no options were supplied */ 149 /* no options were supplied */
148 if (argc < 2) 150 if (argc < 2) {
149 return ERROR; 151 return ERROR;
152 }
150 153
151 while (1) { 154 while (1) {
152 155
153 c = getopt_long(argc, argv, "hHsvVw:c:d:l:", longopts, &option); 156 c = getopt_long(argc, argv, "hHsvVw:c:d:l:", longopts, &option);
154 157
155 if (c == -1 || c == EOF || c == 1) 158 if (c == -1 || c == EOF || c == 1) {
156 break; 159 break;
160 }
157 161
158 switch (c) { 162 switch (c) {
159 163
@@ -177,12 +181,15 @@ int process_arguments(int argc, char **argv) {
177 data_vals = (char *)strdup(optarg); 181 data_vals = (char *)strdup(optarg);
178 /* validate data */ 182 /* validate data */
179 for (ptr = data_vals; ptr != NULL; ptr += 2) { 183 for (ptr = data_vals; ptr != NULL; ptr += 2) {
180 if (ptr[0] < '0' || ptr[0] > '3') 184 if (ptr[0] < '0' || ptr[0] > '3') {
181 return ERROR; 185 return ERROR;
182 if (ptr[1] == '\0') 186 }
187 if (ptr[1] == '\0') {
183 break; 188 break;
184 if (ptr[1] != ',') 189 }
190 if (ptr[1] != ',') {
185 return ERROR; 191 return ERROR;
192 }
186 } 193 }
187 break; 194 break;
188 195
@@ -210,8 +217,9 @@ int process_arguments(int argc, char **argv) {
210 } 217 }
211 } 218 }
212 219
213 if (data_vals == NULL) 220 if (data_vals == NULL) {
214 return ERROR; 221 return ERROR;
222 }
215 223
216 return OK; 224 return OK;
217} 225}