Code

replace "terminate" with "die" for shorter name and better readability
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>
Thu, 7 Aug 2003 11:51:12 +0000 (11:51 +0000)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>
Thu, 7 Aug 2003 11:51:12 +0000 (11:51 +0000)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@656 f882894a-f735-0410-b71e-b25c423dba1c

23 files changed:
plugins/check_by_ssh.c
plugins/check_disk.c
plugins/check_dns.c
plugins/check_fping.c
plugins/check_game.c
plugins/check_http.c
plugins/check_mrtg.c
plugins/check_mrtgtraf.c
plugins/check_nagios.c
plugins/check_nt.c
plugins/check_nwstat.c
plugins/check_overcr.c
plugins/check_radius.c
plugins/check_real.c
plugins/check_snmp.c
plugins/check_swap.c
plugins/check_tcp.c
plugins/check_time.c
plugins/negate.c
plugins/netutils.c
plugins/popen.c
plugins/utils.c
plugins/utils.h

index ae19253fad8853398741e4fd1474bd83da643035..1211daa33d593fd11c3c8153e2085f02679a4e70 100644 (file)
@@ -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;
 }
index c758530e71c33ac5a307ef481d149791186b2903..b0b0d2a5cf0e58491e9494cd113c5e6d4131d9ae 100644 (file)
@@ -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 */
index eae5880e5aec40b9f1d8300b78ed0a1e6b37050f..8b3bb4f6addfd21b4edadba0432bd8d0ff084dfd 100644 (file)
@@ -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++]);
        }
 
index 16e177cec2cdf2efe80dcf72768614927a213a3c..7e4049c8189c8d9e313fdec49598e83cebeaaf06 100644 (file)
@@ -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);
        }
index 811da2706e78572a636e6b71b262c451967b9bb5..2b10991505794c7e88fe0cf94851c481547cb6bb 100644 (file)
@@ -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 */
index 951c76415cec97f48db648ec62a76f1adab1d46e..b5f2a562af4c727af52816993c9be8c76bc2aed4 100644 (file)
@@ -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;
 }
 
index 88c8e49074376312f310a174deea0e0bdb83148b..2a9958d0be77455a8895520c88cbd87c10375980 100644 (file)
@@ -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);
        }
index c99e421394a98bae412433cd2019270584487500..ce9ab19184b24a69f5de3998840802cab9aff09a 100644 (file)
@@ -163,7 +163,7 @@ main (int argc, char **argv)
        time (&current_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));
index 7ae0ff855dcdada5bc6b762046c442bc3b66ceee..a678e2a4e8f2d975e85cf7a70d8465c6aefe13b1 100644 (file)
@@ -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);
 
index 9652fa6b04d322bc70ce3a8d6e1573de80e5ad36..85c67531faabee25d9ea1e9edfb5b35a141410d6 100644 (file)
@@ -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)
index 94f0543b2c89f92632bed5a43f6de42334179f55..de8a620069aca2bbee411ec48449cfbbdbe66437 100644 (file)
@@ -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)
index 4ee47a519fa99bbf02943aa0075484777a43aeac..5f50ca7ec4c848538ddb3ac4e2cd06b1589990fe 100644 (file)
@@ -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;
index 3aa5ae713401df11c9b273bc87bbec061c5d0ac9..714de58c83158c21740a558a7844612cf4017747 100644 (file)
@@ -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);
 }
 
index 1744b329a81ba11d90e6b9a3a39cfd6a18163758..875f9c40c84738d1913ecc01b1e3132c48851085 100644 (file)
@@ -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)) {
index 68ffaf55c4e37a19ff4669eff869d75b13ab55c1..2e2430da62951f5ef8cb650573b7c95f761a8b6c 100644 (file)
@@ -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;
 }
index 65cd899c65915b97d683a8ef173c92a04103f782..b92694d90ef923a87b59047a598d2736561d099f 100644 (file)
@@ -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;
 }
 
index 32bdae70cc55b64d834f7142c25ab0c037a03adc..a897d8e8ec96b446dd579af66297c4c72a14ef7b 100644 (file)
@@ -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;
index b3210bc3e1f85b59319f7d0bcc61a3fb7bffe3ea..dde6eeaf7cca411aea1ba7578f89ba7fba000f46 100644 (file)
@@ -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;
index faf81b34d475b59968cc6d48bd788aec0f1c9325..3ef5ee769e4075220bafd48d9a7350ff365bc68a 100644 (file)
@@ -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);
 
index ea004bb40bafc59409049d2b5af13466d351b50d..4ca3168d9553e7767ef893b9aba0ea8769f42a60 100644 (file)
@@ -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;
        }
 
index e41ae9ae7f4dd975322653b59ee4204b4867c3a5..fb855d7bbb134641c6195005162524ac4983778f 100644 (file)
@@ -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, ...)
index 5f770a1f5a508c339238f45209bc829a36452131..959541bf53f382939e677b29fa450e8feeda1a29 100644 (file)
@@ -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';
index 83793e4650ab5891d57f1abcccb3b30f93fb56eb..f36834f9cdcefa4590849403716396a4aa633773 100644 (file)
@@ -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 */