From e9ccc6b21a1152bbf150302c4a29a6df79d75bd7 Mon Sep 17 00:00:00 2001 From: Benoit Mortier Date: Sat, 25 Dec 2004 23:17:46 +0000 Subject: various fixes for localization git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1061 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/check_dig.c | 8 ++-- plugins/check_disk.c | 6 +-- plugins/check_dns.c | 10 +---- plugins/check_dummy.c | 1 - plugins/check_fping.c | 10 +---- plugins/check_game.c | 15 +++----- plugins/check_hpjd.c | 7 +--- plugins/check_icmp.c | 94 +++++++++++++++++++++++------------------------ plugins/check_ide_smart.c | 6 +-- plugins/check_ldap.c | 20 ++++------ plugins/check_load.c | 4 +- plugins/check_mrtg.c | 4 +- plugins/check_mrtgtraf.c | 6 +-- plugins/check_mysql.c | 16 +++----- plugins/check_nagios.c | 18 +++------ plugins/check_nt.c | 12 +++--- plugins/check_nwstat.c | 6 +-- plugins/check_overcr.c | 17 +-------- plugins/check_pgsql.c | 6 +-- plugins/check_ping.c | 4 +- plugins/check_procs.c | 28 +++++--------- plugins/check_radius.c | 12 +++--- plugins/check_real.c | 10 ++--- plugins/check_smtp.c | 6 +-- plugins/check_snmp.c | 8 ++-- plugins/check_ssh.c | 10 ++--- plugins/check_swap.c | 10 ++--- plugins/check_tcp.c | 30 +++++++-------- plugins/check_time.c | 4 +- plugins/check_udp.c | 10 ++--- plugins/check_ups.c | 59 ++++++++++++++--------------- plugins/check_users.c | 13 +++---- plugins/negate.c | 4 +- plugins/netutils.c | 16 ++++---- plugins/popen.c | 12 +++--- plugins/popen.h | 6 +++ plugins/urlize.c | 4 +- plugins/utils.c | 8 ++-- 38 files changed, 204 insertions(+), 316 deletions(-) (limited to 'plugins') diff --git a/plugins/check_dig.c b/plugins/check_dig.c index a44d5786..c6078965 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c @@ -81,9 +81,9 @@ main (int argc, char **argv) if (verbose) { printf ("%s\n", command_line); if(expected_address != NULL) { - printf ("Looking for: '%s'\n", expected_address); + printf (_("Looking for: '%s'\n"), expected_address); } else { - printf ("Looking for: '%s'\n", query_address); + printf (_("Looking for: '%s'\n"), query_address); } } @@ -214,9 +214,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* help */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 669a1cd6..ab9f66f8 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -438,9 +438,7 @@ process_arguments (int argc, char **argv) print_help (); exit (STATE_OK); case '?': /* help */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); } } @@ -488,7 +486,7 @@ print_path (const char *mypath) if (mypath == NULL) printf ("\n"); else - printf (" for %s\n", mypath); + printf (_(" for %s\n"), mypath); return; } diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 20cb6dd8..e6483b9c 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -135,7 +135,7 @@ main (int argc, char **argv) asprintf(&address, "%s,%s", address, temp_buffer); } - else if (strstr (input_buffer, "Non-authoritative answer:")) { + else if (strstr (input_buffer, _("Non-authoritative answer:"))) { non_authoritative = TRUE; } @@ -277,7 +277,6 @@ error_scan (char *input_buffer) } - /* process command-line arguments */ int process_arguments (int argc, char **argv) @@ -313,9 +312,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* args not parsable */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); @@ -386,7 +383,6 @@ process_arguments (int argc, char **argv) } - int validate_arguments () { @@ -397,7 +393,6 @@ validate_arguments () } - void print_help (void) { @@ -432,7 +427,6 @@ specified in /etc/resolv.conf will be used.\n\n")); } - void print_usage (void) { diff --git a/plugins/check_dummy.c b/plugins/check_dummy.c index 2dbbaec8..08926115 100644 --- a/plugins/check_dummy.c +++ b/plugins/check_dummy.c @@ -30,7 +30,6 @@ void print_help (void); void print_usage (void); - int main (int argc, char **argv) { diff --git a/plugins/check_fping.c b/plugins/check_fping.c index 7f05d4d5..5ffcd16e 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c @@ -242,9 +242,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* print short usage statement if args not parsable */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); @@ -301,15 +299,13 @@ process_arguments (int argc, char **argv) } } - if (server_name == NULL) - usage (_("Hostname was not supplied\n\n")); + usage4 (_("Hostname was not supplied")); return OK; } - int get_threshold (char *arg, char *rv[2]) { @@ -351,7 +347,6 @@ get_threshold (char *arg, char *rv[2]) } - void print_help (void) { @@ -395,7 +390,6 @@ percentage of packet loss to trigger an alarm state.\n")); } - void print_usage (void) { diff --git a/plugins/check_game.c b/plugins/check_game.c index 6699c71d..05b363af 100644 --- a/plugins/check_game.c +++ b/plugins/check_game.c @@ -123,15 +123,15 @@ main (int argc, char **argv) } if (strstr (ret[2], QSTAT_HOST_ERROR)) { - printf ("CRITICAL - Host not found\n"); + printf (_("CRITICAL - Host not found\n")); result = STATE_CRITICAL; } else if (strstr (ret[2], QSTAT_HOST_DOWN)) { - printf ("CRITICAL - Game server down or unavailable\n"); + printf (_("CRITICAL - Game server down or unavailable\n")); result = STATE_CRITICAL; } else if (strstr (ret[2], QSTAT_HOST_TIMEOUT)) { - printf ("CRITICAL - Game server timeout\n"); + printf (_("CRITICAL - Game server timeout\n")); result = STATE_CRITICAL; } else { @@ -156,7 +156,6 @@ main (int argc, char **argv) } - int process_arguments (int argc, char **argv) { @@ -199,9 +198,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* args not parsable */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); @@ -269,6 +266,7 @@ process_arguments (int argc, char **argv) return validate_arguments (); } + int validate_arguments (void) { @@ -291,9 +289,6 @@ validate_arguments (void) } - - - void print_help (void) { diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c index 53769565..dd49893b 100644 --- a/plugins/check_hpjd.c +++ b/plugins/check_hpjd.c @@ -286,7 +286,6 @@ main (int argc, char **argv) } - /* process command-line arguments */ int process_arguments (int argc, char **argv) @@ -334,9 +333,7 @@ process_arguments (int argc, char **argv) print_help (); exit (STATE_OK); case '?': /* help */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); } } @@ -361,7 +358,6 @@ process_arguments (int argc, char **argv) } - int validate_arguments (void) { @@ -369,7 +365,6 @@ validate_arguments (void) } - void print_help (void) { diff --git a/plugins/check_icmp.c b/plugins/check_icmp.c index cbd68642..45716824 100644 --- a/plugins/check_icmp.c +++ b/plugins/check_icmp.c @@ -310,19 +310,19 @@ int main(int argc, char **argv) /* check if we are root */ if(geteuid()) { - printf("Root access needed (for raw sockets)\n"); + printf(_("Root access needed (for raw sockets)\n")); exit(STATE_UNKNOWN); } /* confirm that ICMP is available on this machine */ if((proto = getprotobyname("icmp")) == NULL) - crash("icmp: unknown protocol"); + crash(_("icmp: unknown protocol")); /* create raw socket for ICMP calls (ping) */ sock = socket(AF_INET, SOCK_RAW, proto->p_proto); if(sock < 0) - crash("can't create raw socket"); + crash(_("Can't create raw socket")); /* drop privileges now that we have the socket */ if((uid = getuid())) { @@ -334,7 +334,7 @@ int main(int argc, char **argv) ident = getpid() & 0xFFFF; if(!(host_base_ptr = malloc(sizeof(struct host_name_list)))) { - crash("Unable to allocate memory for host name list\n"); + crash(_("Unable to allocate memory for host name list\n")); } host_ptr = host_base_ptr; @@ -359,12 +359,12 @@ int main(int argc, char **argv) switch (c) { case 'H': if(!(host_ptr->entry = malloc(strlen(optarg) + 1))) { - crash("Failed to allocate memory for hostname"); + crash(_("Failed to allocate memory for hostname")); } memset(host_ptr->entry, 0, strlen(optarg) + 1); host_ptr->entry = memcpy(host_ptr->entry, optarg, strlen(optarg)); if(!(host_ptr->next = malloc(sizeof(struct host_name_list)))) - crash("Failed to allocate memory for hostname"); + crash(_("Failed to allocate memory for hostname")); host_ptr = host_ptr->next; host_ptr->next = NULL; // add_name(optarg); @@ -375,35 +375,35 @@ int main(int argc, char **argv) break; case 'w': if(get_threshold(optarg, &warn)) { - printf("Illegal threshold pair specified for -%c", c); + printf(_("Illegal threshold pair specified for -%c"), c); print_usage(); } break; case 'c': if(get_threshold(optarg, &crit)) { - printf("Illegal threshold pair specified for -%c", c); + printf(_("Illegal threshold pair specified for -%c"), c); print_usage(); } break; case 't': if(!(timeout = (u_int) strtoul(optarg, NULL, 0) * 100)) { - printf("option -%c requires integer argument\n", c); + printf(_("Option -%c requires integer argument\n"), c); print_usage(); } break; case 'r': if(!(retry = (u_int) strtoul(optarg, NULL, 0))) { - printf("option -%c requires integer argument\n", c); + printf(_("Option -%c requires integer argument\n"), c); print_usage(); } break; case 'i': if(!(interval = (u_int) strtoul(optarg, NULL, 0) * 100)) { - printf("option -%c requires positive non-zero integer argument\n", c); + printf(_("Option -%c requires positive non-zero integer argument\n"), c); print_usage(); } break; @@ -411,14 +411,14 @@ int main(int argc, char **argv) case 'p': case 'n': if(!(count = (u_int) strtoul(optarg, NULL, 0))) { - printf("option -%c requires positive non-zero integer argument\n", c); + printf(_("Option -%c requires positive non-zero integer argument\n"), c); print_usage(); } break; case 'b': if(!(ping_data_size = (u_int) strtoul(optarg, NULL, 0))) { - printf("option -%c requires integer argument\n", c); + printf(_("Option -%c requires integer argument\n"), c); print_usage(); } break; @@ -467,7 +467,7 @@ int main(int argc, char **argv) break; default: - printf("option flag -%c specified, but not recognized\n", c); + printf(_("Option flag -%c specified, but not recognized\n"), c); print_usage(); break; } @@ -494,30 +494,30 @@ int main(int argc, char **argv) else if(timeout < warn.rta) timeout = warn.rta; if((interval < MIN_INTERVAL * 100 || retry > MAX_RETRY) && getuid()) { - printf("%s: these options are too risky for mere mortals.\n", prog); - printf("%s: You need i >= %u and r < %u\n", + printf(_("%s: these options are too risky for mere mortals.\n"), prog); + printf(_("%s: You need i >= %u and r < %u\n"), prog, MIN_INTERVAL, MAX_RETRY); - printf("Current settings; i = %d, r = %d\n", + printf(_("Current settings; i = %d, r = %d\n"), interval / 100, retry); print_usage(); } if((ping_data_size > MAX_PING_DATA) || (ping_data_size < MIN_PING_DATA)) { - printf("%s: data size %u not valid, must be between %u and %u\n", + printf(_("%s: data size %u not valid, must be between %u and %u\n"), prog, ping_data_size, MIN_PING_DATA, MAX_PING_DATA); print_usage(); } if((backoff > MAX_BACKOFF_FACTOR) || (backoff < MIN_BACKOFF_FACTOR)) { - printf("%s: backoff factor %.1f not valid, must be between %.1f and %.1f\n", + printf(_("%s: backoff factor %.1f not valid, must be between %.1f and %.1f\n"), prog, backoff, MIN_BACKOFF_FACTOR, MAX_BACKOFF_FACTOR); print_usage(); } if(count > MAX_COUNT) { - printf("%s: count %u not valid, must be less than %u\n", + printf(_("%s: count %u not valid, must be less than %u\n"), prog, count, MAX_COUNT); print_usage(); } @@ -536,19 +536,19 @@ int main(int argc, char **argv) /* generate requires command line parameters beyond the switches */ if(generate_flag && !*argv) { - printf("generate flag requires command line parameters beyond switches\n"); + printf(_("Generate flag requires command line parameters beyond switches\n")); print_usage(); } if(*argv && !generate_flag) { while(*argv) { if(!(host_ptr->entry = malloc(strlen(*argv) + 1))) { - crash("Failed to allocate memory for hostname"); + crash(_("Failed to allocate memory for hostname")); } memset(host_ptr->entry, 0, strlen(*argv) + 1); host_ptr->entry = memcpy(host_ptr->entry, *argv, strlen(*argv)); if(!(host_ptr->next = malloc(sizeof(struct host_name_list)))) - crash("Failed to allocate memory for hostname"); + crash(_("Failed to allocate memory for hostname")); host_ptr = host_ptr->next; host_ptr->next = NULL; @@ -565,13 +565,13 @@ int main(int argc, char **argv) } if(!num_hosts) { - printf("No hosts to work with!\n\n"); + printf(_("No hosts to work with!\n\n")); print_usage(); } /* allocate array to hold outstanding ping requests */ table = (HOST_ENTRY **) malloc(sizeof(HOST_ENTRY *) * num_hosts); - if(!table) crash("Can't malloc array of hosts"); + if(!table) crash(_("Can't malloc array of hosts")); cursor = rrlist; @@ -703,7 +703,7 @@ void finish() warn.pl, crit.pl); } else { - printf("%s is down (lost 100%%)", h->host); + printf(_("%s is down (lost 100%%)"), h->host); } } else { @@ -754,7 +754,7 @@ void finish() } if(num_noaddress) { - printf("No hostaddress specified.\n"); + printf(_("No hostaddress specified.\n")); print_usage(); } else if(num_alive != num_hosts) { @@ -765,10 +765,10 @@ void finish() if(num_hosts > 1) { if(num_alive == num_hosts) { - printf("OK - All %d hosts are alive\n", num_hosts); + printf(_("OK - All %d hosts are alive\n"), num_hosts); } else { - printf("CRITICAL - %d of %d hosts are alive\n", num_alive, num_hosts); + printf(_("CRITICAL - %d of %d hosts are alive\n"), num_alive, num_hosts); } } exit(fin_stat); @@ -784,7 +784,7 @@ void send_ping(int lsock, HOST_ENTRY *h) buffer = (char *)malloc((size_t) ping_pkt_size); if(!buffer) - crash("can't malloc ping packet"); + crash(_("Can't malloc ping packet")); memset(buffer, 0, ping_pkt_size * sizeof(char)); icp = (struct icmp *)buffer; @@ -808,7 +808,7 @@ void send_ping(int lsock, HOST_ENTRY *h) if(n < 0 || (unsigned int)n != ping_pkt_size) { if(unreachable_flag) { - printf("%s error while sending ping: %s\n", + printf(_("%s error while sending ping: %s\n"), h->host, strerror(errno)); } /* IF */ @@ -860,7 +860,7 @@ int wait_for_reply(int lsock) #endif /* defined(__alpha__) && __STDC__ */ if(result < hlen + ICMP_MINLEN) { - printf("received packet too short for ICMP (%d bytes from %s)\n", result, + printf(_("Received packet too short for ICMP (%d bytes from %s)\n"), result, inet_ntoa(response_addr.sin_addr)); return (1); /* too short */ @@ -903,7 +903,7 @@ int wait_for_reply(int lsock) /* note reply time in array, probably */ if((this_count >= 0) && ((unsigned int)this_count < trials)) { if(h->resp_times[this_count] != RESP_WAITING) { - printf("%s : duplicate for [%d], %d bytes, %s ms", + printf(_("%s : duplicate for [%d], %d bytes, %s ms"), h->host, this_count, result, sprint_tm(this_reply)); if(response_addr.sin_addr.s_addr != h->saddr.sin_addr.s_addr) @@ -913,7 +913,7 @@ int wait_for_reply(int lsock) } /* IF */ else { /* count is out of bounds?? */ - printf("%s : duplicate for [%d], %d bytes, %s ms\n", + printf(_("%s : duplicate for [%d], %d bytes, %s ms\n"), h->host, this_count, result, sprint_tm(this_reply)); } /* ELSE */ @@ -942,12 +942,12 @@ int handle_random_icmp(struct icmp *p, struct sockaddr_in *addr) h = table[sent_icmp->icmp_seq]; if(p->icmp_code > ICMP_UNREACH_MAXTYPE) { - printf("ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s", + printf(_("ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s"), inet_ntoa(addr->sin_addr), h->host); } /* IF */ else { - printf("ICMP Unreachable from %s for ICMP Echo sent to %s", + printf(_("ICMP Unreachable from %s for ICMP Echo sent to %s"), inet_ntoa(addr->sin_addr), h->host); } /* ELSE */ @@ -971,7 +971,7 @@ int handle_random_icmp(struct icmp *p, struct sockaddr_in *addr) (sent_icmp->icmp_seq < (n_short) num_hosts)) { /* this is a response to a ping we sent */ h = table[sent_icmp->icmp_seq]; - printf("ICMP Unreachable from %s for ICMP Echo sent to %s", + printf(_("ICMP Unreachable from %s for ICMP Echo sent to %s"), inet_ntoa(addr->sin_addr), h->host); if(inet_addr(h->host) == INADDR_NONE) @@ -1056,7 +1056,7 @@ void add_name(char *name) } /* IF */ if(host_ent == NULL) { - printf("%s address not found\n", name); + printf(_("%s address not found\n"), name); num_noaddress++; return; } /* IF */ @@ -1064,7 +1064,7 @@ void add_name(char *name) host_add = (struct in_addr *)*(host_ent->h_addr_list); if(host_add == NULL) { - printf("%s has no address data\n", name); + printf(_("%s has no address data\n"), name); num_noaddress++; return; } /* IF */ @@ -1097,7 +1097,7 @@ char *na_cat(char *name, struct in_addr ipaddr) nm = (char *)malloc(strlen(name) + strlen(as) + 4); if(!nm) - crash("can't allocate some space for a string"); + crash(_("Can't allocate some space for a string")); strcpy(nm, name); strcat(nm, " ("); @@ -1116,7 +1116,7 @@ void add_addr(char *name, char *host, struct in_addr ipaddr) int *i; if(!(p = (HOST_ENTRY *) malloc(sizeof(HOST_ENTRY)))) { - crash("can't allocate HOST_ENTRY"); + crash(_("Can't allocate HOST_ENTRY")); } memset((char *)p, 0, sizeof(HOST_ENTRY)); @@ -1129,7 +1129,7 @@ void add_addr(char *name, char *host, struct in_addr ipaddr) /* array for response time results */ if(!(i = (int *)malloc(trials * sizeof(int)))) { - crash("can't allocate resp_times array"); + crash(_("Can't allocate resp_times array")); } for(n = 1; n < trials; n++) @@ -1193,7 +1193,7 @@ char *cpystr(char *string) if(string) { dst = (char *)malloc(1 + strlen(string)); - if(!dst) crash("malloc() failed!"); + if(!dst) crash(_("malloc() failed!")); strcpy(dst, string); return dst; @@ -1210,7 +1210,7 @@ void crash(char *msg) if(errno) printf("%s: %s : %s\n", prog, msg, strerror(errno)); if(h_errno) - printf("%s: %s : A network error occurred\n", prog, msg); + printf(_("%s: %s : A network error occurred\n"), prog, msg); } else printf("%s: %s\n", prog, msg); @@ -1276,7 +1276,7 @@ void u_sleep(int u_sec) FD_ZERO(&readset); nfound = select(0, &readset, &writeset, NULL, &to); if(nfound < 0) - crash("select() in u_sleep:"); + crash(_("select() in u_sleep:")); return; } /* u_sleep() */ @@ -1306,14 +1306,14 @@ int recvfrom_wto(int lsock, char *buf, int len, struct sockaddr *saddr, int timo FD_ZERO(&writeset); FD_SET(lsock, &readset); nfound = select(lsock + 1, &readset, &writeset, NULL, &to); - if(nfound < 0) crash("select() in recvfrom_wto"); + if(nfound < 0) crash(_("select() in recvfrom_wto")); if(nfound == 0) return -1; /* timeout */ if(nfound) { slen = sizeof(struct sockaddr); n = recvfrom(sock, buf, len, 0, saddr, &slen); - if(n < 0) crash("recvfrom"); + if(n < 0) crash(_("recvfrom")); return(n); } diff --git a/plugins/check_ide_smart.c b/plugins/check_ide_smart.c index 644dc488..16cd1a87 100644 --- a/plugins/check_ide_smart.c +++ b/plugins/check_ide_smart.c @@ -206,9 +206,7 @@ main (int argc, char *argv[]) print_revision (progname, revision); return STATE_OK; default: - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); } if (optind < argc) { @@ -488,7 +486,6 @@ smart_read_thresholds (int fd, thresholds_t * thresholds) } - void print_help () { @@ -515,7 +512,6 @@ Usage: %s [DEVICE] [OPTION]\n\ } - void print_usage (void) { diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index 582c9564..4f143280 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c @@ -134,11 +134,11 @@ main (int argc, char *argv[]) if (ldap_set_option (ld, LDAP_OPT_X_TLS, &tls) != LDAP_SUCCESS) { /*ldap_perror(ld, "ldaps_option"); */ - printf ("Could not init TLS at port %i!\n", ld_port); + printf (_("Could not init TLS at port %i!\n"), ld_port); return STATE_CRITICAL; } #else - printf ("TLS not supported by the libraries!\n", ld_port); + printf (_("TLS not supported by the libraries!\n"), ld_port); return STATE_CRITICAL; #endif /* LDAP_OPT_X_TLS */ } else { @@ -157,11 +157,11 @@ main (int argc, char *argv[]) if (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) { /*ldap_perror(ld, "ldap_start_tls"); */ - printf ("Could not init startTLS at port %i!\n", ld_port); + printf (_("Could not init startTLS at port %i!\n"), ld_port); return STATE_CRITICAL; } #else - printf ("startTLS not supported by the library, needs LDAPv3!\n"); + printf (_("startTLS not supported by the library, needs LDAPv3!\n")); return STATE_CRITICAL; #endif /* HAVE_LDAP_START_TLS_S */ } @@ -312,9 +312,7 @@ process_arguments (int argc, char **argv) #endif break; default: - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); } } @@ -328,21 +326,20 @@ process_arguments (int argc, char **argv) return validate_arguments (); } + int validate_arguments () { if (ld_host==NULL || strlen(ld_host)==0) - usage (_("please specify the host name\n")); + usage4 (_("Please specify the host name\n")); if (ld_base==NULL || strlen(ld_base)==0) - usage (_("please specify the LDAP base\n")); + usage4 (_("Please specify the LDAP base\n")); return OK; - } - void print_help (void) { @@ -392,7 +389,6 @@ print_help (void) } - void print_usage (void) { diff --git a/plugins/check_load.c b/plugins/check_load.c index 1b7865c7..7e1cc481 100644 --- a/plugins/check_load.c +++ b/plugins/check_load.c @@ -224,9 +224,7 @@ process_arguments (int argc, char **argv) print_help (); exit (STATE_OK); case '?': /* help */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); } } diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c index bd37aeff..067429cf 100644 --- a/plugins/check_mrtg.c +++ b/plugins/check_mrtg.c @@ -233,9 +233,7 @@ process_arguments (int argc, char **argv) print_help (); exit (STATE_OK); case '?': /* help */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); } } diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c index 096b3bde..877072ce 100644 --- a/plugins/check_mrtgtraf.c +++ b/plugins/check_mrtgtraf.c @@ -260,9 +260,7 @@ process_arguments (int argc, char **argv) print_help (); exit (STATE_OK); case '?': /* help */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); } } @@ -304,7 +302,6 @@ process_arguments (int argc, char **argv) } - int validate_arguments (void) { @@ -312,7 +309,6 @@ validate_arguments (void) } - void print_help (void) { diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 1e7a82f9..735eaa2e 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c @@ -98,25 +98,25 @@ main (int argc, char **argv) /* check the slave status */ if (mysql_query (&mysql, "show slave status") != 0) { mysql_close (&mysql); - die (STATE_CRITICAL, "slave query error: %s\n", mysql_error (&mysql)); + die (STATE_CRITICAL, _("slave query error: %s\n"), mysql_error (&mysql)); } /* store the result */ if ( (res = mysql_store_result (&mysql)) == NULL) { mysql_close (&mysql); - die (STATE_CRITICAL, "slave store_result error: %s\n", mysql_error (&mysql)); + die (STATE_CRITICAL, _("slave store_result error: %s\n"), mysql_error (&mysql)); } /* fetch the first row */ if ( (row = mysql_fetch_row (res)) == NULL) { mysql_free_result (res); mysql_close (&mysql); - die (STATE_CRITICAL, "slave fetch row error: %s\n", mysql_error (&mysql)); + die (STATE_CRITICAL, _("slave fetch row error: %s\n"), mysql_error (&mysql)); } if (mysql_field_count (&mysql) == 12) { /* mysql 3.23.x */ - snprintf (slaveresult, SLAVERESULTSIZE, "Slave running: %s", row[6]); + snprintf (slaveresult, SLAVERESULTSIZE, _("Slave running: %s"), row[6]); if (strcmp (row[6], "Yes") != 0) { mysql_free_result (res); mysql_close (&mysql); @@ -151,7 +151,6 @@ main (int argc, char **argv) } - /* process command-line arguments */ int process_arguments (int argc, char **argv) @@ -212,9 +211,7 @@ process_arguments (int argc, char **argv) print_help (); exit (STATE_OK); case '?': /* help */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); } } @@ -245,7 +242,6 @@ process_arguments (int argc, char **argv) } - int validate_arguments (void) { @@ -265,7 +261,6 @@ validate_arguments (void) } - void print_help (void) { @@ -304,7 +299,6 @@ a server listening on MySQL standard port %d will be checked\n"), MYSQL_PORT); } - void print_usage (void) { diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c index 465b409d..0176983c 100644 --- a/plugins/check_nagios.c +++ b/plugins/check_nagios.c @@ -95,7 +95,7 @@ main (int argc, char **argv) fclose (fp); if (verbose >= 2) - printf("command: %s\n", PS_COMMAND); + printf(_("command: %s\n"), PS_COMMAND); /* run the command to check for the Nagios process.. */ child_process = spopen (PS_COMMAND); @@ -206,8 +206,7 @@ process_arguments (int argc, char **argv) expire_minutes = atoi (argv[2]); else die (STATE_UNKNOWN, - _("Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n"), - progname); + _("Expiration time must be an integer (seconds)\n")); process_string = argv[3]; return OK; } @@ -220,9 +219,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* print short usage statement if args not parsable */ - printf (_("%s: Unknown argument: %c\n\n"), progname, optopt); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); @@ -240,8 +237,7 @@ process_arguments (int argc, char **argv) expire_minutes = atoi (optarg); else die (STATE_UNKNOWN, - _("Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n"), - progname); + _("Expiration time must be an integer (seconds)\n")); break; case 'v': verbose++; @@ -252,12 +248,10 @@ process_arguments (int argc, char **argv) if (status_log == NULL) die (STATE_UNKNOWN, - _("You must provide the status_log\nType '%s -h' for additional help\n"), - progname); + _("You must provide the status_log\n")); else if (process_string == NULL) die (STATE_UNKNOWN, - _("You must provide a process string\nType '%s -h' for additional help\n"), - progname); + _("You must provide a process string\n")); return OK; } diff --git a/plugins/check_nt.c b/plugins/check_nt.c index fa93fce7..cac826f5 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c @@ -423,7 +423,7 @@ int main(int argc, char **argv){ case CHECK_NONE: default: - usage (_("Please specify a variable to check")); + usage4 (_("Please specify a variable to check")); break; } @@ -487,14 +487,12 @@ int process_arguments(int argc, char **argv){ switch (c) { case '?': /* print short usage statement if args not parsable */ - printf("%s: Unknown argument: %s\n\n",progname,optarg); - print_usage(); - exit(STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help(); exit(STATE_OK); case 'V': /* version */ - print_revision(progname,"$Revision$"); + print_revision(progname,revision); exit(STATE_OK); case 'H': /* hostname */ if (server_address) free(server_address); @@ -507,7 +505,7 @@ int process_arguments(int argc, char **argv){ if (is_intnonneg(optarg)) server_port=atoi(optarg); else - die(STATE_UNKNOWN,_("Server port an integer (seconds)\nType '%s -h' for additional help\n"),progname); + die(STATE_UNKNOWN,_("Server port must be an integer\n")); break; case 'v': if(strlen(optarg)<4) @@ -573,7 +571,7 @@ void fetch_data (const char *address, int port, const char *sendb) { result=process_tcp_request(address, port, sendb, recv_buffer,sizeof(recv_buffer)); if(result!=STATE_OK) - die (result, "could not fetch information from server\n"); + die (result, _("could not fetch information from server\n")); if (!strncmp(recv_buffer,"ERROR",5)) die (STATE_UNKNOWN, "NSClient - %s\n",recv_buffer); diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c index 2d7e611d..601b25d3 100644 --- a/plugins/check_nwstat.c +++ b/plugins/check_nwstat.c @@ -760,9 +760,7 @@ int process_arguments(int argc, char **argv) { switch (c) { case '?': /* print short usage statement if args not parsable */ - printf ("%s: Unknown argument: %s\n\n", progname, optarg); - print_usage(); - exit(STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help(); exit(STATE_OK); @@ -779,7 +777,7 @@ int process_arguments(int argc, char **argv) { if (is_intnonneg(optarg)) server_port=atoi(optarg); else - die(STATE_UNKNOWN,_("Server port an integer (seconds)\nType '%s -h' for additional help\n"),progname); + die(STATE_UNKNOWN,_("Server port an integer\n")); break; case 'v': if (strlen(optarg)<3) diff --git a/plugins/check_overcr.c b/plugins/check_overcr.c index 9bf40d3c..a4abf2b9 100644 --- a/plugins/check_overcr.c +++ b/plugins/check_overcr.c @@ -272,17 +272,9 @@ main (int argc, char **argv) die (STATE_UNKNOWN, _("Nothing to check!\n")); break; } - - /* reset timeout */ -/* alarm (0); */ - -/* printf (_("Reached end of program with no data returned\n")); */ - -/* return result; */ } - /* process command-line arguments */ int process_arguments (int argc, char **argv) @@ -332,9 +324,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* print short usage statement if args not parsable */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); @@ -349,8 +339,7 @@ process_arguments (int argc, char **argv) server_port = atoi (optarg); else die (STATE_UNKNOWN, - _("Server port an integer (seconds)\nType '%s -h' for additional help\n"), - progname); + _("Server port an integer\n")); break; case 'v': /* variable */ if (strcmp (optarg, "LOAD") == 0) { @@ -403,7 +392,6 @@ process_arguments (int argc, char **argv) } - void print_help (void) { @@ -459,7 +447,6 @@ Notes:\n\ } - void print_usage (void) { diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c index b5b9ff81..d56ce9b0 100644 --- a/plugins/check_pgsql.c +++ b/plugins/check_pgsql.c @@ -209,9 +209,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* usage */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); @@ -232,7 +230,7 @@ process_arguments (int argc, char **argv) break; case 'w': /* warning time threshold */ if (!is_nonnegative (optarg)) - usage2 (_("Critical threshold must be a positive integer"), optarg); + usage2 (_("Warning threshold must be a positive integer"), optarg); else twarn = strtod (optarg, NULL); break; diff --git a/plugins/check_ping.c b/plugins/check_ping.c index 91764666..818bb668 100644 --- a/plugins/check_ping.c +++ b/plugins/check_ping.c @@ -194,9 +194,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* usage */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); diff --git a/plugins/check_procs.c b/plugins/check_procs.c index 1be93f46..0cd9153c 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c @@ -343,9 +343,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* help */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); @@ -368,7 +366,7 @@ process_arguments (int argc, char **argv) else if (sscanf (optarg, "%d:", &cmin) == 1) break; else - usage (_("Critical Process Count must be an integer!\n\n")); + usage4 (_("Critical Process Count must be an integer!")); break; case 'w': /* warning threshold */ if (is_integer (optarg)) @@ -380,7 +378,7 @@ process_arguments (int argc, char **argv) else if (sscanf (optarg, "%d:", &wmin) == 1) break; else - usage (_("Warning Process Count must be an integer!\n\n")); + usage4 (_("Warning Process Count must be an integer!")); break; case 'p': /* process id */ if (sscanf (optarg, "%d%[^0-9]", &ppid, tmp) == 1) { @@ -388,7 +386,7 @@ process_arguments (int argc, char **argv) options |= PPID; break; } - usage2 (_("%s: Parent Process ID must be an integer!\n\n"), progname); + usage4 (_("Parent Process ID must be an integer!")); case 's': /* status */ if (statopts) break; @@ -403,13 +401,13 @@ process_arguments (int argc, char **argv) pw = getpwuid ((uid_t) uid); /* check to be sure user exists */ if (pw == NULL) - usage2 (_("UID %s was not found\n"), optarg); + usage2 (_("UID %s was not found"), optarg); } else { pw = getpwnam (optarg); /* check to be sure user exists */ if (pw == NULL) - usage2 (_("User name %s was not found\n"), optarg); + usage2 (_("User name %s was not found"), optarg); /* then get uid */ uid = pw->pw_uid; } @@ -443,14 +441,14 @@ process_arguments (int argc, char **argv) options |= RSS; break; } - usage2 (_("%s: RSS must be an integer!\n\n"), progname); + usage4 (_("RSS must be an integer!")); case 'z': /* VSZ */ if (sscanf (optarg, "%d%[^0-9]", &vsz, tmp) == 1) { asprintf (&fmt, _("%s%sVSZ >= %d"), (fmt ? fmt : ""), (options ? ", " : ""), vsz); options |= VSZ; break; } - usage2 (_("%s: VSZ must be an integer!\n\n"), progname); + usage4 (_("VSZ must be an integer!")); case 'P': /* PCPU */ /* TODO: -P 1.5.5 is accepted */ if (sscanf (optarg, "%f%[^0-9.]", &pcpu, tmp) == 1) { @@ -458,7 +456,7 @@ process_arguments (int argc, char **argv) options |= PCPU; break; } - usage2 (_("%s: PCPU must be a float!\n\n"), progname); + usage4 (_("PCPU must be a float!")); case 'm': asprintf (&metric_name, "%s", optarg); if ( strcmp(optarg, "PROCS") == 0) { @@ -482,10 +480,7 @@ process_arguments (int argc, char **argv) break; } - printf (_("%s: metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!\n\n"), - progname); - print_usage (); - exit (STATE_UNKNOWN); + usage4 (_("Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!")); case 'v': /* command */ verbose++; break; @@ -588,8 +583,6 @@ check_thresholds (int value) } - - /* convert the elapsed time to seconds */ int convert_to_seconds(char *etime) { @@ -653,7 +646,6 @@ convert_to_seconds(char *etime) { } - void print_help (void) { diff --git a/plugins/check_radius.c b/plugins/check_radius.c index 9e104686..07ee4c7f 100644 --- a/plugins/check_radius.c +++ b/plugins/check_radius.c @@ -199,12 +199,12 @@ process_arguments (int argc, char **argv) if (is_intpos (argv[5])) retries = atoi (argv[5]); else - usage (_("Number of retries must be a positive integer")); + usage4 (_("Number of retries must be a positive integer")); server = argv[6]; if (is_intpos (argv[7])) port = atoi (argv[7]); else - usage (_("Port must be a positive integer")); + usage4 (_("Port must be a positive integer")); expect = argv[8]; return OK; } @@ -218,9 +218,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* print short usage statement if args not parsable */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (OK); @@ -240,7 +238,7 @@ process_arguments (int argc, char **argv) if (is_intnonneg (optarg)) port = atoi (optarg); else - usage (_("Port must be a positive integer")); + usage4 (_("Port must be a positive integer")); break; case 'u': /* username */ username = optarg; @@ -261,7 +259,7 @@ process_arguments (int argc, char **argv) if (is_intpos (optarg)) retries = atoi (optarg); else - usage (_("Number of retries must be a positive integer")); + usage4 (_("Number of retries must be a positive integer")); break; case 't': /* timeout */ if (is_intpos (optarg)) diff --git a/plugins/check_real.c b/plugins/check_real.c index 30424656..eb892c77 100644 --- a/plugins/check_real.c +++ b/plugins/check_real.c @@ -330,7 +330,7 @@ process_arguments (int argc, char **argv) check_critical_time = TRUE; } else { - usage4 (_("Critical time must be a nonnegative integer")); + usage4 (_("Critical time must be a positive integer")); } break; case 'v': /* verbose */ @@ -341,7 +341,7 @@ process_arguments (int argc, char **argv) socket_timeout = atoi (optarg); } else { - usage4 (_("Time interval must be a nonnegative integer")); + usage4 (_("Timeout interval must be a positive integer")); } break; case 'V': /* version */ @@ -351,9 +351,7 @@ process_arguments (int argc, char **argv) print_help (); exit (STATE_OK); case '?': /* usage */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); } } @@ -368,7 +366,7 @@ process_arguments (int argc, char **argv) } if (server_address==NULL) - usage (_("You must provide a server to check\n")); + usage4 (_("You must provide a server to check")); if (host_name==NULL) host_name = strdup (server_address); diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index b6c60c24..55cf5da5 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -351,7 +351,7 @@ process_arguments (int argc, char **argv) socket_timeout = atoi (optarg); } else { - usage4 (_("Time interval must be a positive integer")); + usage4 (_("Timeout interval must be a positive integer")); } break; case '4': @@ -371,9 +371,7 @@ process_arguments (int argc, char **argv) print_help (); exit (STATE_OK); case '?': /* help */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); } } diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index c1c4ea83..5f221218 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -251,7 +251,7 @@ main (int argc, char **argv) eval_method[i] & WARN_NE) { p2 = strpbrk (p2, "0123456789"); if (p2 == NULL) - die (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]); @@ -398,9 +398,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* usage */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); @@ -795,7 +793,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, "'")) - die (STATE_UNKNOWN, "Unbalanced quotes\n"); + die (STATE_UNKNOWN, _("Unbalanced quotes\n")); } return str; } diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c index e957c053..7b7bc8fd 100644 --- a/plugins/check_ssh.c +++ b/plugins/check_ssh.c @@ -110,9 +110,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* help */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'V': /* version */ print_revision (progname, revision); exit (STATE_OK); @@ -135,7 +133,7 @@ process_arguments (int argc, char **argv) #ifdef USE_IPV6 address_family = AF_INET6; #else - usage (_("IPv6 support not available\n")); + usage4 (_("IPv6 support not available")); #endif break; case 'r': /* remote version */ @@ -151,11 +149,9 @@ process_arguments (int argc, char **argv) port = atoi (optarg); } else { - printf ("Port number nust be a positive integer: %s\n", optarg); - usage (""); + usage2 (_("Port number must be a positive integer"), optarg); } } - } c = optind; diff --git a/plugins/check_swap.c b/plugins/check_swap.c index 6e2ab723..093845b4 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c @@ -239,7 +239,7 @@ main (int argc, char **argv) /* and now, tally 'em up */ swapctl_res=swapctl(SC_LIST, tbl); if(swapctl_res < 0){ - perror("swapctl failed: "); + perror(_("swapctl failed: ")); result = STATE_WARNING; } @@ -278,7 +278,7 @@ main (int argc, char **argv) /* and now, tally 'em up */ swapctl_res=swapctl(SWAP_STATS, ent, nswaps); if(swapctl_res < 0){ - perror("swapctl failed: "); + perror(_("swapctl failed: ")); result = STATE_WARNING; } @@ -388,7 +388,7 @@ process_arguments (int argc, char **argv) break; } else { - usage (_("Warning threshold must be integer or percentage!\n")); + usage4 (_("Warning threshold must be integer or percentage!")); } case 'c': /* critical size threshold */ if (is_intnonneg (optarg)) { @@ -420,9 +420,7 @@ process_arguments (int argc, char **argv) print_help (); exit (STATE_OK); case '?': /* error */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); } } diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index b922536e..fcd67786 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c @@ -259,13 +259,13 @@ main (int argc, char **argv) #ifdef HAVE_SSL if (use_ssl && check_cert == TRUE) { if (connect_SSL () != OK) - die (STATE_CRITICAL,"CRITICAL - Could not make SSL connection\n"); + die (STATE_CRITICAL,_("CRITICAL - Could not make SSL connection\n")); if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) { result = check_certificate (&server_cert); X509_free(server_cert); } else { - printf("CRITICAL - Cannot retrieve server certificate.\n"); + printf(_("CRITICAL - Cannot retrieve server certificate.\n")); result = STATE_CRITICAL; } SSL_shutdown (ssl); @@ -434,7 +434,7 @@ process_arguments (int argc, char **argv) }; if (argc < 2) - usage ("No arguments found\n"); + usage4 (_("No arguments found")); /* backwards compatibility */ for (c = 1; c < argc; c++) { @@ -462,14 +462,12 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* print short usage statement if args not parsable */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); case 'V': /* version */ - print_revision (progname, "$Revision$"); + print_revision (progname, revision); exit (STATE_OK); case 'v': /* verbose mode */ verbose = TRUE; @@ -575,7 +573,7 @@ process_arguments (int argc, char **argv) case 'D': /* Check SSL cert validity - days 'til certificate expiration */ #ifdef HAVE_SSL if (!is_intnonneg (optarg)) - usage2 ("invalid certificate expiration period", optarg); + usage2 (_("Invalid certificate expiration period"), optarg); days_till_exp = atoi (optarg); check_cert = TRUE; use_ssl = TRUE; @@ -583,14 +581,14 @@ process_arguments (int argc, char **argv) case 'S': use_ssl = TRUE; #else - die (STATE_UNKNOWN, "SSL support not available. Install OpenSSL and recompile."); + die (STATE_UNKNOWN, _("SSL support not available. Install OpenSSL and recompile.")); #endif break; } } if (server_address == NULL) - usage (_("You must provide a server address\n")); + usage4 (_("You must provide a server address")); return TRUE; } @@ -669,7 +667,7 @@ check_certificate (X509 ** certificate) /* Generate tm structure to process timestamp */ if (tm->type == V_ASN1_UTCTIME) { if (tm->length < 10) { - printf ("CRITICAL - Wrong time format in certificate.\n"); + printf (_("CRITICAL - Wrong time format in certificate.\n")); return STATE_CRITICAL; } else { @@ -681,7 +679,7 @@ check_certificate (X509 ** certificate) } else { if (tm->length < 12) { - printf ("CRITICAL - Wrong time format in certificate.\n"); + printf (_("CRITICAL - Wrong time format in certificate.\n")); return STATE_CRITICAL; } else { @@ -710,20 +708,20 @@ check_certificate (X509 ** certificate) stamp.tm_mday, stamp.tm_year + 1900, stamp.tm_hour, stamp.tm_min); if (days_left > 0 && days_left <= days_till_exp) { - printf ("Certificate expires in %d day(s) (%s).\n", days_left, timestamp); + printf (_("Certificate expires in %d day(s) (%s).\n"), days_left, timestamp); return STATE_WARNING; } if (days_left < 0) { - printf ("Certificate expired on %s.\n", timestamp); + printf (_("Certificate expired on %s.\n"), timestamp); return STATE_CRITICAL; } if (days_left == 0) { - printf ("Certificate expires today (%s).\n", timestamp); + printf (_("Certificate expires today (%s).\n"), timestamp); return STATE_WARNING; } - printf ("Certificate will expire on %s.\n", timestamp); + printf (_("Certificate will expire on %s.\n"), timestamp); return STATE_OK; } diff --git a/plugins/check_time.c b/plugins/check_time.c index 63d7ee25..efca91bd 100644 --- a/plugins/check_time.c +++ b/plugins/check_time.c @@ -216,9 +216,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* print short usage statement if args not parsable */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); diff --git a/plugins/check_udp.c b/plugins/check_udp.c index b79f31f7..e7d5280c 100644 --- a/plugins/check_udp.c +++ b/plugins/check_udp.c @@ -67,7 +67,7 @@ main (int argc, char **argv) time (&end_time); if (result != STATE_OK) { - printf ("No response from host on port %d\n", server_port); + printf (_("No response from host on port %d\n"), server_port); result = STATE_CRITICAL; } @@ -76,7 +76,7 @@ main (int argc, char **argv) /* check to see if we got the response we wanted */ if (server_expect) { if (!strstr (recv_buffer, server_expect)) { - printf ("Invalid response received from host on port %d\n", + printf (_("Invalid response received from host on port %d\n"), server_port); result = STATE_CRITICAL; } @@ -146,9 +146,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* print short usage statement if args not parsable */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); @@ -254,8 +252,6 @@ STATE_CRITICAL, other errors return STATE_UNKNOWN.\n\n")); } - - /* Original Command line: check_udp [-p port] [-s send] [-e expect] \ [-wt warn_time] [-ct crit_time] [-to to_sec] */ diff --git a/plugins/check_ups.c b/plugins/check_ups.c index a4d76503..1cdf9e9e 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c @@ -133,48 +133,48 @@ main (int argc, char **argv) } else if ((status & (UPSSTATUS_OB | UPSSTATUS_LB)) == (UPSSTATUS_OB | UPSSTATUS_LB)) { - asprintf (&ups_status, "On Battery, Low Battery"); + asprintf (&ups_status, _("On Battery, Low Battery")); result = STATE_CRITICAL; } else { if (status & UPSSTATUS_OL) { - asprintf (&ups_status, "%s%s", ups_status, "Online"); + asprintf (&ups_status, "%s%s", ups_status, _("Online")); } if (status & UPSSTATUS_OB) { - asprintf (&ups_status, "%s%s", ups_status, "On Battery"); + asprintf (&ups_status, "%s%s", ups_status, _("On Battery")); result = STATE_WARNING; } if (status & UPSSTATUS_LB) { - asprintf (&ups_status, "%s%s", ups_status, ", Low Battery"); + asprintf (&ups_status, "%s%s", ups_status, _(", Low Battery")); result = STATE_WARNING; } if (status & UPSSTATUS_CAL) { - asprintf (&ups_status, "%s%s", ups_status, ", Calibrating"); + asprintf (&ups_status, "%s%s", ups_status, _(", Calibrating")); } if (status & UPSSTATUS_RB) { - asprintf (&ups_status, "%s%s", ups_status, ", Replace Battery"); + asprintf (&ups_status, "%s%s", ups_status, _(", Replace Battery")); result = STATE_WARNING; } if (status & UPSSTATUS_BYPASS) { - asprintf (&ups_status, "%s%s", ups_status, ", On Bypass"); + asprintf (&ups_status, "%s%s", ups_status, _(", On Bypass")); } if (status & UPSSTATUS_OVER) { - asprintf (&ups_status, "%s%s", ups_status, ", Overload"); + asprintf (&ups_status, "%s%s", ups_status, _(", Overload")); } if (status & UPSSTATUS_TRIM) { - asprintf (&ups_status, "%s%s", ups_status, ", Trimming"); + asprintf (&ups_status, "%s%s", ups_status, _(", Trimming")); } if (status & UPSSTATUS_BOOST) { - asprintf (&ups_status, "%s%s", ups_status, ", Boosting"); + asprintf (&ups_status, "%s%s", ups_status, _(", Boosting")); } if (status & UPSSTATUS_CHRG) { - asprintf (&ups_status, "%s%s", ups_status, ", Charging"); + asprintf (&ups_status, "%s%s", ups_status, _(", Charging")); } if (status & UPSSTATUS_DISCHRG) { - asprintf (&ups_status, "%s%s", ups_status, ", Discharging"); + asprintf (&ups_status, "%s%s", ups_status, _(", Discharging")); } if (status & UPSSTATUS_UNKOWN) { - asprintf (&ups_status, "%s%s", ups_status, ", Unknown"); + asprintf (&ups_status, "%s%s", ups_status, _(", Unknown")); } } asprintf (&message, "%sStatus=%s ", message, ups_status); @@ -311,7 +311,7 @@ main (int argc, char **argv) /* if the UPS does not support any options we are looking for, report an error */ if (supported_options == UPS_NONE) { result = STATE_CRITICAL; - asprintf (&message, "UPS does not support any available options\n"); + asprintf (&message, _("UPS does not support any available options\n")); } /* reset timeout */ @@ -335,7 +335,7 @@ determine_status (void) res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer)); if (res == NOSUCHVAR) return OK; if (res != STATE_OK) { - printf ("Invalid response received from host\n"); + printf (_("Invalid response received from host\n")); return ERROR; } @@ -395,7 +395,7 @@ get_ups_variable (const char *varname, char *buf, size_t buflen) if (process_tcp_request (server_address, server_port, send_buffer, temp_buffer, sizeof (temp_buffer)) != STATE_OK) { - printf ("Invalid response received from host\n"); + printf (_("Invalid response received from host\n")); return ERROR; } @@ -403,7 +403,7 @@ get_ups_variable (const char *varname, char *buf, size_t buflen) len = strlen(ptr); if (len > 0 && ptr[len-1] == '\n') ptr[len-1]=0; if (strcmp (ptr, "ERR UNKNOWN-UPS") == 0) { - printf ("CRITICAL - no such ups '%s' on that host\n", ups_name); + printf (_("CRITICAL - no such ups '%s' on that host\n"), ups_name); return ERROR; } @@ -413,19 +413,19 @@ get_ups_variable (const char *varname, char *buf, size_t buflen) } if (strcmp (ptr, "ERR DATA-STALE") == 0) { - printf ("CRITICAL - UPS data is stale\n"); + printf (_("CRITICAL - UPS data is stale\n")); return ERROR; } if (strncmp (ptr, "ERR", 3) == 0) { - printf ("Unknown error: %s\n", ptr); + printf (_("Unknown error: %s\n"), ptr); return ERROR; } ptr = temp_buffer + strlen (varname) + strlen (ups_name) + 6; len = strlen(ptr); if (len < 2 || ptr[0] != '"' || ptr[len-1] != '"') { - printf ("Error: unable to parse variable\n"); + printf (_("Error: unable to parse variable\n")); return ERROR; } strncpy (buf, ptr+1, len - 2); @@ -481,9 +481,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* help */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'H': /* hostname */ if (is_host (optarg)) { server_address = optarg; @@ -503,7 +501,7 @@ process_arguments (int argc, char **argv) server_port = atoi (optarg); } else { - usage2 ("Port must be a positive integer", optarg); + usage2 (_("Port must be a positive integer"), optarg); } break; case 'c': /* critical time threshold */ @@ -512,7 +510,7 @@ process_arguments (int argc, char **argv) check_crit = TRUE; } else { - usage2 ("Critical time must be a positive integer", optarg); + usage2 (_("Critical time must be a positive integer"), optarg); } break; case 'w': /* warning time threshold */ @@ -521,7 +519,7 @@ process_arguments (int argc, char **argv) check_warn = TRUE; } else { - usage2 ("Warning time must be a positive integer", optarg); + usage2 (_("Warning time must be a positive integer"), optarg); } break; case 'v': /* variable */ @@ -534,14 +532,14 @@ process_arguments (int argc, char **argv) else if (!strcmp (optarg, "LOADPCT")) check_variable = UPS_LOADPCT; else - usage2 ("Unrecognized UPS variable", optarg); + usage2 (_("Unrecognized UPS variable"), optarg); break; case 't': /* timeout */ if (is_intnonneg (optarg)) { socket_timeout = atoi (optarg); } else { - usage ("Time interval must be a positive integer\n"); + usage4 (_("Timeout interval must be a positive integer")); } break; case 'V': /* version */ @@ -568,19 +566,17 @@ process_arguments (int argc, char **argv) } - int validate_arguments (void) { if (! ups_name) { - printf ("Error : no ups indicated\n"); + printf (_("Error : no ups indicated\n")); return ERROR; } return OK; } - void print_help (void) { @@ -641,7 +637,6 @@ http://www.networkupstools.org\n\n")); } - void print_usage (void) { diff --git a/plugins/check_users.c b/plugins/check_users.c index d1b4f018..25d04ed0 100644 --- a/plugins/check_users.c +++ b/plugins/check_users.c @@ -140,9 +140,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* print short usage statement if args not parsable */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); case 'h': /* help */ print_help (); exit (STATE_OK); @@ -151,13 +149,13 @@ process_arguments (int argc, char **argv) exit (STATE_OK); case 'c': /* critical */ if (!is_intnonneg (optarg)) - usage (_("Critical threshold must be a positive integer\n")); + usage4 (_("Critical threshold must be a positive integer")); else cusers = atoi (optarg); break; case 'w': /* warning */ if (!is_intnonneg (optarg)) - usage (_("Warning threshold must be a positive integer\n")); + usage4 (_("Warning threshold must be a positive integer")); else wusers = atoi (optarg); break; @@ -167,14 +165,14 @@ process_arguments (int argc, char **argv) c = optind; if (wusers == -1 && argc > c) { if (is_intnonneg (argv[c]) == FALSE) - usage (_("Warning threshold must be a positive integer\n")); + usage4 (_("Warning threshold must be a positive integer")); else wusers = atoi (argv[c++]); } if (cusers == -1 && argc > c) { if (is_intnonneg (argv[c]) == FALSE) - usage (_("Warning threshold must be a positive integer\n")); + usage4 (_("Warning threshold must be a positive integer")); else cusers = atoi (argv[c]); } @@ -210,7 +208,6 @@ system and generates an error if the number exceeds the thresholds specified.\n" } - void print_usage (void) { diff --git a/plugins/negate.c b/plugins/negate.c index e35ddb9e..d08c3a30 100644 --- a/plugins/negate.c +++ b/plugins/negate.c @@ -174,9 +174,7 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* help */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); break; case 'h': /* help */ print_help (); diff --git a/plugins/netutils.c b/plugins/netutils.c index 6702b13f..1231c1ef 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c @@ -45,9 +45,9 @@ void socket_timeout_alarm_handler (int sig) { if (sig == SIGALRM) - printf ("CRITICAL - Socket timeout after %d seconds\n", socket_timeout); + printf (_("CRITICAL - Socket timeout after %d seconds\n"), socket_timeout); else - printf ("CRITICAL - Abnormal timeout after %d seconds\n", socket_timeout); + printf (_("CRITICAL - Abnormal timeout after %d seconds\n"), socket_timeout); exit (STATE_CRITICAL); } @@ -106,7 +106,7 @@ process_tcp_request2 (const char *server_address, int server_port, send_result = send (sd, send_buffer, strlen (send_buffer), 0); if (send_result<0 || (size_t)send_result!=strlen(send_buffer)) { - printf ("Send failed\n"); + printf (_("Send failed\n")); result = STATE_WARNING; } @@ -123,7 +123,7 @@ process_tcp_request2 (const char *server_address, int server_port, if (!FD_ISSET (sd, &readfds)) { /* it hasn't */ if (!recv_length) { strcpy (recv_buffer, ""); - printf ("No data was received from host!\n"); + printf (_("No data was received from host!\n")); result = STATE_WARNING; } else { /* this one failed, but previous ones worked */ @@ -239,7 +239,7 @@ my_connect (const char *host_name, int port, int *sd, int proto) SOCK_DGRAM : SOCK_STREAM, res->ai_protocol); if (*sd < 0) { - printf ("Socket creation failed\n"); + printf (_("Socket creation failed\n")); freeaddrinfo (res); return STATE_UNKNOWN; } @@ -315,7 +315,7 @@ send_request (int sd, int proto, const char *send_buffer, char *recv_buffer, int send_result = send (sd, send_buffer, strlen (send_buffer), 0); if (send_result<0 || (size_t)send_result!=strlen(send_buffer)) { - printf ("Send failed\n"); + printf (_("Send failed\n")); result = STATE_WARNING; } @@ -330,7 +330,7 @@ send_request (int sd, int proto, const char *send_buffer, char *recv_buffer, int /* make sure some data has arrived */ if (!FD_ISSET (sd, &readfds)) { strcpy (recv_buffer, ""); - printf ("No data was received from host!\n"); + printf (_("No data was received from host!\n")); result = STATE_WARNING; } @@ -339,7 +339,7 @@ send_request (int sd, int proto, const char *send_buffer, char *recv_buffer, int if (recv_result == -1) { strcpy (recv_buffer, ""); if (proto != IPPROTO_TCP) - printf ("Receive failed\n"); + printf (_("Receive failed\n")); result = STATE_WARNING; } else diff --git a/plugins/popen.c b/plugins/popen.c index 94ad583f..04eb3881 100644 --- a/plugins/popen.c +++ b/plugins/popen.c @@ -114,7 +114,7 @@ spopen (const char *cmdstring) argv = malloc (sizeof(char*)*argc); if (argv == NULL) { - printf ("Could not malloc argv array in popen()\n"); + printf (_("Could not malloc argv array in popen()\n")); return NULL; } @@ -124,7 +124,7 @@ spopen (const char *cmdstring) str += strspn (str, " \t\r\n"); /* trim any leading whitespace */ if (i >= argc - 2) { - printf ("CRITICAL - You need more args!!!\n"); + printf (_("CRITICAL - You need more args!!!\n")); return (NULL); } @@ -239,17 +239,19 @@ static int openmax = 0; #define OPEN_MAX_GUESS 256 /* if OPEN_MAX is indeterminate */ /* no guarantee this is adequate */ + void popen_timeout_alarm_handler (int signo) { if (signo == SIGALRM) { kill (childpid[fileno (child_process)], SIGKILL); - printf ("CRITICAL - Plugin timed out after %d seconds\n", + printf (_("CRITICAL - Plugin timed out after %d seconds\n"), timeout_interval); exit (STATE_CRITICAL); } } + int open_max (void) { @@ -259,14 +261,13 @@ open_max (void) if (errno == 0) openmax = OPEN_MAX_GUESS; /* it's indeterminate */ else - err_sys ("sysconf error for _SC_OPEN_MAX"); + err_sys (_("sysconf error for _SC_OPEN_MAX")); } } return (openmax); } - /* Fatal error related to a system call. * Print a message and die. */ @@ -309,4 +310,3 @@ rtrim (char *str, const char *tok) } return str; } - diff --git a/plugins/popen.h b/plugins/popen.h index b7585792..1f4e413a 100644 --- a/plugins/popen.h +++ b/plugins/popen.h @@ -1,3 +1,9 @@ +/****************************************************************************** + * + * $Id$ + * + ******************************************************************************/ + FILE *spopen (const char *); int spclose (FILE *); RETSIGTYPE popen_timeout_alarm_handler (int); diff --git a/plugins/urlize.c b/plugins/urlize.c index 3564e469..96bbdc00 100644 --- a/plugins/urlize.c +++ b/plugins/urlize.c @@ -71,9 +71,7 @@ main (int argc, char **argv) break; case '?': default: - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); + usage2 (_("Unknown argument"), optarg); } } diff --git a/plugins/utils.c b/plugins/utils.c index b2948e65..b9a19d3f 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -53,7 +53,7 @@ max_state (int a, int b) void usage (const char *msg) { - printf ("%s", msg); + printf ("%s\n", msg); print_usage (); exit (STATE_UNKNOWN); } @@ -133,7 +133,7 @@ void timeout_alarm_handler (int signo) { if (signo == SIGALRM) { - printf ("CRITICAL - Plugin timed out after %d seconds\n", + printf (_("CRITICAL - Plugin timed out after %d seconds\n"), timeout_interval); exit (STATE_CRITICAL); } @@ -430,7 +430,7 @@ strpcpy (char *dest, const char *src, const char *str) if (dest == NULL || strlen (dest) < len) dest = realloc (dest, len + 1); if (dest == NULL) - die (STATE_UNKNOWN, "failed realloc in strpcpy\n"); + die (STATE_UNKNOWN, _("failed realloc in strpcpy\n")); strncpy (dest, src, len); dest[len] = '\0'; @@ -472,7 +472,7 @@ strpcat (char *dest, const char *src, const char *str) dest = realloc (dest, len + l2 + 1); if (dest == NULL) - die (STATE_UNKNOWN, "failed malloc in strscat\n"); + die (STATE_UNKNOWN, _("failed malloc in strscat\n")); strncpy (dest + len, src, l2); dest[len + l2] = '\0'; -- cgit v1.2.3