diff options
author | Benoit Mortier <opensides@users.sourceforge.net> | 2004-12-02 16:51:25 +0000 |
---|---|---|
committer | Benoit Mortier <opensides@users.sourceforge.net> | 2004-12-02 16:51:25 +0000 |
commit | 234481163fc3caf0cb8b14f601f0f9f1458f97f5 (patch) | |
tree | e8debce30a2722f5f4dc5e33faf54c9915dd022f /plugins | |
parent | df1bd0c89ff63de64ee630e0025389651947020c (diff) | |
download | monitoring-plugins-234481163fc3caf0cb8b14f601f0f9f1458f97f5.tar.gz |
More internationalization work
new usage4 function to permit localisation of think like check_ssh: xxxxx
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@979 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
34 files changed, 53 insertions, 64 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c index 20ae6283..f569731d 100644 --- a/plugins/check_by_ssh.c +++ b/plugins/check_by_ssh.c @@ -69,17 +69,14 @@ main (int argc, char **argv) /* process arguments */ if (process_arguments (argc, argv) != TRUE) - usage (_("check_by_ssh: could not parse arguments\n")); - + usage4 (_("Could not parse arguments")); /* Set signal handling and alarm timeout */ if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { - printf (_("Cannot catch SIGALRM")); - return STATE_UNKNOWN; + usage4 (_(" Cannot catch SIGALRM")); } alarm (timeout_interval); - /* run the command */ if (verbose) diff --git a/plugins/check_dig.c b/plugins/check_dig.c index 14c0da5a..0102ea56 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c @@ -66,10 +66,10 @@ main (int argc, char **argv) /* Set signal handling and alarm */ if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) - usage (_("Cannot catch SIGALRM\n")); + usage4 (_("Cannot catch SIGALRM")); if (process_arguments (argc, argv) != TRUE) - usage (_("Could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* get the command to run */ asprintf (&command_line, "%s @%s -p %d %s -t %s", diff --git a/plugins/check_disk.c b/plugins/check_disk.c index 0cab9ac5..c7ea3441 100644 --- a/plugins/check_disk.c +++ b/plugins/check_disk.c @@ -164,7 +164,7 @@ main (int argc, char **argv) mount_list = read_filesystem_list (0); if (process_arguments (argc, argv) != TRUE) - usage (_("check_disk: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); for (me = mount_list; me; me = me->me_next) { diff --git a/plugins/check_dns.c b/plugins/check_dns.c index d64431a8..070223e7 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -68,12 +68,11 @@ main (int argc, char **argv) /* Set signal handling and alarm */ if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { - printf (_("Cannot catch SIGALRM")); - return STATE_UNKNOWN; + usage4 (_("Cannot catch SIGALRM")); } if (process_arguments (argc, argv) != TRUE) { - usage (_("check_dns: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); } /* get the command to run */ diff --git a/plugins/check_fping.c b/plugins/check_fping.c index 74236d9b..817d647a 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c @@ -68,7 +68,7 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_fping: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); server = strscpy (server, server_name); diff --git a/plugins/check_game.c b/plugins/check_game.c index c8492d8f..89c212e8 100644 --- a/plugins/check_game.c +++ b/plugins/check_game.c @@ -64,22 +64,9 @@ main (int argc, char **argv) setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - -// result = process_arguments (argc, argv); if (process_arguments (argc, argv) != TRUE) - usage (_("check_game: could not parse arguments\n")); - -/* if (result != OK) { - printf (_("Incorrect arguments supplied\n")); - printf ("\n"); - print_revision (progname, revision); - printf ("Copyright (c) 1999 Ian Cass, Knowledge Matters Limited\n"); - printf (_("License: GPL\n")); - printf ("\n"); - return STATE_UNKNOWN; - } -*/ + usage4 (_("Could not parse arguments")); result = STATE_OK; @@ -312,6 +299,7 @@ print_help (void) { print_revision (progname, revision); + printf ("Copyright (c) 1999 Ian Cass, Knowledge Matters Limited\n"); printf (_(COPYRIGHT), copyright, email); printf (_("This plugin tests %s connections with the specified host."), progname); diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c index 5fdfc8ac..7c56e5dc 100644 --- a/plugins/check_hpjd.c +++ b/plugins/check_hpjd.c @@ -85,7 +85,7 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_hpjd: could not parse arguments\n")); + usage4 (_("Could not parse arguments\n")); /* removed ' 2>1' at end of command 10/27/1999 - EG */ /* create the query string */ diff --git a/plugins/check_http.c b/plugins/check_http.c index e962e024..93bff453 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -146,7 +146,7 @@ main (int argc, char **argv) clean_revstring (revision), VERSION); if (process_arguments (argc, argv) != TRUE) - usage (_("check_http: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); if (strstr (timestamp, ":")) { if (strstr (server_url, "?")) diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index 07b89acb..9c41cc30 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c @@ -73,7 +73,7 @@ main (int argc, char *argv[]) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_ldap: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* initialize alarm signal handling */ signal (SIGALRM, socket_timeout_alarm_handler); diff --git a/plugins/check_load.c b/plugins/check_load.c index 8322dbb3..b918fa54 100644 --- a/plugins/check_load.c +++ b/plugins/check_load.c @@ -74,7 +74,7 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_load: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); #if HAVE_GETLOADAVG==1 result = getloadavg (la, 3); diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c index 58717bff..31d132d4 100644 --- a/plugins/check_mrtg.c +++ b/plugins/check_mrtg.c @@ -60,7 +60,7 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_mrtg: could not parse arguments\n")); + usage4 (_("Could not parse arguments\n")); /* open the MRTG log file for reading */ fp = fopen (log_file, "r"); diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c index 5bbce500..24ccaa93 100644 --- a/plugins/check_mrtgtraf.c +++ b/plugins/check_mrtgtraf.c @@ -63,12 +63,12 @@ main (int argc, char **argv) char outgoing_speed_rating[8]; if (process_arguments (argc, argv) != TRUE) - usage (_("check_ldap: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* open the MRTG log file for reading */ fp = fopen (log_file, "r"); if (fp == NULL) - usage (_("Unable to open MRTG log file\n")); + usage4 (_("Unable to open MRTG log file")); line = 0; while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) { @@ -110,7 +110,7 @@ main (int argc, char **argv) /* if we couldn't read enough data, return an unknown error */ if (line <= 2) - usage (_("Unable to process MRTG log file\n")); + usage4 (_("Unable to process MRTG log file")); /* make sure the MRTG data isn't too old */ time (¤t_time); diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 0564f7c8..f55630b2 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c @@ -56,7 +56,7 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_mysql: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* initialize mysql */ mysql_init (&mysql); diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c index 7c36d116..618ee573 100644 --- a/plugins/check_nagios.c +++ b/plugins/check_nagios.c @@ -66,12 +66,11 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_nagios: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); - /* Set signal handling and alarm */ + /* Set signal handling and alarm timeout */ if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) { - printf (_("Cannot catch SIGALRM")); - return STATE_UNKNOWN; + usage4 (_("Cannot catch SIGALRM")); } /* handle timeouts gracefully... */ diff --git a/plugins/check_nt.c b/plugins/check_nt.c index c7fc7459..efd7cdef 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c @@ -111,7 +111,7 @@ int main(int argc, char **argv){ textdomain (PACKAGE); if(process_arguments(argc,argv) != TRUE) - usage (_("check_nt: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* initialize alarm signal handling */ signal(SIGALRM,socket_timeout_alarm_handler); diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c index a6d2e249..ce5773b9 100644 --- a/plugins/check_nwstat.c +++ b/plugins/check_nwstat.c @@ -122,7 +122,7 @@ main(int argc, char **argv) { textdomain (PACKAGE); if (process_arguments(argc,argv) != TRUE) - usage (_("check_nwstat: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* initialize alarm signal handling */ signal(SIGALRM,socket_timeout_alarm_handler); diff --git a/plugins/check_overcr.c b/plugins/check_overcr.c index cb85dc66..22277f6e 100644 --- a/plugins/check_overcr.c +++ b/plugins/check_overcr.c @@ -86,7 +86,7 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_overcr: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* initialize alarm signal handling */ signal (SIGALRM, socket_timeout_alarm_handler); diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c index 5c3b8107..f9d66110 100644 --- a/plugins/check_pgsql.c +++ b/plugins/check_pgsql.c @@ -133,12 +133,11 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_pgsql: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* Set signal handling and alarm */ if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) { - printf (_("Cannot catch SIGALRM")); - return STATE_UNKNOWN; + usage4 (_("Cannot catch SIGALRM")); } alarm (timeout_interval); diff --git a/plugins/check_ping.c b/plugins/check_ping.c index 6d8ef06d..ecaf03ed 100644 --- a/plugins/check_ping.c +++ b/plugins/check_ping.c @@ -79,12 +79,11 @@ main (int argc, char **argv) addresses[0] = NULL; if (process_arguments (argc, argv) != TRUE) - usage (_("check_ping: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* Set signal handling and alarm */ if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { - printf (_("Cannot catch SIGALRM")); - return STATE_UNKNOWN; + usage4 (_("Cannot catch SIGALRM")); } /* handle timeouts gracefully */ diff --git a/plugins/check_procs.c b/plugins/check_procs.c index d1e1b7c5..4bc87c0a 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c @@ -116,12 +116,11 @@ main (int argc, char **argv) metric = METRIC_PROCS; if (process_arguments (argc, argv) != TRUE) - usage (_("check_procs: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* Set signal handling and alarm timeout */ if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { - printf (_("Cannot catch SIGALRM")); - return STATE_UNKNOWN; + usage4 (_("Cannot catch SIGALRM")); } alarm (timeout_interval); diff --git a/plugins/check_radius.c b/plugins/check_radius.c index 405b417b..68ed4d88 100644 --- a/plugins/check_radius.c +++ b/plugins/check_radius.c @@ -113,7 +113,7 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_radius: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); str = strdup ("dictionary"); if ((config_file && rc_read_config (config_file)) || diff --git a/plugins/check_real.c b/plugins/check_real.c index 9a8f42a0..4ede6a5c 100644 --- a/plugins/check_real.c +++ b/plugins/check_real.c @@ -65,7 +65,7 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_real: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* initialize alarm signal handling */ signal (SIGALRM, socket_timeout_alarm_handler); diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 33224948..257a38bb 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -89,7 +89,7 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_smtp: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* initialize the HELO command with the localhostname */ #ifndef HOST_MAX_BYTES diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index c7dff3d2..6a41c6af 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -157,7 +157,7 @@ main (int argc, char **argv) miblist = strdup (DEFAULT_MIBLIST); if (process_arguments (argc, argv) != TRUE) - usage (_("check_snmp: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* create the command line to execute */ asprintf (&command_line, "%s -t 1 -r %d -m %s -v %s %s %s:%s %s", diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c index f9bbd122..82d0acad 100644 --- a/plugins/check_ssh.c +++ b/plugins/check_ssh.c @@ -58,7 +58,7 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_ssh: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* initialize alarm signal handling */ signal (SIGALRM, socket_timeout_alarm_handler); diff --git a/plugins/check_swap.c b/plugins/check_swap.c index f2d722ce..608080ac 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c @@ -90,7 +90,7 @@ main (int argc, char **argv) perf = strdup (""); if (process_arguments (argc, argv) != TRUE) - usage (_("Incorrect arguments supplied\n")); + usage4 (_("Could not parse arguments")); #ifdef HAVE_PROC_MEMINFO fp = fopen (PROC_MEMINFO, "r"); diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index ed51e94a..af3c7206 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c @@ -240,7 +240,7 @@ main (int argc, char **argv) status = strdup (""); if (process_arguments (argc, argv) != TRUE) - usage (_("check_tcp: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* use default expect if none listed in process_arguments() */ if (EXPECT && server_expect_count == 0) { @@ -265,7 +265,7 @@ main (int argc, char **argv) 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); diff --git a/plugins/check_time.c b/plugins/check_time.c index 042a7d5a..ee6ff438 100644 --- a/plugins/check_time.c +++ b/plugins/check_time.c @@ -63,7 +63,7 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_time: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* initialize alarm signal handling */ signal (SIGALRM, socket_timeout_alarm_handler); diff --git a/plugins/check_udp.c b/plugins/check_udp.c index fb7cae1a..5d671745 100644 --- a/plugins/check_udp.c +++ b/plugins/check_udp.c @@ -52,7 +52,7 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("check_udp: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* initialize alarm signal handling */ signal (SIGALRM, socket_timeout_alarm_handler); diff --git a/plugins/check_ups.c b/plugins/check_ups.c index 4006031f..e974b753 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c @@ -112,7 +112,7 @@ main (int argc, char **argv) message = strdup (""); if (process_arguments (argc, argv) != TRUE) - usage (_("check_ups: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* initialize alarm signal handling */ signal (SIGALRM, socket_timeout_alarm_handler); diff --git a/plugins/check_users.c b/plugins/check_users.c index 23f8973c..891fe3b7 100644 --- a/plugins/check_users.c +++ b/plugins/check_users.c @@ -51,7 +51,7 @@ main (int argc, char **argv) perf = strdup(""); if (process_arguments (argc, argv) != TRUE) - usage (_("check_users: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* run the command */ child_process = spopen (WHO_COMMAND); diff --git a/plugins/negate.c b/plugins/negate.c index 02838a67..9e25ebc5 100644 --- a/plugins/negate.c +++ b/plugins/negate.c @@ -84,7 +84,7 @@ main (int argc, char **argv) textdomain (PACKAGE); if (process_arguments (argc, argv) != TRUE) - usage (_("negate: could not parse arguments\n")); + usage4 (_("Could not parse arguments")); /* Set signal handling and alarm */ if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) @@ -97,6 +97,7 @@ main (int argc, char **argv) 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) { printf (_("Could not open stderr for %s\n"), command_line); } diff --git a/plugins/popen.c b/plugins/popen.c index f05fe974..94ad583f 100644 --- a/plugins/popen.c +++ b/plugins/popen.c @@ -112,6 +112,7 @@ spopen (const char *cmdstring) /* there cannot be more args than characters */ argc = strlen (cmdstring) + 1; /* add 1 for NULL termination */ argv = malloc (sizeof(char*)*argc); + if (argv == NULL) { printf ("Could not malloc argv array in popen()\n"); return NULL; diff --git a/plugins/utils.c b/plugins/utils.c index 460ff824..1d7c0db6 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -73,6 +73,13 @@ usage3 (const char *msg, int arg) exit (STATE_UNKNOWN); } +void +usage4 (const char *msg) +{ + printf ("%s: %s\n", progname, msg); + print_usage(); + exit (STATE_UNKNOWN); +} void support (void) |