summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorLorenz <12514511+RincewindsHat@users.noreply.github.com>2022-09-11 06:29:36 +0200
committerGitHub <noreply@github.com>2022-09-11 06:29:36 +0200
commita9cdbc8959a7722494700aaddc63f0c7e0d34062 (patch)
treea4a74d4c8e21fec9bc9b6c197e1296a27994390d /plugins
parentfbbc9fcbd566db60058047870fbd6a2105e96663 (diff)
downloadmonitoring-plugins-a9cdbc8959a7722494700aaddc63f0c7e0d34062.tar.gz
Check load compiler warnings (#1759)
* Fix compiler warnings due to implizit conversion and formats * Make includes more specific and complement them * Formatting fixes
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_load.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/plugins/check_load.c b/plugins/check_load.c
index 0e4de54e..d1bb30a4 100644
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
@@ -1,41 +1,43 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_load plugin 3* Monitoring check_load plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Monitoring Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_load plugin 10* This file contains the check_load plugin
11* 11*
12* This plugin tests the current system load average. 12* This plugin tests the current system load average.
13* 13*
14* 14*
15* This program is free software: you can redistribute it and/or modify 15* This program is free software: you can redistribute it and/or modify
16* it under the terms of the GNU General Public License as published by 16* it under the terms of the GNU General Public License as published by
17* the Free Software Foundation, either version 3 of the License, or 17* the Free Software Foundation, either version 3 of the License, or
18* (at your option) any later version. 18* (at your option) any later version.
19* 19*
20* This program is distributed in the hope that it will be useful, 20* This program is distributed in the hope that it will be useful,
21* but WITHOUT ANY WARRANTY; without even the implied warranty of 21* but WITHOUT ANY WARRANTY; without even the implied warranty of
22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23* GNU General Public License for more details. 23* GNU General Public License for more details.
24* 24*
25* You should have received a copy of the GNU General Public License 25* You should have received a copy of the GNU General Public License
26* along with this program. If not, see <http://www.gnu.org/licenses/>. 26* along with this program. If not, see <http://www.gnu.org/licenses/>.
27* 27*
28* 28*
29*****************************************************************************/ 29*****************************************************************************/
30 30
31const char *progname = "check_load"; 31const char *progname = "check_load";
32const char *copyright = "1999-2007"; 32const char *copyright = "1999-2007";
33const char *email = "devel@monitoring-plugins.org"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "./common.h"
36#include "runcmd.h" 36#include "./runcmd.h"
37#include "utils.h" 37#include "./utils.h"
38#include "popen.h" 38#include "./popen.h"
39
40#include <string.h>
39 41
40#ifdef HAVE_SYS_LOADAVG_H 42#ifdef HAVE_SYS_LOADAVG_H
41#include <sys/loadavg.h> 43#include <sys/loadavg.h>
@@ -101,7 +103,7 @@ get_threshold(char *arg, double *th)
101int 103int
102main (int argc, char **argv) 104main (int argc, char **argv)
103{ 105{
104 int result; 106 int result = -1;
105 int i; 107 int i;
106 long numcpus; 108 long numcpus;
107 109
@@ -164,7 +166,7 @@ main (int argc, char **argv)
164 sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15); 166 sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15);
165 } 167 }
166 else { 168 else {
167 printf (_("could not parse load from uptime %s: %s\n"), PATH_TO_UPTIME, result); 169 printf (_("could not parse load from uptime %s: %d\n"), PATH_TO_UPTIME, result);
168 return STATE_UNKNOWN; 170 return STATE_UNKNOWN;
169 } 171 }
170 172
@@ -289,7 +291,6 @@ process_arguments (int argc, char **argv)
289} 291}
290 292
291 293
292
293static int 294static int
294validate_arguments (void) 295validate_arguments (void)
295{ 296{
@@ -310,7 +311,6 @@ validate_arguments (void)
310} 311}
311 312
312 313
313
314void 314void
315print_help (void) 315print_help (void)
316{ 316{
@@ -321,7 +321,7 @@ print_help (void)
321 321
322 printf (_("This plugin tests the current system load average.")); 322 printf (_("This plugin tests the current system load average."));
323 323
324 printf ("\n\n"); 324 printf ("\n\n");
325 325
326 print_usage (); 326 print_usage ();
327 327
@@ -329,15 +329,15 @@ print_help (void)
329 printf (UT_EXTRA_OPTS); 329 printf (UT_EXTRA_OPTS);
330 330
331 printf (" %s\n", "-w, --warning=WLOAD1,WLOAD5,WLOAD15"); 331 printf (" %s\n", "-w, --warning=WLOAD1,WLOAD5,WLOAD15");
332 printf (" %s\n", _("Exit with WARNING status if load average exceeds WLOADn")); 332 printf (" %s\n", _("Exit with WARNING status if load average exceeds WLOADn"));
333 printf (" %s\n", "-c, --critical=CLOAD1,CLOAD5,CLOAD15"); 333 printf (" %s\n", "-c, --critical=CLOAD1,CLOAD5,CLOAD15");
334 printf (" %s\n", _("Exit with CRITICAL status if load average exceed CLOADn")); 334 printf (" %s\n", _("Exit with CRITICAL status if load average exceed CLOADn"));
335 printf (" %s\n", _("the load average format is the same used by \"uptime\" and \"w\"")); 335 printf (" %s\n", _("the load average format is the same used by \"uptime\" and \"w\""));
336 printf (" %s\n", "-r, --percpu"); 336 printf (" %s\n", "-r, --percpu");
337 printf (" %s\n", _("Divide the load averages by the number of CPUs (when possible)")); 337 printf (" %s\n", _("Divide the load averages by the number of CPUs (when possible)"));
338 printf (" %s\n", "-n, --procs-to-show=NUMBER_OF_PROCS"); 338 printf (" %s\n", "-n, --procs-to-show=NUMBER_OF_PROCS");
339 printf (" %s\n", _("Number of processes to show when printing the top consuming processes.")); 339 printf (" %s\n", _("Number of processes to show when printing the top consuming processes."));
340 printf (" %s\n", _("NUMBER_OF_PROCS=0 disables this feature. Default value is 0")); 340 printf (" %s\n", _("NUMBER_OF_PROCS=0 disables this feature. Default value is 0"));
341 341
342 printf (UT_SUPPORT); 342 printf (UT_SUPPORT);
343} 343}
@@ -345,8 +345,8 @@ print_help (void)
345void 345void
346print_usage (void) 346print_usage (void)
347{ 347{
348 printf ("%s\n", _("Usage:")); 348 printf ("%s\n", _("Usage:"));
349 printf ("%s [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15 [-n NUMBER_OF_PROCS]\n", progname); 349 printf ("%s [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15 [-n NUMBER_OF_PROCS]\n", progname);
350} 350}
351 351
352#ifdef PS_USES_PROCPCPU 352#ifdef PS_USES_PROCPCPU
@@ -384,8 +384,8 @@ static int print_top_consuming_processes() {
384#ifdef PS_USES_PROCPCPU 384#ifdef PS_USES_PROCPCPU
385 qsort(chld_out.line + 1, chld_out.lines - 1, sizeof(char*), cmpstringp); 385 qsort(chld_out.line + 1, chld_out.lines - 1, sizeof(char*), cmpstringp);
386#endif /* PS_USES_PROCPCPU */ 386#endif /* PS_USES_PROCPCPU */
387 int lines_to_show = chld_out.lines < (n_procs_to_show + 1) 387 int lines_to_show = chld_out.lines < (size_t)(n_procs_to_show + 1)
388 ? chld_out.lines : n_procs_to_show + 1; 388 ? (int)chld_out.lines : n_procs_to_show + 1;
389 for (i = 0; i < lines_to_show; i += 1) { 389 for (i = 0; i < lines_to_show; i += 1) {
390 printf("%s\n", chld_out.line[i]); 390 printf("%s\n", chld_out.line[i]);
391 } 391 }