summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: df1bd0c)
raw | patch | inline | side by side (parent: df1bd0c)
author | Benoit Mortier <opensides@users.sourceforge.net> | |
Thu, 2 Dec 2004 16:51:25 +0000 (16:51 +0000) | ||
committer | Benoit Mortier <opensides@users.sourceforge.net> | |
Thu, 2 Dec 2004 16:51:25 +0000 (16:51 +0000) |
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
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@979 f882894a-f735-0410-b71e-b25c423dba1c
34 files changed:
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 20ae62833a53e88ffc85baddbcad38d36861120d..f569731de9acb5e3b7896b3ec2f5c449744e91b0 100644 (file)
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
/* 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 14c0da5a56e3516b3e6316a869dc9da1c9216bec..0102ea566e6ae16c2d46d6a5e62af670dda6585c 100644 (file)
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
/* 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 0cab9ac51b047727f82028a646edc8c393fb4ebb..c7ea3441e3a1f3c48b264ebaf9fd1bf607fad893 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
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 d64431a8f9435753157fc70aea99a4420ea9b052..070223e7d70b973bb9d0ffc0134fa8522c74caef 100644 (file)
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
/* 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 74236d9b7d9c6d6dda6af2b2fbe25019de4887dd..817d647aa4aa14757a49647b13a657cf4f0d2e49 100644 (file)
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
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 c8492d8f172aa846eedbbb17cdc7bad73492fe67..89c212e854bd85c1c4df75b6c8000b781523c973 100644 (file)
--- a/plugins/check_game.c
+++ b/plugins/check_game.c
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;
{
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 5fdfc8ac3c59e0ffed631fc001f58aa7595dc783..7c56e5dc3d7207d4199b4a64872b6f1bb950aeb3 100644 (file)
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
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 e962e024de0ff09f8d351ad4eae04ad54b8bee94..93bff45310706fd2783a38ba367a8bd791391145 100644 (file)
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
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 07b89acbf946dc314cbcc453ad33c6daa203ac00..9c41cc302cfdca9007052890bc65e8fda09484ab 100644 (file)
--- a/plugins/check_ldap.c
+++ b/plugins/check_ldap.c
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 8322dbb3bb092c0a38ad94c697c8565a01b123d1..b918fa54a79ef234f966a4ac0e297756801a5d17 100644 (file)
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
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 58717bffe8547194d603d35b1dfb802db99e3ab5..31d132d443758ac3335542b3271279fb4f58a93a 100644 (file)
--- a/plugins/check_mrtg.c
+++ b/plugins/check_mrtg.c
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");
index 5bbce5007e7796e04287baa882f40bdf41246a03..24ccaa9326b3a61930152f65529526f96cecded4 100644 (file)
--- a/plugins/check_mrtgtraf.c
+++ b/plugins/check_mrtgtraf.c
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)) {
/* 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 0564f7c8c97196c61146cfb90c6351f45dd0b100..f55630b2c38d1a772ce406f84af5e0e4cd08f72a 100644 (file)
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
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 7c36d116b8be3c5e30491699d0ed1be54f2e7f3b..618ee57313a086938ea3b1f4d021ba9584ca2def 100644 (file)
--- a/plugins/check_nagios.c
+++ b/plugins/check_nagios.c
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 c7fc74596948d94ab76c24885fc3637ecea6f639..efd7cdef0b619ccd249224143f04c15da037e500 100644 (file)
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
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 a6d2e249c4373d709260d186337df7e3c5d523bb..ce5773b9dbbdb87c770bee6e4464516004d7143c 100644 (file)
--- a/plugins/check_nwstat.c
+++ b/plugins/check_nwstat.c
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 cb85dc66a3b646611751df5fa5a6ad05b28afb42..22277f6eefc903d3dfd80e818fc6b5d59b298628 100644 (file)
--- a/plugins/check_overcr.c
+++ b/plugins/check_overcr.c
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 5c3b81074402875a945889433b0adad9987d6cae..f9d66110328cbbd0f39c4c9634e045ed504288c8 100644 (file)
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
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 6d8ef06d567d6d1a4dbc9a1e1c42a2d747657016..ecaf03ed4a2573cd04cf47363b8b7948ae7c3168 100644 (file)
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
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 d1e1b7c57a1bd8554abdaa23e075e3dc8bbf75b2..4bc87c0a63493f89b67b8fdab60eac8f787fbf77 100644 (file)
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
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 405b417b1e0a9d0c846a820cfd2753fb096f4d97..68ed4d88f3e25d4b721dba79550e627926d3be86 100644 (file)
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
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 9a8f42a005766f1d67654a2f912b3ace93354c88..4ede6a5c32f9dc839caa63f1a1917bc47b688f37 100644 (file)
--- a/plugins/check_real.c
+++ b/plugins/check_real.c
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 3322494847c92ee5811f6c236d1b8e4010698e85..257a38bba8d2926fa7878b6dc294887edcb746d5 100644 (file)
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
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 c7dff3d21f2f6b824c8aeee27620065323111b89..6a41c6af095e582a7004833f600ca932d1b3cc4b 100644 (file)
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
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 f9bbd1227b379c1fbb37bc390e220f12ac52f56a..82d0acad57f02f1d251775dd148b97e1369dd04e 100644 (file)
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
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 f2d722ce91afc82da6f2af3724a86da952b44eef..608080acb6f0ab856977c47b739f3c867be08dc3 100644 (file)
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
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 ed51e94ad560d62cdb60cf079bbd076186258228..af3c7206fdc3c63c45ae5304846a7b5f186df33b 100644 (file)
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
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) {
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 042a7d5a5541e466c874f260159d7db029d31cac..ee6ff43865c6484fd1f6e9c0722a18567c980d1e 100644 (file)
--- a/plugins/check_time.c
+++ b/plugins/check_time.c
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 fb7cae1aee7e6644b645405b5c941b071d969570..5d671745791fe3348cbc6ec0f90692c06e6c9137 100644 (file)
--- a/plugins/check_udp.c
+++ b/plugins/check_udp.c
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 4006031f183f3ddd98f94da01935f5527a50bef6..e974b7534576799b3e1c7045b84359ba35843ca9 100644 (file)
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
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 23f8973cd6a2b4dcccf650a68571f1ae8b78a48f..891fe3b78e17c4af1e40a4754b40406b214be9c5 100644 (file)
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
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 02838a67f5a2cf6602ee2e7d909c03b360c8ef5a..9e25ebc57a5e0b4c8292ff4bdcafd71871732e2f 100644 (file)
--- a/plugins/negate.c
+++ b/plugins/negate.c
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)
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 f05fe974efa2d30d4552ba3ac642ee58ad10283c..94ad583f78770dfac294e5ee3b91376c0b2b3fc4 100644 (file)
--- a/plugins/popen.c
+++ b/plugins/popen.c
/* 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 460ff824a1fa7acae0426e412489abbf4265b704..1d7c0db668ad1e53251fced58be2d4226e886103 100644 (file)
--- a/plugins/utils.c
+++ b/plugins/utils.c
exit (STATE_UNKNOWN);
}
+void
+usage4 (const char *msg)
+{
+ printf ("%s: %s\n", progname, msg);
+ print_usage();
+ exit (STATE_UNKNOWN);
+}
void
support (void)