[Nagiosplug-checkins] CVS: nagiosplug/plugins check_dig.c,1.15,1.16 check_http.c,1.42,1.43 check_load.c,1.9,1.10 check_mrtg.c,1.7,1.8 check_mrtgtraf.c,1.7,1.8 check_nwstat.c,1.10,1.11 check_overcr.c,1.5,1.6 check_ping.c,1.20,1.21 check_procs.c,1.17,1.18 check_real.c,1.9,1.10 utils.c,1.30,1.31 utils.h,1.14,1.15
Karl DeBisschop
kdebisschop at users.sourceforge.net
Fri Aug 8 23:02:02 CEST 2003
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv8765
Modified Files:
check_dig.c check_http.c check_load.c check_mrtg.c
check_mrtgtraf.c check_nwstat.c check_overcr.c check_ping.c
check_procs.c check_real.c utils.c utils.h
Log Message:
more pedantic compiler warns
Index: check_dig.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dig.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** check_dig.c 8 Aug 2003 05:09:40 -0000 1.15
--- check_dig.c 9 Aug 2003 06:01:02 -0000 1.16
***************
*** 98,102 ****
if (strstr (input_buffer, query_address) == input_buffer) {
! asprintf (&output, input_buffer);
result = STATE_OK;
}
--- 98,102 ----
if (strstr (input_buffer, query_address) == input_buffer) {
! output = strdup(input_buffer);
result = STATE_OK;
}
***************
*** 120,124 ****
printf ("%s", input_buffer);
if (strlen (output) == 0)
! asprintf (&output, 1 + index (input_buffer, ':'));
}
--- 120,124 ----
printf ("%s", input_buffer);
if (strlen (output) == 0)
! output = strdup (1 + index (input_buffer, ':'));
}
Index: check_http.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_http.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -r1.42 -r1.43
*** check_http.c 9 Aug 2003 04:19:41 -0000 1.42
--- check_http.c 9 Aug 2003 06:01:02 -0000 1.43
***************
*** 993,996 ****
--- 993,997 ----
print_revision (progname, revision);
+ printf (_("Copyright (c) 1999 Ethan Galstad <nagios at nagios.org>\n"));
printf (_(COPYRIGHT), copyright, email);
Index: check_load.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_load.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** check_load.c 7 Aug 2003 12:09:43 -0000 1.9
--- check_load.c 9 Aug 2003 06:01:02 -0000 1.10
***************
*** 46,50 ****
float cload1 = -1, cload5 = -1, cload15 = -1;
! char *status_line = "";
--- 46,50 ----
float cload1 = -1, cload5 = -1, cload15 = -1;
! char *status_line;
***************
*** 73,77 ****
if (process_arguments (argc, argv) == ERROR)
! usage ("\n");
#if HAVE_GETLOADAVG==1
--- 73,77 ----
if (process_arguments (argc, argv) == ERROR)
! usage ("failed processing arguments\n");
#if HAVE_GETLOADAVG==1
***************
*** 123,127 ****
#endif
! if ((la1 == -1) || (la5 == -1) || (la15 == -1)) {
#if HAVE_GETLOADAVG==1
printf (_("Error in getloadavg()\n"));
--- 123,127 ----
#endif
! if ((la1 < 0.0) || (la5 < 0.0) || (la15 < 0.0)) {
#if HAVE_GETLOADAVG==1
printf (_("Error in getloadavg()\n"));
Index: check_mrtg.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_mrtg.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** check_mrtg.c 7 Aug 2003 11:51:11 -0000 1.7
--- check_mrtg.c 9 Aug 2003 06:01:02 -0000 1.8
***************
*** 25,102 ****
#include "utils.h"
- /* original command line:
- <log_file> <expire_minutes> <AVG|MAX> <variable> <vwl> <vcl> <label> [units] */
-
- void
- print_usage (void)
- {
- printf (_("\
- Usage: %s -F log_file -a <AVG | MAX> -v variable -w warning -c critical\n\
- [-l label] [-u units] [-e expire_minutes] [-t timeout] [-v]\n"), progname);
- printf (_(UT_HLP_VRS), progname, progname);
- }
-
- void
- print_help (void)
- {
- print_revision (progname, revision);
-
- printf (_(COPYRIGHT), copyright, email);
-
- printf(_("\
- This plugin will check either the average or maximum value of one of the\n\
- two variables recorded in an MRTG log file.\n"));
-
- print_usage ();
-
- printf (_(UT_HELP_VRSN));
-
- printf (_("\
- -F, --logfile=FILE\n\
- The MRTG log file containing the data you want to monitor\n\
- -e, --expires=MINUTES\n\
- Minutes before MRTG data is considered to be too old\n\
- -a, --aggregation=AVG|MAX\n\
- Should we check average or maximum values?\n\
- -v, --variable=INTEGER\n\
- Which variable set should we inspect? (1 or 2)\n\
- -w, --warning=INTEGER\n\
- Threshold value for data to result in WARNING status\n\
- -c, --critical=INTEGER\n\
- Threshold value for data to result in CRITICAL status\n"));
-
- printf (_("\
- -l, --label=STRING\n\
- Type label for data (Examples: Conns, \"Processor Load\", In, Out)\n\
- -u, --units=STRING\n\
- Option units label for data (Example: Packets/Sec, Errors/Sec, \n\
- \"Bytes Per Second\", \"%% Utilization\")\n"));
-
- printf (_("\
- If the value exceeds the <vwl> threshold, a WARNING status is returned. If\n\
- the value exceeds the <vcl> threshold, a CRITICAL status is returned. If\n\
- the data in the log file is older than <expire_minutes> old, a WARNING\n\
- status is returned and a warning message is printed.\n\n"));
-
- printf(_("This plugin is useful for monitoring MRTG data that does not correspond to\n\
- bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth).\n\
- It can be used to monitor any kind of data that MRTG is monitoring - errors,\n\
- packets/sec, etc. I use MRTG in conjuction with the Novell NLM that allows\n\
- me to track processor utilization, user connections, drive space, etc and\n\
- this plugin works well for monitoring that kind of data as well.\n\n"));
-
- printf (_("Notes:\n\
- - This plugin only monitors one of the two variables stored in the MRTG log\n\
- file. If you want to monitor both values you will have to define two\n\
- commands with different values for the <variable> argument. Of course,\n\
- you can always hack the code to make this plugin work for you...\n\
- - MRTG stands for the Multi Router Traffic Grapher. It can be downloaded from\n\
- http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html\n"));
-
- printf (_(UT_SUPPORT));
- }
-
int process_arguments (int, char **);
int validate_arguments (void);
char *log_file = NULL;
--- 25,32 ----
#include "utils.h"
int process_arguments (int, char **);
int validate_arguments (void);
+ void print_help (void);
+ void print_usage (void);
char *log_file = NULL;
***************
*** 106,111 ****
unsigned long value_warning_threshold = 0L;
unsigned long value_critical_threshold = 0L;
! char *value_label = "";
! char *units_label = "";
int
--- 36,41 ----
unsigned long value_warning_threshold = 0L;
unsigned long value_critical_threshold = 0L;
! char *value_label;
! char *units_label;
int
***************
*** 352,355 ****
--- 282,372 ----
usage (_("You must supply the variable number\n"));
+ if (value_label == NULL)
+ value_label = strdup ("");
+
+ if (units_label == NULL)
+ units_label = strdup ("");
+
return OK;
+ }
+
+
+
+
+
+
+ void
+ print_help (void)
+ {
+ print_revision (progname, revision);
+
+ printf (_("Copyright (c) 1999 Ethan Galstad <nagios at nagios.org>\n"));
+ printf (_(COPYRIGHT), copyright, email);
+
+ printf(_("\
+ This plugin will check either the average or maximum value of one of the\n\
+ two variables recorded in an MRTG log file.\n"));
+
+ print_usage ();
+
+ printf (_(UT_HELP_VRSN));
+
+ printf (_("\
+ -F, --logfile=FILE\n\
+ The MRTG log file containing the data you want to monitor\n\
+ -e, --expires=MINUTES\n\
+ Minutes before MRTG data is considered to be too old\n\
+ -a, --aggregation=AVG|MAX\n\
+ Should we check average or maximum values?\n\
+ -v, --variable=INTEGER\n\
+ Which variable set should we inspect? (1 or 2)\n\
+ -w, --warning=INTEGER\n\
+ Threshold value for data to result in WARNING status\n\
+ -c, --critical=INTEGER\n\
+ Threshold value for data to result in CRITICAL status\n"));
+
+ printf (_("\
+ -l, --label=STRING\n\
+ Type label for data (Examples: Conns, \"Processor Load\", In, Out)\n\
+ -u, --units=STRING\n\
+ Option units label for data (Example: Packets/Sec, Errors/Sec, \n\
+ \"Bytes Per Second\", \"%% Utilization\")\n"));
+
+ printf (_("\
+ If the value exceeds the <vwl> threshold, a WARNING status is returned. If\n\
+ the value exceeds the <vcl> threshold, a CRITICAL status is returned. If\n\
+ the data in the log file is older than <expire_minutes> old, a WARNING\n\
+ status is returned and a warning message is printed.\n\n"));
+
+ printf(_("This plugin is useful for monitoring MRTG data that does not correspond to\n\
+ bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth).\n\
+ It can be used to monitor any kind of data that MRTG is monitoring - errors,\n\
+ packets/sec, etc. I use MRTG in conjuction with the Novell NLM that allows\n\
+ me to track processor utilization, user connections, drive space, etc and\n\
+ this plugin works well for monitoring that kind of data as well.\n\n"));
+
+ printf (_("Notes:\n\
+ - This plugin only monitors one of the two variables stored in the MRTG log\n\
+ file. If you want to monitor both values you will have to define two\n\
+ commands with different values for the <variable> argument. Of course,\n\
+ you can always hack the code to make this plugin work for you...\n\
+ - MRTG stands for the Multi Router Traffic Grapher. It can be downloaded from\n\
+ http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html\n"));
+
+ printf (_(UT_SUPPORT));
+ }
+
+
+
+
+ /* original command line:
+ <log_file> <expire_minutes> <AVG|MAX> <variable> <vwl> <vcl> <label> [units] */
+
+ void
+ print_usage (void)
+ {
+ printf (_("\
+ Usage: %s -F log_file -a <AVG | MAX> -v variable -w warning -c critical\n\
+ [-l label] [-u units] [-e expire_minutes] [-t timeout] [-v]\n"), progname);
+ printf (_(UT_HLP_VRS), progname, progname);
}
Index: check_mrtgtraf.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_mrtgtraf.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** check_mrtgtraf.c 7 Aug 2003 11:51:11 -0000 1.7
--- check_mrtgtraf.c 9 Aug 2003 06:01:02 -0000 1.8
***************
*** 25,82 ****
const char *email = "nagiosplug-devel at lists.sourceforge.net";
- void
- print_usage (void)
- {
- printf (_("\
- Usage: %s -F <log_file> -a <AVG | MAX> -v <variable> -w <warning_pair> -c <critical_pair>\n\
- [-e expire_minutes] [-t timeout] [-v]\n"), progname);
- printf (_(UT_HLP_VRS), progname, progname);
- }
-
- void
- print_help (void)
- {
- print_revision (progname, revision);
-
- printf (_(COPYRIGHT), copyright, email);
-
- print_usage ();
-
- printf (_(UT_HELP_VRSN));
-
- printf (_("\
- -F, --filename=STRING\n\
- File to read log from\n\
- -e, --expires=INTEGER\n\
- Minutes after which log expires\n\
- -a, --aggregation=(AVG|MAX)\n\
- Test average or maximum\n\
- -w, --warning\n\
- Warning threshold pair \"<incoming>,<outgoing>\"\n\
- -c, --critical\n\
- Critical threshold pair \"<incoming>,<outgoing>\"\n"));
-
- printf (_("\n\
- This plugin will check the incoming/outgoing transfer rates of a router,\n\
- switch, etc recorded in an MRTG log. If the newest log entry is older\n\
- than <expire_minutes>, a WARNING status is returned. If either the\n\
- incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in\n\
- Bytes/sec), a CRITICAL status results. If either of the rates exceed\n\
- the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results.\n\n"));
-
- printf (_("Notes:\n\
- - MRTG stands for Multi Router Traffic Grapher. It can be downloaded from\n\
- http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html\n\
- - While MRTG can monitor things other than traffic rates, this\n\
- plugin probably won't work with much else without modification.\n\
- - The calculated i/o rates are a little off from what MRTG actually\n\
- reports. I'm not sure why this is right now, but will look into it\n\
- for future enhancements of this plugin.\n"));
-
- printf (_(UT_SUPPORT));
- }
-
int process_arguments (int, char **);
int validate_arguments (void);
char *log_file = NULL;
--- 25,32 ----
const char *email = "nagiosplug-devel at lists.sourceforge.net";
int process_arguments (int, char **);
int validate_arguments (void);
+ void print_help(void);
+ void print_usage(void);
char *log_file = NULL;
***************
*** 88,91 ****
--- 38,45 ----
unsigned long outgoing_critical_threshold = 0L;
+
+
+
+
int
main (int argc, char **argv)
***************
*** 357,359 ****
--- 311,374 ----
{
return OK;
+ }
+
+
+
+
+
+
+ void
+ print_help (void)
+ {
+ print_revision (progname, revision);
+
+ printf (_("Copyright (c) 1999 Ethan Galstad <nagios at nagios.org>\n"));
+ printf (_(COPYRIGHT), copyright, email);
+
+ print_usage ();
+
+ printf (_(UT_HELP_VRSN));
+
+ printf (_("\
+ -F, --filename=STRING\n\
+ File to read log from\n\
+ -e, --expires=INTEGER\n\
+ Minutes after which log expires\n\
+ -a, --aggregation=(AVG|MAX)\n\
+ Test average or maximum\n\
+ -w, --warning\n\
+ Warning threshold pair \"<incoming>,<outgoing>\"\n\
+ -c, --critical\n\
+ Critical threshold pair \"<incoming>,<outgoing>\"\n"));
+
+ printf (_("\n\
+ This plugin will check the incoming/outgoing transfer rates of a router,\n\
+ switch, etc recorded in an MRTG log. If the newest log entry is older\n\
+ than <expire_minutes>, a WARNING status is returned. If either the\n\
+ incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in\n\
+ Bytes/sec), a CRITICAL status results. If either of the rates exceed\n\
+ the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results.\n\n"));
+
+ printf (_("Notes:\n\
+ - MRTG stands for Multi Router Traffic Grapher. It can be downloaded from\n\
+ http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html\n\
+ - While MRTG can monitor things other than traffic rates, this\n\
+ plugin probably won't work with much else without modification.\n\
+ - The calculated i/o rates are a little off from what MRTG actually\n\
+ reports. I'm not sure why this is right now, but will look into it\n\
+ for future enhancements of this plugin.\n"));
+
+ printf (_(UT_SUPPORT));
+ }
+
+
+
+
+ void
+ print_usage (void)
+ {
+ printf (_("\
+ Usage: %s -F <log_file> -a <AVG | MAX> -v <variable> -w <warning_pair> -c <critical_pair>\n\
+ [-e expire_minutes] [-t timeout] [-v]\n"), progname);
+ printf (_(UT_HLP_VRS), progname, progname);
}
Index: check_nwstat.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_nwstat.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** check_nwstat.c 7 Aug 2003 11:51:11 -0000 1.10
--- check_nwstat.c 9 Aug 2003 06:01:02 -0000 1.11
***************
*** 76,82 ****
int process_arguments(int, char **);
- void print_usage(void);
void print_help(void);
int
main(int argc, char **argv) {
--- 76,87 ----
int process_arguments(int, char **);
void print_help(void);
+ void print_usage(void);
+
+
+
+
+
int
main(int argc, char **argv) {
***************
*** 879,891 ****
return OK;
}
-
- void print_usage(void)
- {
- printf (_("\
- Usage: %s -H host [-p port] [-v variable] [-w warning] [-c critical]\n\
- [-t timeout].\n"), progname);
- printf (_(UT_HLP_VRS), progname, progname);
- }
void print_help(void)
{
--- 884,893 ----
return OK;
}
+
+
+
+
+
void print_help(void)
{
***************
*** 895,899 ****
print_revision (progname, revision);
! printf (_("Copyright (c) 1999-2001 Ethan Galstad <nagios at nagios.org>\n"));
printf (_(COPYRIGHT), copyright, email);
--- 897,901 ----
print_revision (progname, revision);
! printf (_("Copyright (c) 1999 Ethan Galstad <nagios at nagios.org>\n"));
printf (_(COPYRIGHT), copyright, email);
***************
*** 972,974 ****
--- 974,987 ----
printf (_(UT_SUPPORT));
+ }
+
+
+
+
+ void print_usage(void)
+ {
+ printf (_("\
+ Usage: %s -H host [-p port] [-v variable] [-w warning] [-c critical]\n\
+ [-t timeout].\n"), progname);
+ printf (_(UT_HLP_VRS), progname, progname);
}
Index: check_overcr.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_overcr.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** check_overcr.c 7 Aug 2003 11:51:11 -0000 1.5
--- check_overcr.c 9 Aug 2003 06:01:02 -0000 1.6
***************
*** 107,121 ****
if (temp_ptr == NULL)
die (STATE_CRITICAL, _("Invalid response from server - no load information\n"));
! load_1min = strtod (temp_ptr, NULL);
temp_ptr = (char *) strtok (NULL, "\r\n");
if (temp_ptr == NULL)
die (STATE_CRITICAL, _("Invalid response from server after load 1\n"));
! load_5min = strtod (temp_ptr, NULL);
temp_ptr = (char *) strtok (NULL, "\r\n");
if (temp_ptr == NULL)
die (STATE_CRITICAL, _("Invalid response from server after load 5\n"));
! load_15min = strtod (temp_ptr, NULL);
switch (vars_to_check) {
--- 107,124 ----
if (temp_ptr == NULL)
die (STATE_CRITICAL, _("Invalid response from server - no load information\n"));
! else
! load_1min = strtod (temp_ptr, NULL);
temp_ptr = (char *) strtok (NULL, "\r\n");
if (temp_ptr == NULL)
die (STATE_CRITICAL, _("Invalid response from server after load 1\n"));
! else
! load_5min = strtod (temp_ptr, NULL);
temp_ptr = (char *) strtok (NULL, "\r\n");
if (temp_ptr == NULL)
die (STATE_CRITICAL, _("Invalid response from server after load 5\n"));
! else
! load_15min = strtod (temp_ptr, NULL);
switch (vars_to_check) {
***************
*** 161,165 ****
if (temp_ptr == NULL)
die (STATE_CRITICAL, _("Invalid response from server\n"));
! percent_used_disk_space = strtoul (temp_ptr, NULL, 10);
break;
}
--- 164,169 ----
if (temp_ptr == NULL)
die (STATE_CRITICAL, _("Invalid response from server\n"));
! else
! percent_used_disk_space = strtoul (temp_ptr, NULL, 10);
break;
}
***************
*** 187,192 ****
if (result != STATE_OK)
die (result, _("Unknown error fetching network status\n"));
!
! port_connections = strtod (recv_buffer, NULL);
if (check_critical_value == TRUE && (port_connections >= critical_value))
--- 191,196 ----
if (result != STATE_OK)
die (result, _("Unknown error fetching network status\n"));
! else
! port_connections = strtod (recv_buffer, NULL);
if (check_critical_value == TRUE && (port_connections >= critical_value))
***************
*** 216,221 ****
if (temp_ptr == NULL)
die (STATE_CRITICAL, _("Invalid response from server\n"));
!
! processes = strtod (temp_ptr, NULL);
if (check_critical_value == TRUE && (processes >= critical_value))
--- 220,225 ----
if (temp_ptr == NULL)
die (STATE_CRITICAL, _("Invalid response from server\n"));
! else
! processes = strtod (temp_ptr, NULL);
if (check_critical_value == TRUE && (processes >= critical_value))
***************
*** 265,273 ****
/* reset timeout */
! alarm (0);
! printf (_("Reached end of program with no data returned\n"));
! return result;
}
--- 269,277 ----
/* reset timeout */
! /* alarm (0); */
! /* printf (_("Reached end of program with no data returned\n")); */
! /* return result; */
}
Index: check_ping.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ping.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** check_ping.c 7 Aug 2003 11:49:47 -0000 1.20
--- check_ping.c 9 Aug 2003 06:01:03 -0000 1.21
***************
*** 56,60 ****
int pl = UNKNOWN_PACKET_LOSS;
! char *warn_text = "";
--- 56,60 ----
int pl = UNKNOWN_PACKET_LOSS;
! char *warn_text;
***************
*** 70,78 ****
int i;
! addresses = malloc (max_addr);
if (process_arguments (argc, argv) == ERROR)
usage (_("Could not parse arguments"));
- exit;
/* Set signal handling and alarm */
--- 70,77 ----
int i;
! addresses = malloc ((size_t)max_addr);
if (process_arguments (argc, argv) == ERROR)
usage (_("Could not parse arguments"));
/* Set signal handling and alarm */
***************
*** 114,118 ****
this_result = run_ping (cmd, addresses[i]);
! if (pl == UNKNOWN_PACKET_LOSS || rta == UNKNOWN_TRIP_TIME) {
printf ("%s\n", cmd);
die (STATE_UNKNOWN,
--- 113,117 ----
this_result = run_ping (cmd, addresses[i]);
! if (pl == UNKNOWN_PACKET_LOSS || rta < 0.0) {
printf ("%s\n", cmd);
die (STATE_UNKNOWN,
***************
*** 194,203 ****
--- 193,205 ----
case '?': /* usage */
usage3 (_("Unknown argument"), optopt);
+ break;
case 'h': /* help */
print_help ();
exit (STATE_OK);
+ break;
case 'V': /* version */
print_revision (progname, revision);
exit (STATE_OK);
+ break;
case 't': /* timeout period */
timeout_interval = atoi (optarg);
***************
*** 222,226 ****
if (n_addresses > max_addr) {
max_addr *= 2;
! addresses = realloc (addresses, max_addr);
if (addresses == NULL)
die (STATE_UNKNOWN, _("Could not realloc() addresses\n"));
--- 224,228 ----
if (n_addresses > max_addr) {
max_addr *= 2;
! addresses = realloc (addresses, (size_t)max_addr);
if (addresses == NULL)
die (STATE_UNKNOWN, _("Could not realloc() addresses\n"));
***************
*** 293,297 ****
}
! if (wrta == UNKNOWN_TRIP_TIME) {
if (is_negative (argv[c])) {
printf (_("<wrta> (%s) must be a non-negative number\n"), argv[c]);
--- 295,299 ----
}
! if (wrta < 0.0) {
if (is_negative (argv[c])) {
printf (_("<wrta> (%s) must be a non-negative number\n"), argv[c]);
***************
*** 304,308 ****
}
! if (crta == UNKNOWN_TRIP_TIME) {
if (is_negative (argv[c])) {
printf (_("<crta> (%s) must be a non-negative number\n"), argv[c]);
--- 306,310 ----
}
! if (crta < 0.0) {
if (is_negative (argv[c])) {
printf (_("<crta> (%s) must be a non-negative number\n"), argv[c]);
***************
*** 347,355 ****
int i;
! if (wrta == UNKNOWN_TRIP_TIME) {
printf (_("<wrta> was not set\n"));
return ERROR;
}
! else if (crta == UNKNOWN_TRIP_TIME) {
printf (_("<crta> was not set\n"));
return ERROR;
--- 349,357 ----
int i;
! if (wrta < 0.0) {
printf (_("<wrta> was not set\n"));
return ERROR;
}
! else if (crta < 0.0) {
printf (_("<crta> was not set\n"));
return ERROR;
***************
*** 398,405 ****
int result = STATE_UNKNOWN;
! if ((child_process = spopen (cmd)) == NULL) {
! printf (_("Cannot open pipe: "));
! die (STATE_UNKNOWN, cmd);
! }
child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
if (child_stderr == NULL)
--- 400,406 ----
int result = STATE_UNKNOWN;
! if ((child_process = spopen (cmd)) == NULL)
! die (STATE_UNKNOWN, _("Cannot open pipe: %s"), cmd);
!
child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
if (child_stderr == NULL)
***************
*** 456,460 ****
server_address);
! if (strlen (warn_text) == 0)
warn_text = strdup (buf);
else if (asprintf (&warn_text, "%s %s", warn_text, buf) == -1)
--- 457,461 ----
server_address);
! if (warn_text == NULL)
warn_text = strdup (buf);
else if (asprintf (&warn_text, "%s %s", warn_text, buf) == -1)
***************
*** 472,475 ****
--- 473,479 ----
if (spclose (child_process))
result = max_state (result, STATE_WARNING);
+
+ if (warn_text == NULL)
+ warn_text = strdup("");
return result;
Index: check_procs.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_procs.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** check_procs.c 7 Aug 2003 12:36:45 -0000 1.17
--- check_procs.c 9 Aug 2003 06:01:03 -0000 1.18
***************
*** 50,59 ****
/* Different metrics */
! int metric = 0;
! #define METRIC_PROCS 0
! #define METRIC_VSZ 1
! #define METRIC_RSS 2
! #define METRIC_CPU 3
! char *metric_name = "";
int verbose = 0;
--- 50,61 ----
/* Different metrics */
! char *metric_name;
! enum metric {
! METRIC_PROCS,
! METRIC_VSZ,
! METRIC_RSS,
! METRIC_CPU
! };
! enum metric metric = METRIC_PROCS;
int verbose = 0;
***************
*** 63,71 ****
int rss;
float pcpu;
! char *statopts = "";
! char *prog = "";
! char *args = "";
! char *fmt = "";
! char *fails = "";
char tmp[MAX_INPUT_BUFFER];
--- 65,73 ----
int rss;
float pcpu;
! char *statopts;
! char *prog;
! char *args;
! char *fmt;
! char *fails;
char tmp[MAX_INPUT_BUFFER];
***************
*** 318,369 ****
exit (STATE_OK);
case 't': /* timeout period */
! if (!is_integer (optarg)) {
! printf (_("%s: Timeout Interval must be an integer!\n\n"),
! progname);
! print_usage ();
! exit (STATE_UNKNOWN);
! }
! timeout_interval = atoi (optarg);
break;
case 'c': /* critical threshold */
! if (is_integer (optarg)) {
cmax = atoi (optarg);
break;
! }
! else if (sscanf (optarg, ":%d", &cmax) == 1) {
break;
! }
! else if (sscanf (optarg, "%d:%d", &cmin, &cmax) == 2) {
break;
! }
! else if (sscanf (optarg, "%d:", &cmin) == 1) {
! break;
! }
! else {
! printf (_("%s: Critical Process Count must be an integer!\n\n"),
! progname);
! print_usage ();
! exit (STATE_UNKNOWN);
! }
case 'w': /* warning time threshold */
! if (is_integer (optarg)) {
wmax = atoi (optarg);
break;
! }
! else if (sscanf (optarg, ":%d", &wmax) == 1) {
! break;
! }
! else if (sscanf (optarg, "%d:%d", &wmin, &wmax) == 2) {
break;
! }
! else if (sscanf (optarg, "%d:", &wmin) == 1) {
break;
! }
! else {
! printf (_("%s: Warning Process Count must be an integer!\n\n"),
! progname);
! print_usage ();
! exit (STATE_UNKNOWN);
! }
case 'p': /* process id */
if (sscanf (optarg, "%d%[^0-9]", &ppid, tmp) == 1) {
--- 320,352 ----
exit (STATE_OK);
case 't': /* timeout period */
! if (!is_integer (optarg))
! usage (_("Timeout Interval must be an integer!\n\n"));
! else
! timeout_interval = atoi (optarg);
break;
case 'c': /* critical threshold */
! if (is_integer (optarg))
cmax = atoi (optarg);
+ else if (sscanf (optarg, ":%d", &cmax) == 1)
break;
! else if (sscanf (optarg, "%d:%d", &cmin, &cmax) == 2)
break;
! else if (sscanf (optarg, "%d:", &cmin) == 1)
break;
! else
! usage (_("Critical Process Count must be an integer!\n\n"));
! break;
case 'w': /* warning time threshold */
! if (is_integer (optarg))
wmax = atoi (optarg);
+ else if (sscanf (optarg, ":%d", &wmax) == 1)
break;
! else if (sscanf (optarg, "%d:%d", &wmin, &wmax) == 2)
break;
! else if (sscanf (optarg, "%d:", &wmin) == 1)
break;
! else
! usage (_("%s: Warning Process Count must be an integer!\n\n"));
! break;
case 'p': /* process id */
if (sscanf (optarg, "%d%[^0-9]", &ppid, tmp) == 1) {
***************
*** 377,381 ****
exit (STATE_UNKNOWN);
case 's': /* status */
! asprintf (&statopts, "%s", optarg);
asprintf (&fmt, _("%s%sSTATE = %s"), fmt, (options ? ", " : ""), statopts);
options |= STAT;
--- 360,367 ----
exit (STATE_UNKNOWN);
case 's': /* status */
! if (statopts)
! break;
! else
! statopts = strdup(optarg);
asprintf (&fmt, _("%s%sSTATE = %s"), fmt, (options ? ", " : ""), statopts);
options |= STAT;
***************
*** 409,413 ****
break;
case 'C': /* command */
! asprintf (&prog, "%s", optarg);
asprintf (&fmt, _("%s%scommand name '%s'"), fmt, (options ? ", " : ""),
prog);
--- 395,402 ----
break;
case 'C': /* command */
! if (prog)
! break;
! else
! prog = strdup(optarg);
asprintf (&fmt, _("%s%scommand name '%s'"), fmt, (options ? ", " : ""),
prog);
***************
*** 415,419 ****
break;
case 'a': /* args (full path name with args) */
! asprintf (&args, "%s", optarg);
asprintf (&fmt, _("%s%sargs '%s'"), fmt, (options ? ", " : ""), args);
options |= ARGS;
--- 404,411 ----
break;
case 'a': /* args (full path name with args) */
! if (args)
! break;
! else
! args = strdup(optarg);
asprintf (&fmt, _("%s%sargs '%s'"), fmt, (options ? ", " : ""), args);
options |= ARGS;
***************
*** 521,524 ****
--- 513,531 ----
if (options == 0)
options = ALL;
+
+ if (statopts==NULL)
+ statopts = strdup("");
+
+ if (prog==NULL)
+ prog = strdup("");
+
+ if (args==NULL)
+ args = strdup("");
+
+ if (fmt==NULL)
+ fmt = strdup("");
+
+ if (fails==NULL)
+ fails = strdup("");
return options;
Index: check_real.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_real.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** check_real.c 7 Aug 2003 23:17:53 -0000 1.9
--- check_real.c 9 Aug 2003 06:01:03 -0000 1.10
***************
*** 39,46 ****
int server_port = PORT;
! char *server_address = "";
! char *host_name = "";
char *server_url = NULL;
! char *server_expect = EXPECT;
int warning_time = 0;
int check_warning_time = FALSE;
--- 39,46 ----
int server_port = PORT;
! char *server_address;
! char *host_name;
char *server_url = NULL;
! char *server_expect;
int warning_time = 0;
int check_warning_time = FALSE;
***************
*** 295,310 ****
case 'I': /* hostname */
case 'H': /* hostname */
! if (is_host (optarg)) {
! server_address = optarg;
! }
! else {
usage (_("Invalid host name\n"));
- }
break;
case 'e': /* string to expect in response header */
! server_expect = optarg;
break;
case 'u': /* server URL */
! server_url = optarg;
break;
case 'p': /* port */
--- 295,310 ----
case 'I': /* hostname */
case 'H': /* hostname */
! if (server_address)
! break;
! else if (is_host (optarg))
! server_address = strdup(optarg);
! else
usage (_("Invalid host name\n"));
break;
case 'e': /* string to expect in response header */
! server_expect = strdup(optarg);
break;
case 'u': /* server URL */
! server_url = strdup(optarg);
break;
case 'p': /* port */
***************
*** 357,361 ****
c = optind;
! if (strlen(server_address)==0 && argc>c) {
if (is_host (argv[c])) {
server_address = argv[c++];
--- 357,361 ----
c = optind;
! if (server_address==NULL && argc>c) {
if (is_host (argv[c])) {
server_address = argv[c++];
***************
*** 366,374 ****
}
! if (strlen(server_address) == 0)
usage (_("You must provide a server to check\n"));
! if (strlen(host_name) == 0)
! asprintf (&host_name, "%s", server_address);
return validate_arguments ();
--- 366,377 ----
}
! if (server_address==NULL)
usage (_("You must provide a server to check\n"));
! if (host_name==NULL)
! host_name = strdup (server_address);
!
! if (server_expect == NULL)
! server_expect = strdup(EXPECT);
return validate_arguments ();
Index: utils.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** utils.c 9 Aug 2003 04:12:14 -0000 1.30
--- utils.c 9 Aug 2003 06:01:03 -0000 1.31
***************
*** 53,57 ****
}
! void usage (char *msg)
{
printf ("%s", msg);
--- 53,57 ----
}
! void usage (const char *msg)
{
printf ("%s", msg);
***************
*** 60,64 ****
}
! void usage2(char *msg, char *arg)
{
printf ("%s: %s - %s\n",progname,msg,arg);
--- 60,64 ----
}
! void usage2(const char *msg, const char *arg)
{
printf ("%s: %s - %s\n",progname,msg,arg);
***************
*** 68,72 ****
void
! usage3 (char *msg, int arg)
{
printf ("%s: %s - %c\n", progname, msg, arg);
--- 68,72 ----
void
! usage3 (const char *msg, int arg)
{
printf ("%s: %s - %c\n", progname, msg, arg);
Index: utils.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** utils.h 9 Aug 2003 04:12:14 -0000 1.14
--- utils.h 9 Aug 2003 06:01:03 -0000 1.15
***************
*** 72,78 ****
int max_state (int a, int b);
! void usage (char *msg) __attribute__((noreturn));
! void usage2(char *msg, char *arg) __attribute__((noreturn));
! void usage3(char *msg, int arg) __attribute__((noreturn));
const char *state_text (int result);
--- 72,78 ----
int max_state (int a, int b);
! void usage (const char *msg) __attribute__((noreturn));
! void usage2(const char *msg, const char *arg) __attribute__((noreturn));
! void usage3(const char *msg, int arg) __attribute__((noreturn));
const char *state_text (int result);
More information about the Commits
mailing list