diff --git a/plugins/check_load.c b/plugins/check_load.c
index 3c0ecad80b51506b1fa1acf0438dce68d4a28bd0..ba1a59830ae8d0ec0d55b06ac33fca66cf024396 100644 (file)
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
#endif
-#define PROGNAME "check_load"
+const char *progname = "check_load";
int process_arguments (int argc, char **argv);
int validate_arguments (void);
float wload1 = -1, wload5 = -1, wload15 = -1;
float cload1 = -1, cload5 = -1, cload15 = -1;
+char *status_line = "";
+
int
main (int argc, char **argv)
{
#endif
return STATE_UNKNOWN;
}
- printf ("load average: %.2f, %.2f, %.2f", la1, la5, la15);
+ asprintf(&status_line, "load average: %.2f, %.2f, %.2f", la1, la5, la15);
if ((la1 >= cload1) || (la5 >= cload5) || (la15 >= cload15)) {
- printf (" CRITICAL\n");
+ printf("CRITICAL - %s\n", status_line);
return STATE_CRITICAL;
}
if ((la1 >= wload1) || (la5 >= wload5) || (la15 >= wload15)) {
- printf (" WARNING\n");
+ printf ("WARNING - %s\n", status_line);
return STATE_WARNING;
}
- printf ("\n");
+ printf ("OK - %s\n", status_line);
return STATE_OK;
}
int
process_arguments (int argc, char **argv)
{
- int c, i = 0;
+ int c = 0;
-#ifdef HAVE_GETOPT_H
int option_index = 0;
static struct option long_options[] = {
{"warning", required_argument, 0, 'w'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
-#endif
-
-#define OPTCHARS "Vhc:w:"
if (argc < 2)
return ERROR;
while (1) {
-#ifdef HAVE_GETOPT_H
- c = getopt_long (argc, argv, OPTCHARS, long_options, &option_index);
-#else
- c = getopt (argc, argv, OPTCHARS);
-#endif
+ c = getopt_long (argc, argv, "Vhc:w:", long_options, &option_index);
+
if (c == -1 || c == EOF)
break;
usage ("Critical threshold must be float or float triplet!\n");
break;
case 'V': /* version */
- print_revision (my_basename (argv[0]), "$Revision$");
+ print_revision (progname, "$Revision$");
exit (STATE_OK);
case 'h': /* help */
print_help ();
void
print_help (void)
{
- print_revision (PROGNAME, "$Revision$");
+ print_revision (progname, "$Revision$");
printf
("Copyright (c) 1999 Felipe Gustavo de Almeida <galmeida@linux.ime.usp.br>\n"
"Copyright (c) 2000 Karl DeBisschop\n\n"