summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-10-18 14:27:28 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-10-18 14:27:28 (GMT)
commit4a6c5ecc942e8f12a6b39fc39a3030eb56ce13f2 (patch)
treef21518488b5797047585f95f3c53e328d59b0017 /plugins
parenta964f87d144b58196838148e7e0806db7e3ae870 (diff)
downloadmonitoring-plugins-4a6c5ecc942e8f12a6b39fc39a3030eb56ce13f2.tar.gz
check_fping: Use C99 booleans
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_fping.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index 23a9e99..70d6f9f 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -59,16 +59,16 @@ int packet_size = PACKET_SIZE;
59int packet_count = PACKET_COUNT; 59int packet_count = PACKET_COUNT;
60int target_timeout = 0; 60int target_timeout = 0;
61int packet_interval = 0; 61int packet_interval = 0;
62int verbose = FALSE; 62bool verbose = false;
63int cpl; 63int cpl;
64int wpl; 64int wpl;
65double crta; 65double crta;
66double wrta; 66double wrta;
67int cpl_p = FALSE; 67bool cpl_p = false;
68int wpl_p = FALSE; 68bool wpl_p = false;
69bool alive_p = FALSE; 69bool alive_p = false;
70int crta_p = FALSE; 70bool crta_p = false;
71int wrta_p = FALSE; 71bool wrta_p = false;
72 72
73int 73int
74main (int argc, char **argv) 74main (int argc, char **argv)
@@ -194,8 +194,8 @@ int textscan (char *buf) {
194 _("FPING %s - %s (rta=%f ms)|%s\n"), 194 _("FPING %s - %s (rta=%f ms)|%s\n"),
195 state_text (STATE_OK), server_name,rta, 195 state_text (STATE_OK), server_name,rta,
196 /* No loss since we only waited for the first reply 196 /* No loss since we only waited for the first reply
197 perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100), */ 197 perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, true, 0, true, 100), */
198 fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, TRUE, 0, FALSE, 0)); 198 fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, true, 0, false, 0));
199 } 199 }
200 200
201 if (strstr (buf, "not found")) { 201 if (strstr (buf, "not found")) {
@@ -228,21 +228,21 @@ int textscan (char *buf) {
228 rtastr = 1 + index (rtastr, '/'); 228 rtastr = 1 + index (rtastr, '/');
229 loss = strtod (losstr, NULL); 229 loss = strtod (losstr, NULL);
230 rta = strtod (rtastr, NULL); 230 rta = strtod (rtastr, NULL);
231 if (cpl_p == TRUE && loss > cpl) 231 if (cpl_p && loss > cpl)
232 status = STATE_CRITICAL; 232 status = STATE_CRITICAL;
233 else if (crta_p == TRUE && rta > crta) 233 else if (crta_p && rta > crta)
234 status = STATE_CRITICAL; 234 status = STATE_CRITICAL;
235 else if (wpl_p == TRUE && loss > wpl) 235 else if (wpl_p && loss > wpl)
236 status = STATE_WARNING; 236 status = STATE_WARNING;
237 else if (wrta_p == TRUE && rta > wrta) 237 else if (wrta_p && rta > wrta)
238 status = STATE_WARNING; 238 status = STATE_WARNING;
239 else 239 else
240 status = STATE_OK; 240 status = STATE_OK;
241 die (status, 241 die (status,
242 _("FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n"), 242 _("FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n"),
243 state_text (status), server_name, loss, rta, 243 state_text (status), server_name, loss, rta,
244 perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100), 244 perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, true, 0, true, 100),
245 fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, TRUE, 0, FALSE, 0)); 245 fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, true, 0, false, 0));
246 246
247 } 247 }
248 else if(strstr (buf, "xmt/rcv/%loss") ) { 248 else if(strstr (buf, "xmt/rcv/%loss") ) {
@@ -258,16 +258,16 @@ int textscan (char *buf) {
258 loss = strtod (losstr, NULL); 258 loss = strtod (losstr, NULL);
259 if (atoi(losstr) == 100) 259 if (atoi(losstr) == 100)
260 status = STATE_CRITICAL; 260 status = STATE_CRITICAL;
261 else if (cpl_p == TRUE && loss > cpl) 261 else if (cpl_p && loss > cpl)
262 status = STATE_CRITICAL; 262 status = STATE_CRITICAL;
263 else if (wpl_p == TRUE && loss > wpl) 263 else if (wpl_p && loss > wpl)
264 status = STATE_WARNING; 264 status = STATE_WARNING;
265 else 265 else
266 status = STATE_OK; 266 status = STATE_OK;
267 /* loss=%.0f%%;%d;%d;0;100 */ 267 /* loss=%.0f%%;%d;%d;0;100 */
268 die (status, _("FPING %s - %s (loss=%.0f%% )|%s\n"), 268 die (status, _("FPING %s - %s (loss=%.0f%% )|%s\n"),
269 state_text (status), server_name, loss , 269 state_text (status), server_name, loss ,
270 perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100)); 270 perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, true, 0, true, 100));
271 271
272 } 272 }
273 else { 273 else {
@@ -329,7 +329,7 @@ process_arguments (int argc, char **argv)
329 case '?': /* print short usage statement if args not parsable */ 329 case '?': /* print short usage statement if args not parsable */
330 usage5 (); 330 usage5 ();
331 case 'a': /* host alive mode */ 331 case 'a': /* host alive mode */
332 alive_p = TRUE; 332 alive_p = true;
333 break; 333 break;
334 case 'h': /* help */ 334 case 'h': /* help */
335 print_help (); 335 print_help ();
@@ -338,16 +338,16 @@ process_arguments (int argc, char **argv)
338 print_revision (progname, NP_VERSION); 338 print_revision (progname, NP_VERSION);
339 exit (STATE_UNKNOWN); 339 exit (STATE_UNKNOWN);
340 case 'v': /* verbose mode */ 340 case 'v': /* verbose mode */
341 verbose = TRUE; 341 verbose = true;
342 break; 342 break;
343 case 'H': /* hostname */ 343 case 'H': /* hostname */
344 if (is_host (optarg) == FALSE) { 344 if (is_host (optarg) == false) {
345 usage2 (_("Invalid hostname/address"), optarg); 345 usage2 (_("Invalid hostname/address"), optarg);
346 } 346 }
347 server_name = strscpy (server_name, optarg); 347 server_name = strscpy (server_name, optarg);
348 break; 348 break;
349 case 'S': /* sourceip */ 349 case 'S': /* sourceip */
350 if (is_host (optarg) == FALSE) { 350 if (is_host (optarg) == false) {
351 usage2 (_("Invalid hostname/address"), optarg); 351 usage2 (_("Invalid hostname/address"), optarg);
352 } 352 }
353 sourceip = strscpy (sourceip, optarg); 353 sourceip = strscpy (sourceip, optarg);
@@ -369,12 +369,12 @@ process_arguments (int argc, char **argv)
369 get_threshold (optarg, rv); 369 get_threshold (optarg, rv);
370 if (rv[RTA]) { 370 if (rv[RTA]) {
371 crta = strtod (rv[RTA], NULL); 371 crta = strtod (rv[RTA], NULL);
372 crta_p = TRUE; 372 crta_p = true;
373 rv[RTA] = NULL; 373 rv[RTA] = NULL;
374 } 374 }
375 if (rv[PL]) { 375 if (rv[PL]) {
376 cpl = atoi (rv[PL]); 376 cpl = atoi (rv[PL]);
377 cpl_p = TRUE; 377 cpl_p = true;
378 rv[PL] = NULL; 378 rv[PL] = NULL;
379 } 379 }
380 break; 380 break;
@@ -382,12 +382,12 @@ process_arguments (int argc, char **argv)
382 get_threshold (optarg, rv); 382 get_threshold (optarg, rv);
383 if (rv[RTA]) { 383 if (rv[RTA]) {
384 wrta = strtod (rv[RTA], NULL); 384 wrta = strtod (rv[RTA], NULL);
385 wrta_p = TRUE; 385 wrta_p = true;
386 rv[RTA] = NULL; 386 rv[RTA] = NULL;
387 } 387 }
388 if (rv[PL]) { 388 if (rv[PL]) {
389 wpl = atoi (rv[PL]); 389 wpl = atoi (rv[PL]);
390 wpl_p = TRUE; 390 wpl_p = true;
391 rv[PL] = NULL; 391 rv[PL] = NULL;
392 } 392 }
393 break; 393 break;