mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-03-24 11:23:12 -04:00
replace "terminate" with "die" for shorter name and better readability
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@656 f882894a-f735-0410-b71e-b25c423dba1c
This commit is contained in:
parent
7f1bb2a782
commit
9e17dab6c3
23 changed files with 102 additions and 114 deletions
|
|
@ -349,9 +349,9 @@ process_arguments (int argc, char **argv)
|
|||
c = optind;
|
||||
if (hostname == NULL) {
|
||||
if (c <= argc) {
|
||||
terminate (STATE_UNKNOWN, _("%s: You must provide a host name\n"), progname);
|
||||
die (STATE_UNKNOWN, _("%s: You must provide a host name\n"), progname);
|
||||
} else if (!is_host (argv[c]))
|
||||
terminate (STATE_UNKNOWN, _("%s: Invalid host name %s\n"), progname, argv[c]);
|
||||
die (STATE_UNKNOWN, _("%s: Invalid host name %s\n"), progname, argv[c]);
|
||||
hostname = argv[c++];
|
||||
}
|
||||
|
||||
|
|
@ -385,10 +385,10 @@ validate_arguments (void)
|
|||
return ERROR;
|
||||
|
||||
if (passive && commands != services)
|
||||
terminate (STATE_UNKNOWN, _("%s: In passive mode, you must provide a service name for each command.\n"), progname);
|
||||
die (STATE_UNKNOWN, _("%s: In passive mode, you must provide a service name for each command.\n"), progname);
|
||||
|
||||
if (passive && host_shortname == NULL)
|
||||
terminate (STATE_UNKNOWN, _("%s: In passive mode, you must provide the host short name from the nagios configs.\n"), progname);
|
||||
die (STATE_UNKNOWN, _("%s: In passive mode, you must provide the host short name from the nagios configs.\n"), progname);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ main (int argc, char **argv)
|
|||
temp_list = temp_list->name_next;
|
||||
}
|
||||
|
||||
terminate (result, "DISK %s%s\n", state_text (result), output, details);
|
||||
die (result, "DISK %s%s\n", state_text (result), output, details);
|
||||
return STATE_UNKNOWN;
|
||||
}
|
||||
|
||||
|
|
@ -406,7 +406,7 @@ process_arguments (int argc, char **argv)
|
|||
mult = (unsigned long)1024 * 1024 * 1024 * 1024;
|
||||
units = "TB";
|
||||
} else {
|
||||
terminate (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
|
||||
die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
|
||||
}
|
||||
break;
|
||||
case 'k': /* display mountpoint */
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ main (int argc, char **argv)
|
|||
address = strdup (temp_buffer);
|
||||
strip (address);
|
||||
if (address==NULL || strlen(address)==0)
|
||||
terminate (STATE_CRITICAL,
|
||||
die (STATE_CRITICAL,
|
||||
_("DNS CRITICAL - '%s' returned empty host name string\n"),
|
||||
NSLOOKUP_COMMAND);
|
||||
result = STATE_OK;
|
||||
|
|
@ -224,7 +224,7 @@ main (int argc, char **argv)
|
|||
/* If we got here, we should have an address string,
|
||||
and we can segfault if we do not */
|
||||
if (address==NULL || strlen(address)==0)
|
||||
terminate (STATE_CRITICAL,
|
||||
die (STATE_CRITICAL,
|
||||
_("DNS CRITICAL - '%s' output parsing exited with no address\n"),
|
||||
NSLOOKUP_COMMAND);
|
||||
|
||||
|
|
@ -270,32 +270,32 @@ error_scan (char *input_buffer)
|
|||
|
||||
/* DNS server is not running... */
|
||||
else if (strstr (input_buffer, "No response from server"))
|
||||
terminate (STATE_CRITICAL, _("No response from name server %s\n"), dns_server);
|
||||
die (STATE_CRITICAL, _("No response from name server %s\n"), dns_server);
|
||||
|
||||
/* Host name is valid, but server doesn't have records... */
|
||||
else if (strstr (input_buffer, "No records"))
|
||||
terminate (STATE_CRITICAL, _("Name server %s has no records\n"), dns_server);
|
||||
die (STATE_CRITICAL, _("Name server %s has no records\n"), dns_server);
|
||||
|
||||
/* Connection was refused */
|
||||
else if (strstr (input_buffer, "Connection refused") ||
|
||||
(strstr (input_buffer, "** server can't find") &&
|
||||
strstr (input_buffer, ": REFUSED")) ||
|
||||
(strstr (input_buffer, "Refused")))
|
||||
terminate (STATE_CRITICAL, _("Connection to name server %s was refused\n"), dns_server);
|
||||
die (STATE_CRITICAL, _("Connection to name server %s was refused\n"), dns_server);
|
||||
|
||||
/* Host or domain name does not exist */
|
||||
else if (strstr (input_buffer, "Non-existent") ||
|
||||
strstr (input_buffer, "** server can't find") ||
|
||||
strstr (input_buffer,"NXDOMAIN"))
|
||||
terminate (STATE_CRITICAL, _("Domain %s was not found by the server\n"), query_address);
|
||||
die (STATE_CRITICAL, _("Domain %s was not found by the server\n"), query_address);
|
||||
|
||||
/* Network is unreachable */
|
||||
else if (strstr (input_buffer, "Network is unreachable"))
|
||||
terminate (STATE_CRITICAL, _("Network is unreachable\n"));
|
||||
die (STATE_CRITICAL, _("Network is unreachable\n"));
|
||||
|
||||
/* Internal server failure */
|
||||
else if (strstr (input_buffer, "Server failure"))
|
||||
terminate (STATE_CRITICAL, _("Server failure for %s\n"), dns_server);
|
||||
die (STATE_CRITICAL, _("Server failure for %s\n"), dns_server);
|
||||
|
||||
/* Request error or the DNS lookup timed out */
|
||||
else if (strstr (input_buffer, "Format error") ||
|
||||
|
|
@ -357,7 +357,7 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'H': /* hostname */
|
||||
if (strlen (optarg) >= ADDRESS_LENGTH)
|
||||
terminate (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
die (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
strcpy (query_address, optarg);
|
||||
break;
|
||||
case 's': /* server name */
|
||||
|
|
@ -369,7 +369,7 @@ process_arguments (int argc, char **argv)
|
|||
exit (STATE_UNKNOWN);
|
||||
}
|
||||
if (strlen (optarg) >= ADDRESS_LENGTH)
|
||||
terminate (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
die (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
strcpy (dns_server, optarg);
|
||||
break;
|
||||
case 'r': /* reverse server name */
|
||||
|
|
@ -380,12 +380,12 @@ process_arguments (int argc, char **argv)
|
|||
exit (STATE_UNKNOWN);
|
||||
}
|
||||
if (strlen (optarg) >= ADDRESS_LENGTH)
|
||||
terminate (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
die (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
strcpy (ptr_server, optarg);
|
||||
break;
|
||||
case 'a': /* expected address */
|
||||
if (strlen (optarg) >= ADDRESS_LENGTH)
|
||||
terminate (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
die (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
strcpy (expected_address, optarg);
|
||||
match_expected_address = TRUE;
|
||||
break;
|
||||
|
|
@ -395,7 +395,7 @@ process_arguments (int argc, char **argv)
|
|||
c = optind;
|
||||
if (strlen(query_address)==0 && c<argc) {
|
||||
if (strlen(argv[c])>=ADDRESS_LENGTH)
|
||||
terminate (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
die (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
strcpy (query_address, argv[c++]);
|
||||
}
|
||||
|
||||
|
|
@ -406,7 +406,7 @@ process_arguments (int argc, char **argv)
|
|||
return ERROR;
|
||||
}
|
||||
if (strlen(argv[c]) >= ADDRESS_LENGTH)
|
||||
terminate (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
die (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
strcpy (dns_server, argv[c++]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,16 +173,16 @@ textscan (char *buf)
|
|||
int status = STATE_UNKNOWN;
|
||||
|
||||
if (strstr (buf, "not found")) {
|
||||
terminate (STATE_CRITICAL, _("FPING unknown - %s not found\n"), server_name);
|
||||
die (STATE_CRITICAL, _("FPING unknown - %s not found\n"), server_name);
|
||||
|
||||
}
|
||||
else if (strstr (buf, "is unreachable") || strstr (buf, "Unreachable")) {
|
||||
terminate (STATE_CRITICAL, _("FPING critical - %s is unreachable\n"),
|
||||
die (STATE_CRITICAL, _("FPING critical - %s is unreachable\n"),
|
||||
"host");
|
||||
|
||||
}
|
||||
else if (strstr (buf, "is down")) {
|
||||
terminate (STATE_CRITICAL, _("FPING critical - %s is down\n"), server_name);
|
||||
die (STATE_CRITICAL, _("FPING critical - %s is down\n"), server_name);
|
||||
|
||||
}
|
||||
else if (strstr (buf, "is alive")) {
|
||||
|
|
@ -208,7 +208,7 @@ textscan (char *buf)
|
|||
status = STATE_WARNING;
|
||||
else
|
||||
status = STATE_OK;
|
||||
terminate (status, _("FPING %s - %s (loss=%f%%, rta=%f ms)\n"),
|
||||
die (status, _("FPING %s - %s (loss=%f%%, rta=%f ms)\n"),
|
||||
state_text (status), server_name, loss, rta);
|
||||
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ textscan (char *buf)
|
|||
else
|
||||
status = STATE_OK;
|
||||
|
||||
terminate (status, _("FPING %s - %s (loss=%f%% )\n"),
|
||||
die (status, _("FPING %s - %s (loss=%f%% )\n"),
|
||||
state_text (status), server_name, loss );
|
||||
|
||||
}
|
||||
|
|
@ -363,11 +363,11 @@ get_threshold (char *arg, char *rv[2])
|
|||
if (arg2) {
|
||||
arg1[strcspn (arg1, ",:")] = 0;
|
||||
if (strstr (arg1, "%") && strstr (arg2, "%"))
|
||||
terminate (STATE_UNKNOWN,
|
||||
die (STATE_UNKNOWN,
|
||||
_("%s: Only one threshold may be packet loss (%s)\n"), progname,
|
||||
arg);
|
||||
if (!strstr (arg1, "%") && !strstr (arg2, "%"))
|
||||
terminate (STATE_UNKNOWN,
|
||||
die (STATE_UNKNOWN,
|
||||
_("%s: Only one threshold must be packet loss (%s)\n"),
|
||||
progname, arg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'H': /* hostname */
|
||||
if (strlen (optarg) >= MAX_HOST_ADDRESS_LENGTH)
|
||||
terminate (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
die (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
server_ip = strdup (optarg);
|
||||
break;
|
||||
case 'P': /* port */
|
||||
|
|
@ -260,7 +260,7 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'G': /* hostname */
|
||||
if (strlen (optarg) >= MAX_INPUT_BUFFER)
|
||||
terminate (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
die (STATE_UNKNOWN, _("Input buffer overflow\n"));
|
||||
game_type = strdup (optarg);
|
||||
break;
|
||||
case 'p': /* index of ping field */
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ main (int argc, char **argv)
|
|||
#ifdef HAVE_SSL
|
||||
if (use_ssl && check_cert == TRUE) {
|
||||
if (connect_SSL () != OK)
|
||||
terminate (STATE_CRITICAL,
|
||||
die (STATE_CRITICAL,
|
||||
_("HTTP CRITICAL - Could not make SSL connection\n"));
|
||||
if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) {
|
||||
result = check_certificate (&server_cert);
|
||||
|
|
@ -596,7 +596,7 @@ check_http (void)
|
|||
if (use_ssl == TRUE) {
|
||||
|
||||
if (connect_SSL () != OK) {
|
||||
terminate (STATE_CRITICAL, _("Unable to open TCP socket"));
|
||||
die (STATE_CRITICAL, _("Unable to open TCP socket"));
|
||||
}
|
||||
|
||||
if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) {
|
||||
|
|
@ -611,7 +611,7 @@ check_http (void)
|
|||
else {
|
||||
#endif
|
||||
if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK)
|
||||
terminate (STATE_CRITICAL, _("Unable to open TCP socket"));
|
||||
die (STATE_CRITICAL, _("Unable to open TCP socket"));
|
||||
#ifdef HAVE_SSL
|
||||
}
|
||||
#endif
|
||||
|
|
@ -669,14 +669,14 @@ check_http (void)
|
|||
if (use_ssl) {
|
||||
sslerr=SSL_get_error(ssl, i);
|
||||
if ( sslerr == SSL_ERROR_SSL ) {
|
||||
terminate (STATE_WARNING, _("Client Certificate Required\n"));
|
||||
die (STATE_WARNING, _("Client Certificate Required\n"));
|
||||
} else {
|
||||
terminate (STATE_CRITICAL, _("Error in recv()"));
|
||||
die (STATE_CRITICAL, _("Error in recv()"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
terminate (STATE_CRITICAL, _("Error in recv()"));
|
||||
die (STATE_CRITICAL, _("Error in recv()"));
|
||||
#ifdef HAVE_SSL
|
||||
}
|
||||
#endif
|
||||
|
|
@ -684,7 +684,7 @@ check_http (void)
|
|||
|
||||
/* return a CRITICAL status if we couldn't read any data */
|
||||
if (pagesize == (size_t) 0)
|
||||
terminate (STATE_CRITICAL, _("No data received %s"), timestamp);
|
||||
die (STATE_CRITICAL, _("No data received %s"), timestamp);
|
||||
|
||||
/* close the connection */
|
||||
my_close ();
|
||||
|
|
@ -708,7 +708,7 @@ check_http (void)
|
|||
if (verbose)
|
||||
printf ("STATUS: %s\n", status_line);
|
||||
|
||||
/* find header info and null terminate it */
|
||||
/* find header info and null-terminate it */
|
||||
header = page;
|
||||
while (strcspn (page, "\r\n") > 0) {
|
||||
page += (size_t) strcspn (page, "\r\n");
|
||||
|
|
@ -732,7 +732,7 @@ check_http (void)
|
|||
asprintf (&msg,
|
||||
_("Invalid HTTP response received from host on port %d\n"),
|
||||
server_port);
|
||||
terminate (STATE_CRITICAL, msg);
|
||||
die (STATE_CRITICAL, msg);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -753,7 +753,7 @@ check_http (void)
|
|||
strstr (status_line, "501") ||
|
||||
strstr (status_line, "502") ||
|
||||
strstr (status_line, "503")) {
|
||||
terminate (STATE_CRITICAL, _("HTTP CRITICAL: %s\n"), status_line);
|
||||
die (STATE_CRITICAL, _("HTTP CRITICAL: %s\n"), status_line);
|
||||
}
|
||||
|
||||
/* client errors result in a warning state */
|
||||
|
|
@ -762,7 +762,7 @@ check_http (void)
|
|||
strstr (status_line, "402") ||
|
||||
strstr (status_line, "403") ||
|
||||
strstr (status_line, "404")) {
|
||||
terminate (STATE_WARNING, _("HTTP WARNING: %s\n"), status_line);
|
||||
die (STATE_WARNING, _("HTTP WARNING: %s\n"), status_line);
|
||||
}
|
||||
|
||||
/* check redirected page if specified */
|
||||
|
|
@ -778,12 +778,12 @@ check_http (void)
|
|||
while (pos) {
|
||||
server_address = realloc (server_address, MAX_IPV4_HOSTLENGTH + 1);
|
||||
if (server_address == NULL)
|
||||
terminate (STATE_UNKNOWN,
|
||||
die (STATE_UNKNOWN,
|
||||
_("HTTP UNKNOWN: could not allocate server_address"));
|
||||
if (strcspn (pos, "\r\n") > (size_t)server_url_length) {
|
||||
server_url = realloc (server_url, strcspn (pos, "\r\n"));
|
||||
if (server_url == NULL)
|
||||
terminate (STATE_UNKNOWN,
|
||||
die (STATE_UNKNOWN,
|
||||
_("HTTP UNKNOWN: could not allocate server_url"));
|
||||
server_url_length = strcspn (pos, "\r\n");
|
||||
}
|
||||
|
|
@ -840,7 +840,7 @@ check_http (void)
|
|||
asprintf (&msg, _(" - %s - %.3f second response time %s%s|time=%.3f\n"),
|
||||
status_line, elapsed_time, timestamp,
|
||||
(display_html ? "</A>" : ""), elapsed_time);
|
||||
terminate (onredirect, msg);
|
||||
die (onredirect, msg);
|
||||
} /* end if (strstr (status_line, "30[0-4]") */
|
||||
|
||||
|
||||
|
|
@ -853,9 +853,9 @@ check_http (void)
|
|||
status_line, elapsed_time, timestamp,
|
||||
(display_html ? "</A>" : ""), elapsed_time);
|
||||
if (check_critical_time == TRUE && elapsed_time > critical_time)
|
||||
terminate (STATE_CRITICAL, msg);
|
||||
die (STATE_CRITICAL, msg);
|
||||
if (check_warning_time == TRUE && elapsed_time > warning_time)
|
||||
terminate (STATE_WARNING, msg);
|
||||
die (STATE_WARNING, msg);
|
||||
|
||||
/* Page and Header content checks go here */
|
||||
/* these checks should be last */
|
||||
|
|
@ -908,7 +908,7 @@ check_http (void)
|
|||
asprintf (&msg, _("HTTP OK %s - %.3f second response time %s%s|time=%.3f\n"),
|
||||
status_line, (float)elapsed_time,
|
||||
timestamp, (display_html ? "</A>" : ""), elapsed_time);
|
||||
terminate (STATE_OK, msg);
|
||||
die (STATE_OK, msg);
|
||||
return STATE_UNKNOWN;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ process_arguments (int argc, char **argv)
|
|||
if (is_intpos (argv[c]))
|
||||
expire_minutes = atoi (argv[c++]);
|
||||
else
|
||||
terminate (STATE_UNKNOWN,
|
||||
die (STATE_UNKNOWN,
|
||||
_("%s is not a valid expiration time\nUse '%s -h' for additional help\n"),
|
||||
argv[c], progname);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ main (int argc, char **argv)
|
|||
time (¤t_time);
|
||||
if (expire_minutes > 0
|
||||
&& (current_time - timestamp) >
|
||||
(expire_minutes * 60)) terminate (STATE_WARNING,
|
||||
(expire_minutes * 60)) die (STATE_WARNING,
|
||||
_("MRTG data has expired (%d minutes old)\n"),
|
||||
(int) ((current_time - timestamp) /
|
||||
60));
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ process_arguments (int argc, char **argv)
|
|||
if (is_intnonneg (argv[2]))
|
||||
expire_minutes = atoi (argv[2]);
|
||||
else
|
||||
terminate (STATE_UNKNOWN,
|
||||
die (STATE_UNKNOWN,
|
||||
_("Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n"),
|
||||
progname);
|
||||
process_string = argv[3];
|
||||
|
|
@ -251,7 +251,7 @@ process_arguments (int argc, char **argv)
|
|||
if (is_intnonneg (optarg))
|
||||
expire_minutes = atoi (optarg);
|
||||
else
|
||||
terminate (STATE_UNKNOWN,
|
||||
die (STATE_UNKNOWN,
|
||||
_("Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n"),
|
||||
progname);
|
||||
break;
|
||||
|
|
@ -263,11 +263,11 @@ process_arguments (int argc, char **argv)
|
|||
|
||||
|
||||
if (status_log == NULL)
|
||||
terminate (STATE_UNKNOWN,
|
||||
die (STATE_UNKNOWN,
|
||||
_("You must provide the status_log\nType '%s -h' for additional help\n"),
|
||||
progname);
|
||||
else if (process_string == NULL)
|
||||
terminate (STATE_UNKNOWN,
|
||||
die (STATE_UNKNOWN,
|
||||
_("You must provide a process string\nType '%s -h' for additional help\n"),
|
||||
progname);
|
||||
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ int process_arguments(int argc, char **argv){
|
|||
if (is_intnonneg(optarg))
|
||||
server_port=atoi(optarg);
|
||||
else
|
||||
terminate(STATE_UNKNOWN,"Server port an integer (seconds)\nType '%s -h' for additional help\n",progname);
|
||||
die(STATE_UNKNOWN,"Server port an integer (seconds)\nType '%s -h' for additional help\n",progname);
|
||||
break;
|
||||
case 'v':
|
||||
if(strlen(optarg)<4)
|
||||
|
|
|
|||
|
|
@ -763,7 +763,7 @@ int process_arguments(int argc, char **argv) {
|
|||
if (is_intnonneg(optarg))
|
||||
server_port=atoi(optarg);
|
||||
else
|
||||
terminate(STATE_UNKNOWN,_("Server port an integer (seconds)\nType '%s -h' for additional help\n"),progname);
|
||||
die(STATE_UNKNOWN,_("Server port an integer (seconds)\nType '%s -h' for additional help\n"),progname);
|
||||
break;
|
||||
case 'v':
|
||||
if (strlen(optarg)<3)
|
||||
|
|
|
|||
|
|
@ -101,21 +101,21 @@ main (int argc, char **argv)
|
|||
case LOAD15:
|
||||
|
||||
if (result != STATE_OK)
|
||||
terminate (result, _("Unknown error fetching load data\n"));
|
||||
die (result, _("Unknown error fetching load data\n"));
|
||||
|
||||
temp_ptr = (char *) strtok (recv_buffer, "\r\n");
|
||||
if (temp_ptr == NULL)
|
||||
terminate (STATE_CRITICAL, _("Invalid response from server - no load information\n"));
|
||||
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)
|
||||
terminate (STATE_CRITICAL, _("Invalid response from server after load 1\n"));
|
||||
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)
|
||||
terminate (STATE_CRITICAL, _("Invalid response from server after load 5\n"));
|
||||
die (STATE_CRITICAL, _("Invalid response from server after load 5\n"));
|
||||
load_15min = strtod (temp_ptr, NULL);
|
||||
|
||||
switch (vars_to_check) {
|
||||
|
|
@ -138,7 +138,7 @@ main (int argc, char **argv)
|
|||
else if (check_warning_value == TRUE && (load >= warning_value))
|
||||
result = STATE_WARNING;
|
||||
|
||||
terminate (result,
|
||||
die (result,
|
||||
_("Load %s - %s-min load average = %0.2f"),
|
||||
state_text(result),
|
||||
temp_buffer,
|
||||
|
|
@ -149,7 +149,7 @@ main (int argc, char **argv)
|
|||
case DPU:
|
||||
|
||||
if (result != STATE_OK)
|
||||
terminate (result, _("Unknown error fetching disk data\n"));
|
||||
die (result, _("Unknown error fetching disk data\n"));
|
||||
|
||||
for (temp_ptr = (char *) strtok (recv_buffer, " ");
|
||||
temp_ptr != NULL;
|
||||
|
|
@ -159,7 +159,7 @@ main (int argc, char **argv)
|
|||
found_disk = TRUE;
|
||||
temp_ptr = (char *) strtok (NULL, "%");
|
||||
if (temp_ptr == NULL)
|
||||
terminate (STATE_CRITICAL, _("Invalid response from server\n"));
|
||||
die (STATE_CRITICAL, _("Invalid response from server\n"));
|
||||
percent_used_disk_space = strtoul (temp_ptr, NULL, 10);
|
||||
break;
|
||||
}
|
||||
|
|
@ -169,7 +169,7 @@ main (int argc, char **argv)
|
|||
|
||||
/* error if we couldn't find the info for the disk */
|
||||
if (found_disk == FALSE)
|
||||
terminate (STATE_CRITICAL,
|
||||
die (STATE_CRITICAL,
|
||||
"Error: Disk '%s' non-existent or not mounted",
|
||||
disk_name);
|
||||
|
||||
|
|
@ -178,14 +178,14 @@ main (int argc, char **argv)
|
|||
else if (check_warning_value == TRUE && (percent_used_disk_space >= warning_value))
|
||||
result = STATE_WARNING;
|
||||
|
||||
terminate (result, "Disk %s - %lu%% used on %s", state_text(result), percent_used_disk_space, disk_name);
|
||||
die (result, "Disk %s - %lu%% used on %s", state_text(result), percent_used_disk_space, disk_name);
|
||||
|
||||
break;
|
||||
|
||||
case NETSTAT:
|
||||
|
||||
if (result != STATE_OK)
|
||||
terminate (result, _("Unknown error fetching network status\n"));
|
||||
die (result, _("Unknown error fetching network status\n"));
|
||||
|
||||
port_connections = strtod (recv_buffer, NULL);
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ main (int argc, char **argv)
|
|||
else if (check_warning_value == TRUE && (port_connections >= warning_value))
|
||||
result = STATE_WARNING;
|
||||
|
||||
terminate (result,
|
||||
die (result,
|
||||
_("Net %s - %d connection%s on port %d"),
|
||||
state_text(result),
|
||||
port_connections,
|
||||
|
|
@ -206,15 +206,15 @@ main (int argc, char **argv)
|
|||
case PROCS:
|
||||
|
||||
if (result != STATE_OK)
|
||||
terminate (result, _("Unknown error fetching process status\n"));
|
||||
die (result, _("Unknown error fetching process status\n"));
|
||||
|
||||
temp_ptr = (char *) strtok (recv_buffer, "(");
|
||||
if (temp_ptr == NULL)
|
||||
terminate (STATE_CRITICAL, _("Invalid response from server\n"));
|
||||
die (STATE_CRITICAL, _("Invalid response from server\n"));
|
||||
|
||||
temp_ptr = (char *) strtok (NULL, ")");
|
||||
if (temp_ptr == NULL)
|
||||
terminate (STATE_CRITICAL, _("Invalid response from server\n"));
|
||||
die (STATE_CRITICAL, _("Invalid response from server\n"));
|
||||
|
||||
processes = strtod (temp_ptr, NULL);
|
||||
|
||||
|
|
@ -223,7 +223,7 @@ main (int argc, char **argv)
|
|||
else if (check_warning_value == TRUE && (processes >= warning_value))
|
||||
result = STATE_WARNING;
|
||||
|
||||
terminate (result,
|
||||
die (result,
|
||||
_("Process %s - %d instance%s of %s running"),
|
||||
state_text(result),
|
||||
processes,
|
||||
|
|
@ -250,7 +250,7 @@ main (int argc, char **argv)
|
|||
uptime_raw_minutes %= 60;
|
||||
uptime_minutes = uptime_raw_minutes;
|
||||
|
||||
terminate (result,
|
||||
die (result,
|
||||
_("Uptime %s - Up %d days %d hours %d minutes"),
|
||||
state_text(result),
|
||||
uptime_days,
|
||||
|
|
@ -259,7 +259,7 @@ main (int argc, char **argv)
|
|||
break;
|
||||
|
||||
default:
|
||||
terminate (STATE_UNKNOWN, _("Nothing to check!\n"));
|
||||
die (STATE_UNKNOWN, _("Nothing to check!\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -340,7 +340,7 @@ process_arguments (int argc, char **argv)
|
|||
if (is_intnonneg (optarg))
|
||||
server_port = atoi (optarg);
|
||||
else
|
||||
terminate (STATE_UNKNOWN,
|
||||
die (STATE_UNKNOWN,
|
||||
_("Server port an integer (seconds)\nType '%s -h' for additional help\n"),
|
||||
progname);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -165,14 +165,14 @@ main (int argc, char **argv)
|
|||
|
||||
if ((config_file && rc_read_config (config_file)) ||
|
||||
rc_read_dictionary (rc_conf_str ("dictionary")))
|
||||
terminate (STATE_UNKNOWN, _("Config file error"));
|
||||
die (STATE_UNKNOWN, _("Config file error"));
|
||||
|
||||
service = PW_AUTHENTICATE_ONLY;
|
||||
|
||||
if (!(rc_avpair_add (&data.send_pairs, PW_SERVICE_TYPE, &service, 0) &&
|
||||
rc_avpair_add (&data.send_pairs, PW_USER_NAME, username, 0) &&
|
||||
rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0)))
|
||||
terminate (STATE_UNKNOWN, _("Out of Memory?"));
|
||||
die (STATE_UNKNOWN, _("Out of Memory?"));
|
||||
|
||||
/*
|
||||
* Fill in NAS-IP-Address
|
||||
|
|
@ -193,15 +193,15 @@ main (int argc, char **argv)
|
|||
rc_avpair_free (data.receive_pairs);
|
||||
|
||||
if (result == TIMEOUT_RC)
|
||||
terminate (STATE_CRITICAL, _("Timeout"));
|
||||
die (STATE_CRITICAL, _("Timeout"));
|
||||
if (result == ERROR_RC)
|
||||
terminate (STATE_CRITICAL, _("Auth Error"));
|
||||
die (STATE_CRITICAL, _("Auth Error"));
|
||||
if (result == BADRESP_RC)
|
||||
terminate (STATE_WARNING, _("Auth Failed"));
|
||||
die (STATE_WARNING, _("Auth Failed"));
|
||||
if (expect && !strstr (msg, expect))
|
||||
terminate (STATE_WARNING, msg);
|
||||
die (STATE_WARNING, msg);
|
||||
if (result == OK_RC)
|
||||
terminate (STATE_OK, _("Auth OK"));
|
||||
die (STATE_OK, _("Auth OK"));
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ main (int argc, char **argv)
|
|||
|
||||
/* try to connect to the host at the given port number */
|
||||
if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK)
|
||||
terminate (STATE_CRITICAL, "Unable to connect to %s on port %d\n",
|
||||
die (STATE_CRITICAL, "Unable to connect to %s on port %d\n",
|
||||
server_address, server_port);
|
||||
|
||||
/* Part I - Server Check */
|
||||
|
|
@ -113,7 +113,7 @@ main (int argc, char **argv)
|
|||
|
||||
/* return a CRITICAL status if we couldn't read any data */
|
||||
if (result == -1)
|
||||
terminate (STATE_CRITICAL, "No data received from %s\n", host_name);
|
||||
die (STATE_CRITICAL, "No data received from %s\n", host_name);
|
||||
|
||||
/* make sure we find the response we are looking for */
|
||||
if (!strstr (buffer, server_expect)) {
|
||||
|
|
|
|||
|
|
@ -361,7 +361,7 @@ main (int argc, char **argv)
|
|||
eval_method[i] & WARN_NE) {
|
||||
p2 = strpbrk (p2, "0123456789");
|
||||
if (p2 == NULL)
|
||||
terminate (STATE_UNKNOWN,"No valid data returned");
|
||||
die (STATE_UNKNOWN,"No valid data returned");
|
||||
response_value[i] = strtoul (p2, NULL, 10);
|
||||
iresult = check_num (i);
|
||||
asprintf (&show, "%lu", response_value[i]);
|
||||
|
|
@ -427,7 +427,7 @@ main (int argc, char **argv)
|
|||
} /* end while (ptr) */
|
||||
|
||||
if (found == 0)
|
||||
terminate
|
||||
die
|
||||
(STATE_UNKNOWN,
|
||||
_("%s problem - No data recieved from host\nCMD: %s\n"),
|
||||
label, command_line);
|
||||
|
|
@ -643,7 +643,7 @@ process_arguments (int argc, char **argv)
|
|||
labels_size += 8;
|
||||
labels = realloc (labels, labels_size);
|
||||
if (labels == NULL)
|
||||
terminate (STATE_UNKNOWN,
|
||||
die (STATE_UNKNOWN,
|
||||
_("Could not realloc() labels[%d]"), nlabels);
|
||||
}
|
||||
labels[nlabels - 1] = optarg;
|
||||
|
|
@ -657,7 +657,7 @@ process_arguments (int argc, char **argv)
|
|||
labels_size += 8;
|
||||
labels = realloc (labels, labels_size);
|
||||
if (labels == NULL)
|
||||
terminate (STATE_UNKNOWN, _("Could not realloc() labels\n"));
|
||||
die (STATE_UNKNOWN, _("Could not realloc() labels\n"));
|
||||
}
|
||||
labels++;
|
||||
ptr = thisarg (ptr);
|
||||
|
|
@ -674,7 +674,7 @@ process_arguments (int argc, char **argv)
|
|||
unitv_size += 8;
|
||||
unitv = realloc (unitv, unitv_size);
|
||||
if (unitv == NULL)
|
||||
terminate (STATE_UNKNOWN,
|
||||
die (STATE_UNKNOWN,
|
||||
_("Could not realloc() units [%d]\n"), nunits);
|
||||
}
|
||||
unitv[nunits - 1] = optarg;
|
||||
|
|
@ -688,7 +688,7 @@ process_arguments (int argc, char **argv)
|
|||
unitv_size += 8;
|
||||
unitv = realloc (unitv, unitv_size);
|
||||
if (units == NULL)
|
||||
terminate (STATE_UNKNOWN, _("Could not realloc() units\n"));
|
||||
die (STATE_UNKNOWN, _("Could not realloc() units\n"));
|
||||
}
|
||||
nunits++;
|
||||
ptr = thisarg (ptr);
|
||||
|
|
@ -905,7 +905,7 @@ thisarg (char *str)
|
|||
str += strspn (str, " \t\r\n"); /* trim any leading whitespace */
|
||||
if (strstr (str, "'") == str) { /* handle SIMPLE quoted strings */
|
||||
if (strlen (str) == 1 || !strstr (str + 1, "'"))
|
||||
terminate (STATE_UNKNOWN, "Unbalanced quotes\n");
|
||||
die (STATE_UNKNOWN, "Unbalanced quotes\n");
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ main (int argc, char **argv)
|
|||
result = max_state (result, STATE_WARNING);
|
||||
#endif
|
||||
|
||||
terminate (result, "SWAP %s:%s\n", state_text (result), status);
|
||||
die (result, "SWAP %s:%s\n", state_text (result), status);
|
||||
return STATE_UNKNOWN;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ main (int argc, char **argv)
|
|||
|
||||
/* return a CRITICAL status if we couldn't read any data */
|
||||
if (status == NULL)
|
||||
terminate (STATE_CRITICAL, _("No data received from host\n"));
|
||||
die (STATE_CRITICAL, _("No data received from host\n"));
|
||||
|
||||
strip (status);
|
||||
|
||||
|
|
@ -335,7 +335,7 @@ main (int argc, char **argv)
|
|||
if (verbose)
|
||||
printf ("%d %d\n", i, server_expect_count);
|
||||
if (i >= server_expect_count)
|
||||
terminate (STATE_WARNING, _("Invalid response from host\n"));
|
||||
die (STATE_WARNING, _("Invalid response from host\n"));
|
||||
if (strstr (status, server_expect[i]))
|
||||
break;
|
||||
}
|
||||
|
|
@ -542,7 +542,7 @@ process_arguments (int argc, char **argv)
|
|||
break;
|
||||
case 'S':
|
||||
#ifndef HAVE_SSL
|
||||
terminate (STATE_UNKNOWN,
|
||||
die (STATE_UNKNOWN,
|
||||
_("SSL support not available. Install OpenSSL and recompile."));
|
||||
#endif
|
||||
use_ssl = TRUE;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ main (int argc, char **argv)
|
|||
result = STATE_WARNING;
|
||||
else
|
||||
result = STATE_UNKNOWN;
|
||||
terminate (result,
|
||||
die (result,
|
||||
_("TIME UNKNOWN - could not connect to server %s, port %d\n"),
|
||||
server_address, server_port);
|
||||
}
|
||||
|
|
@ -142,7 +142,7 @@ main (int argc, char **argv)
|
|||
result = STATE_WARNING;
|
||||
else
|
||||
result = STATE_UNKNOWN;
|
||||
terminate (result,
|
||||
die (result,
|
||||
_("TIME UNKNOWN - no data on recv() from server %s, port %d\n"),
|
||||
server_address, server_port);
|
||||
}
|
||||
|
|
@ -155,7 +155,7 @@ main (int argc, char **argv)
|
|||
&& (end_time - start_time) > warning_time) result = STATE_WARNING;
|
||||
|
||||
if (result != STATE_OK)
|
||||
terminate (result, _("TIME %s - %d second response time\n"),
|
||||
die (result, _("TIME %s - %d second response time\n"),
|
||||
state_text (result), (int) (end_time - start_time));
|
||||
|
||||
server_time = ntohl (raw_server_time) - UNIX_EPOCH;
|
||||
|
|
|
|||
|
|
@ -138,13 +138,13 @@ main (int argc, char **argv)
|
|||
|
||||
/* Set signal handling and alarm */
|
||||
if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR)
|
||||
terminate (STATE_UNKNOWN, _("Cannot catch SIGALRM"));
|
||||
die (STATE_UNKNOWN, _("Cannot catch SIGALRM"));
|
||||
|
||||
(void) alarm ((unsigned) timeout_interval);
|
||||
|
||||
child_process = spopen (command_line);
|
||||
if (child_process == NULL)
|
||||
terminate (STATE_UNKNOWN, _("Could not open pipe: %s\n"), command_line);
|
||||
die (STATE_UNKNOWN, _("Could not open pipe: %s\n"), command_line);
|
||||
|
||||
child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
|
||||
if (child_stderr == NULL) {
|
||||
|
|
@ -163,7 +163,7 @@ main (int argc, char **argv)
|
|||
}
|
||||
|
||||
if (!found)
|
||||
terminate (STATE_UNKNOWN,\
|
||||
die (STATE_UNKNOWN,\
|
||||
_("%s problem - No data recieved from host\nCMD: %s\n"),\
|
||||
argv[0], command_line);
|
||||
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ process_request (char *server_address, int server_port, int proto,
|
|||
else
|
||||
recv_buffer[recv_result] = 0;
|
||||
|
||||
/* terminate returned string */
|
||||
/* die returned string */
|
||||
recv_buffer[recv_size - 1] = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ static void err_doit (int, const char *, va_list);
|
|||
char *pname = NULL; /* caller can set this from argv[0] */
|
||||
|
||||
/* Fatal error related to a system call.
|
||||
* Print a message and terminate. */
|
||||
* Print a message and die. */
|
||||
|
||||
void
|
||||
err_sys (const char *fmt, ...)
|
||||
|
|
|
|||
|
|
@ -130,17 +130,6 @@ state_text (int result)
|
|||
|
||||
void
|
||||
die (int result, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
printf ("%s %s: ", sizeof (char) + index(progname, '_'), state_text(result));
|
||||
va_start (ap, fmt);
|
||||
vprintf (fmt, ap);
|
||||
va_end (ap);
|
||||
exit (result);
|
||||
}
|
||||
|
||||
void
|
||||
terminate (int result, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
|
|
@ -482,7 +471,7 @@ strpcpy (char *dest, const char *src, const char *str)
|
|||
if (dest == NULL || strlen (dest) < len)
|
||||
dest = realloc (dest, len + 1);
|
||||
if (dest == NULL)
|
||||
terminate (STATE_UNKNOWN, "failed realloc in strpcpy\n");
|
||||
die (STATE_UNKNOWN, "failed realloc in strpcpy\n");
|
||||
|
||||
strncpy (dest, src, len);
|
||||
dest[len] = '\0';
|
||||
|
|
@ -526,7 +515,7 @@ strpcat (char *dest, const char *src, const char *str)
|
|||
|
||||
dest = realloc (dest, len + l2 + 1);
|
||||
if (dest == NULL)
|
||||
terminate (STATE_UNKNOWN, "failed malloc in strscat\n");
|
||||
die (STATE_UNKNOWN, "failed malloc in strscat\n");
|
||||
|
||||
strncpy (dest + len, src, l2);
|
||||
dest[len + l2] = '\0';
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ void support (void);
|
|||
char *clean_revstring (const char *revstring);
|
||||
void print_revision (const char *, const char *);
|
||||
void die (int result, const char *fmt, ...);
|
||||
void terminate (int result, const char *msg, ...);
|
||||
|
||||
/* Handle timeouts */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue