diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-04 07:42:24 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-04 07:42:24 +0000 |
commit | 55def28f6619ab0f9807a0195aa01da5d6ff1dc0 (patch) | |
tree | f0762811e1ff964e874d88bd4448b64213bcbd45 /plugins | |
parent | 04b3d4554b829531ee4859859e7dd25fe660bba8 (diff) | |
download | monitoring-plugins-55def28f6619ab0f9807a0195aa01da5d6ff1dc0.tar.gz |
markup for translation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@643 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_ldap.c | 4 | ||||
-rw-r--r-- | plugins/check_nagios.c | 162 | ||||
-rw-r--r-- | plugins/check_radius.c | 189 | ||||
-rw-r--r-- | plugins/check_udp.c | 182 | ||||
-rw-r--r-- | plugins/check_ups.c | 209 | ||||
-rw-r--r-- | plugins/negate.c | 147 |
6 files changed, 401 insertions, 492 deletions
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index f6e0fca0..2064dd3b 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c @@ -88,6 +88,10 @@ print_help () printf (_(UT_WARN_CRIT)); + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + + printf (_(UT_VERBOSE)); + printf (_(UT_SUPPORT)); } diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c index 64a828b9..7ae0ff85 100644 --- a/plugins/check_nagios.c +++ b/plugins/check_nagios.c @@ -1,40 +1,72 @@ /****************************************************************************** - * - * CHECK_NAGIOS.C - * - * Program: Nagios process plugin for Nagios - * License: GPL - * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) - * - * $Id$ - * - * License Information: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +******************************************************************************/ + +const char *progname = "check_nagios"; +const char *revision = "$Revision$"; +const char *copyright = "1999-2003"; +const char *email = "nagiosplug-devel@lists.sourceforge.net"; #include "common.h" #include "popen.h" #include "utils.h" -const char *progname = "check_nagios"; +void +print_usage (void) +{ + printf (_("\ +Usage: %s -F <status log file> -e <expire_minutes> -C <process_string>\n"), + progname); +} +void +print_help (void) +{ + print_revision (progname, revision); + + printf (_(COPYRIGHT), copyright, email); + + printf (_("\ +This plugin attempts to check the status of the Nagios process on the local\n\ +machine. The plugin will check to make sure the Nagios status log is no older\n\ +than the number of minutes specified by the <expire_minutes> option. It also\n\ +uses the /bin/ps command to check for a process matching whatever you specify\n\ +by the <process_string> argument.\n")); + + print_usage (); + + printf (_(UT_HELP_VRSN)); + + printf (_("\ +-F, --filename=FILE\n\ + Name of the log file to check\n\ +-e, --expires=INTEGER\n\ + Seconds aging afterwhich logfile is condsidered stale\n\ +-C, --command=STRING\n\ + Command to search for in process table\n")); + + printf (_("\ +Example:\n\ + ./check_nagios -e 5 \\\ + -F /usr/local/nagios/var/status.log \\\ + -C /usr/local/nagios/bin/nagios\n")); +} + int process_arguments (int, char **); -void print_usage (void); -void print_help (void); char *status_log = NULL; char *process_string = NULL; @@ -64,11 +96,11 @@ main (int argc, char **argv) int pos, cols; if (process_arguments (argc, argv) == ERROR) - usage ("Could not parse arguments\n"); + usage (_("Could not parse arguments\n")); /* Set signal handling and alarm */ if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) { - printf ("Cannot catch SIGALRM"); + printf (_("Cannot catch SIGALRM")); return STATE_UNKNOWN; } @@ -78,7 +110,7 @@ main (int argc, char **argv) /* open the status log */ fp = fopen (status_log, "r"); if (fp == NULL) { - printf ("Error: Cannot open status log for reading!\n"); + printf (_("Error: Cannot open status log for reading!\n")); return STATE_CRITICAL; } @@ -95,13 +127,13 @@ main (int argc, char **argv) /* run the command to check for the Nagios process.. */ child_process = spopen (PS_COMMAND); if (child_process == NULL) { - printf ("Could not open pipe: %s\n", PS_COMMAND); + printf (_("Could not open pipe: %s\n"), PS_COMMAND); return STATE_UNKNOWN; } child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); if (child_stderr == NULL) { - printf ("Could not open stderr for %s\n", PS_COMMAND); + printf (_("Could not open stderr for %s\n"), PS_COMMAND); } fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); @@ -116,7 +148,7 @@ main (int argc, char **argv) if (!strstr(procargs, argv[0]) && strstr(procargs, process_string)) { proc_entries++; if (verbose) - printf ("Found process: %s\n", procargs); + printf (_("Found process: %s\n"), procargs); } } } @@ -136,18 +168,18 @@ main (int argc, char **argv) alarm (0); if (proc_entries == 0) { - printf ("Could not locate a running Nagios process!\n"); + printf (_("Could not locate a running Nagios process!\n")); return STATE_CRITICAL; } result = STATE_OK; time (¤t_time); - if ((current_time - latest_entry_time) > (expire_minutes * 60)) + if ((int)(current_time - latest_entry_time) > (expire_minutes * 60)) result = STATE_WARNING; printf - ("Nagios %s: located %d process%s, status log updated %d second%s ago\n", + (_("Nagios %s: located %d process%s, status log updated %d second%s ago\n"), (result == STATE_OK) ? "ok" : "problem", proc_entries, (proc_entries == 1) ? "" : "es", (int) (current_time - latest_entry_time), @@ -186,7 +218,7 @@ process_arguments (int argc, char **argv) expire_minutes = atoi (argv[2]); else terminate (STATE_UNKNOWN, - "Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n", + _("Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n"), progname); process_string = argv[3]; return OK; @@ -200,7 +232,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); + printf (_("%s: Unknown argument: %c\n\n"), progname, optopt); print_usage (); exit (STATE_UNKNOWN); case 'h': /* help */ @@ -220,7 +252,7 @@ process_arguments (int argc, char **argv) expire_minutes = atoi (optarg); else terminate (STATE_UNKNOWN, - "Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n", + _("Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n"), progname); break; case 'v': @@ -232,56 +264,12 @@ process_arguments (int argc, char **argv) if (status_log == NULL) terminate (STATE_UNKNOWN, - "You must provide the status_log\nType '%s -h' for additional help\n", + _("You must provide the status_log\nType '%s -h' for additional help\n"), progname); else if (process_string == NULL) terminate (STATE_UNKNOWN, - "You must provide a process string\nType '%s -h' for additional help\n", + _("You must provide a process string\nType '%s -h' for additional help\n"), progname); return OK; } - - - - - -void -print_usage (void) -{ - printf - ("Usage: %s -F <status log file> -e <expire_minutes> -C <process_string>\n", - progname); -} - - - - - -void -print_help (void) -{ - print_revision (progname, "$Revision$"); - printf - ("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n" - "This plugin attempts to check the status of the Nagios process on the local\n" - "machine. The plugin will check to make sure the Nagios status log is no older\n" - "than the number of minutes specified by the <expire_minutes> option. It also\n" - "uses the /bin/ps command to check for a process matching whatever you specify\n" - "by the <process_string> argument.\n"); - print_usage (); - printf - ("\nOptions:\n" - "-F, --filename=FILE\n" - " Name of the log file to check\n" - "-e, --expires=INTEGER\n" - " Seconds aging afterwhich logfile is condsidered stale\n" - "-C, --command=STRING\n" - " Command to search for in process table\n" - "-h, --help\n" - " Print this help screen\n" - "-V, --version\n" - " Print version information\n\n" - "Example:\n" - " ./check_nagios -F /usr/local/nagios/var/status.log -e 5 -C /usr/local/nagios/bin/nagios\n"); -} diff --git a/plugins/check_radius.c b/plugins/check_radius.c index c71f3b4c..3aa5ae71 100644 --- a/plugins/check_radius.c +++ b/plugins/check_radius.c @@ -1,45 +1,60 @@ /****************************************************************************** - * - * Program: radius server check plugin for Nagios - * License: GPL - * - * License Information: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - * - *****************************************************************************/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + ******************************************************************************/ const char *progname = "check_radius"; -#define REVISION "$Revision$" -#define COPYRIGHT "1999-2001" -#define AUTHORS "Robert August Vincent II/Karl DeBisschop" -#define EMAIL "kdebisschop@users.sourceforge.net" -#define SUMMARY "Tests to see if a radius server is accepting connections.\n" - -#define OPTIONS "\ --H host -F config_file -u username -p password\'\ - [-P port] [-t timeout] [-r retries] [-e expect]" - -#define LONGOPTIONS "\ - -H, --hostname=HOST\n\ - Host name argument for servers using host headers (use numeric\n\ - address if possible to bypass DNS lookup).\n\ - -P, --port=INTEGER\n\ - Port number (default: %d)\n\ +const char *revision = "$Revision$"; +const char *copyright = "2000-2003"; +const char *email = "nagiosplug-devel@lists.sourceforge.net"; + +#include "config.h" +#include "common.h" +#include "utils.h" +#include <radiusclient.h> + +void +print_usage (void) +{ + printf ("\ +Usage: %s -H host -F config_file -u username -p password [-P port]\n\ + [-t timeout] [-r retries] [-e expect]\n", progname); + printf (_(UT_HLP_VRS), progname, progname); +} + +void +print_help (void) +{ + char *myport; + asprintf (&myport, "%d", PW_AUTH_UDP_PORT); + + print_revision (progname, revision); + + printf (_("Copyright (c) 1999 Robert August Vincent II\n")); + printf (_(COPYRIGHT), copyright, email); + + printf(_("Tests to see if a radius server is accepting connections.\n\n")); + + print_usage (); + + printf (_(UT_HELP_VRSN)); + + printf (_(UT_HOST_PORT), 'P', myport); + + printf (_("\ -u, --username=STRING\n\ The user to authenticate\n\ -p, --password=STRING\n\ @@ -49,48 +64,38 @@ const char *progname = "check_radius"; -e, --expect=STRING\n\ Response string to expect from the server\n\ -r, --retries=INTEGER\n\ - Number of times to retry a failed connection\n\ - -t, --timeout=INTEGER\n\ - Seconds before connection times out (default: %d)\n\ - -v, --verbose\n\ - Show details for command-line debugging (do not use with nagios server)\n\ - -h, --help\n\ - Print detailed help screen\n\ - -V, --version\n\ - Print version information\n" - -#define DESCRIPTION "\ + Number of times to retry a failed connection\n")); + + printf (_(UT_TIMEOUT), timeout_interval); + + printf (_("\n\ This plugin tests a radius server to see if it is accepting connections.\n\ \n\ The server to test must be specified in the invocation, as well as a user\n\ name and password. A configuration file may also be present. The format of\n\ -the configuration file is described in the radiusclient library sources.\n\ -\n\ +the configuration file is described in the radiusclient library sources.\n\n")); + + printf (_("\ The password option presents a substantial security issue because the\n\ password can be determined by careful watching of the command line in\n\ a process listing. This risk is exacerbated because nagios will\n\ run the plugin at regular prdictable intervals. Please be sure that\n\ the password used does not allow access to sensitive system resources,\n\ -otherwise compormise could occur.\n" - -#include "config.h" -#include "common.h" -#include "utils.h" -#include <radiusclient.h> +otherwise compormise could occur.\n")); + printf (_(UT_SUPPORT)); +} + int process_arguments (int, char **); -void print_usage (void); -void print_help (void); char *server = NULL; -int port = PW_AUTH_UDP_PORT; char *username = NULL; char *password = NULL; char *expect = NULL; char *config_file = NULL; +int port = PW_AUTH_UDP_PORT; int retries = 1; int verbose = FALSE; - ENV *env = NULL; /****************************************************************************** @@ -151,23 +156,23 @@ main (int argc, char **argv) { UINT4 service; char msg[BUFFER_LEN]; - SEND_DATA data = { 0 }; + SEND_DATA data; int result; UINT4 client_id; if (process_arguments (argc, argv) == ERROR) - usage ("Could not parse arguments\n"); + usage (_("Could not parse arguments\n")); if ((config_file && rc_read_config (config_file)) || rc_read_dictionary (rc_conf_str ("dictionary"))) - terminate (STATE_UNKNOWN, "Config file error"); + terminate (STATE_UNKNOWN, _("Config file error")); service = PW_AUTHENTICATE_ONLY; if (!(rc_avpair_add (&data.send_pairs, PW_SERVICE_TYPE, &service, 0) && rc_avpair_add (&data.send_pairs, PW_USER_NAME, username, 0) && rc_avpair_add (&data.send_pairs, PW_USER_PASSWORD, password, 0))) - terminate (STATE_UNKNOWN, "Out of Memory?"); + terminate (STATE_UNKNOWN, _("Out of Memory?")); /* * Fill in NAS-IP-Address @@ -188,15 +193,15 @@ main (int argc, char **argv) rc_avpair_free (data.receive_pairs); if (result == TIMEOUT_RC) - terminate (STATE_CRITICAL, "Timeout"); + terminate (STATE_CRITICAL, _("Timeout")); if (result == ERROR_RC) - terminate (STATE_CRITICAL, "Auth Error"); + terminate (STATE_CRITICAL, _("Auth Error")); if (result == BADRESP_RC) - terminate (STATE_WARNING, "Auth Failed"); + terminate (STATE_WARNING, _("Auth Failed")); if (expect && !strstr (msg, expect)) terminate (STATE_WARNING, msg); if (result == OK_RC) - terminate (STATE_OK, "Auth OK"); + terminate (STATE_OK, _("Auth OK")); return (0); } @@ -234,16 +239,16 @@ process_arguments (int argc, char **argv) if (is_intpos (argv[4])) timeout_interval = atoi (argv[4]); else - usage ("Timeout interval must be a positive integer"); + usage (_("Timeout interval must be a positive integer")); if (is_intpos (argv[5])) retries = atoi (argv[5]); else - usage ("Number of retries must be a positive integer"); + usage (_("Number of retries must be a positive integer")); server = argv[6]; if (is_intpos (argv[7])) port = atoi (argv[7]); else - usage ("Server port must be a positive integer"); + usage (_("Server port must be a positive integer")); expect = argv[8]; return OK; } @@ -257,21 +262,21 @@ 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); + printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); print_usage (); exit (STATE_UNKNOWN); case 'h': /* help */ print_help (); exit (OK); case 'V': /* version */ - print_revision (progname, "$Revision$"); + print_revision (progname, revision); exit (OK); case 'v': /* verbose mode */ verbose = TRUE; break; case 'H': /* hostname */ if (is_host (optarg) == FALSE) { - printf ("Invalid host name/address\n\n"); + printf (_("Invalid host name/address\n\n")); print_usage (); exit (STATE_UNKNOWN); } @@ -281,7 +286,7 @@ process_arguments (int argc, char **argv) if (is_intnonneg (optarg)) port = atoi (optarg); else - usage ("Server port must be a positive integer"); + usage (_("Server port must be a positive integer")); break; case 'u': /* username */ username = optarg; @@ -299,41 +304,15 @@ process_arguments (int argc, char **argv) if (is_intpos (optarg)) retries = atoi (optarg); else - usage ("Number of retries must be a positive integer"); + usage (_("Number of retries must be a positive integer")); break; case 't': /* timeout */ if (is_intpos (optarg)) timeout_interval = atoi (optarg); else - usage ("Timeout interval must be a positive integer"); + usage (_("Timeout interval must be a positive integer")); break; } } return OK; } - - - -void -print_help (void) -{ - print_revision (progname, REVISION); - printf - ("Copyright (c) %s %s <%s>\n\n%s\n", - COPYRIGHT, AUTHORS, EMAIL, SUMMARY); - print_usage (); - printf - ("\nOptions:\n" LONGOPTIONS "\n" DESCRIPTION "\n", - port, timeout_interval); - support (); -} - - -void -print_usage (void) -{ - printf ("Usage:\n" " %s %s\n" - " %s (-h | --help) for detailed help\n" - " %s (-V | --version) for version information\n", - progname, OPTIONS, progname, progname); -} diff --git a/plugins/check_udp.c b/plugins/check_udp.c index da9a1420..3e903dfc 100644 --- a/plugins/check_udp.c +++ b/plugins/check_udp.c @@ -1,57 +1,84 @@ /****************************************************************************** -* -* CHECK_UDP.C -* -* Program: UDP port plugin for Nagios -* License: GPL -* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) -* -* Last Modified: $Date$ -* -* Command line: CHECK_UDP <host_address> [-p port] [-s send] [-e expect] \ -* [-wt warn_time] [-ct crit_time] [-to to_sec] -* -* Description: -* -* This plugin will attempt to connect to the specified port -* on the host. Successul connects return STATE_OK, refusals -* and timeouts return STATE_CRITICAL, other errors return -* STATE_UNKNOWN. -* -* License Information: -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -* + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *****************************************************************************/ -#include "config.h" +const char *progname = "check_udp"; +const char *revision = "$Revision$"; +const char *copyright = "1999-2002"; +const char *email = "nagiosplug-devel@lists.sourceforge.net"; + #include "common.h" #include "netutils.h" #include "utils.h" -const char *progname = "check_udp"; +/* Original Command line: + check_udp <host_address> [-p port] [-s send] [-e expect] \ + [-wt warn_time] [-ct crit_time] [-to to_sec] */ +void +print_usage (void) +{ + printf (_("\ +Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n\ + [-e expect] [-s send] [-t to_sec] [-v]\n"), progname); +} + +void +print_help (void) +{ + print_revision (progname, revision); + + printf (_("Copyright (c) 1999 Ethan Galstad\n")); + printf (_(COPYRIGHT), copyright, email); + + printf (_("\ +This plugin tests an UDP connection with the specified host.\n\n")); + + print_usage (); + + printf (_(UT_HELP_VRSN)); + + printf (_(UT_HOST_PORT), 'p', "none"); + + printf (_("\ + -e, --expect=STRING <optional>\n\ + String to expect in first line of server response\n\ + -s, --send=STRING <optional>\n\ + String to send to the server when initiating the connection\n")); + + printf (_(UT_WARN_CRIT)); + + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + + printf (_(UT_VERBOSE)); + + printf (_("\ +This plugin will attempt to connect to the specified port on the host.\n\ +Successful connects return STATE_OK, refusals and timeouts return\n\ +STATE_CRITICAL, other errors return STATE_UNKNOWN.\n\n")); + + printf(_(UT_SUPPORT)); +} + +int process_arguments (int, char **); int warning_time = 0; int check_warning_time = FALSE; int critical_time = 0; int check_critical_time = FALSE; - -int process_arguments (int, char **); -void print_usage (void); -void print_help (void); - int verbose = FALSE; int server_port = 0; char *server_address = NULL; @@ -104,8 +131,8 @@ main (int argc, char **argv) && (end_time - start_time) > warning_time) result = STATE_WARNING; - printf ("Connection %s on port %d - %d second response time\n", - (result == STATE_OK) ? "accepted" : "problem", server_port, + printf (_("Connection %s on port %d - %d second response time\n"), + (result == STATE_OK) ? _("accepted") : _("problem"), server_port, (int) (end_time - start_time)); } @@ -159,43 +186,43 @@ 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); + printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); print_usage (); exit (STATE_UNKNOWN); 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; break; case 'H': /* hostname */ if (is_host (optarg) == FALSE) - usage ("Invalid host name/address\n"); + usage (_("Invalid host name/address\n")); server_address = optarg; break; case 'c': /* critical */ if (!is_intnonneg (optarg)) - usage ("Critical threshold must be a nonnegative integer\n"); + usage (_("Critical threshold must be a nonnegative integer\n")); critical_time = atoi (optarg); check_critical_time = TRUE; break; case 'w': /* warning */ if (!is_intnonneg (optarg)) - usage ("Warning threshold must be a nonnegative integer\n"); + usage (_("Warning threshold must be a nonnegative integer\n")); warning_time = atoi (optarg); check_warning_time = TRUE; break; case 't': /* timeout */ if (!is_intnonneg (optarg)) - usage ("Timeout interval must be a nonnegative integer\n"); + usage (_("Timeout interval must be a nonnegative integer\n")); socket_timeout = atoi (optarg); break; case 'p': /* port */ if (!is_intnonneg (optarg)) - usage ("Serevr port must be a nonnegative integer\n"); + usage (_("Server port must be a nonnegative integer\n")); server_port = atoi (optarg); break; case 'e': /* expect */ @@ -210,61 +237,12 @@ process_arguments (int argc, char **argv) c = optind; if (server_address == NULL && c < argc && argv[c]) { if (is_host (argv[c]) == FALSE) - usage ("Invalid host name/address\n"); + usage (_("Invalid host name/address\n")); server_address = argv[c++]; } if (server_address == NULL) - usage ("Host name was not supplied\n"); + usage (_("Host name was not supplied\n")); return c; } - - - - - -void -print_usage (void) -{ - printf - ("Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n" - " [-e expect] [-s send] [-t to_sec] [-v]\n", progname); -} - - - - - -void -print_help (void) -{ - print_revision (progname, "$Revision$"); - printf - ("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n\n" - "This plugin tests an UDP connection with the specified host.\n\n"); - print_usage (); - printf - ("Options:\n" - " -H, --hostname=ADDRESS\n" - " Host name argument for servers using host headers (use numeric\n" - " address if possible to bypass DNS lookup).\n" - " -p, --port=INTEGER\n" - " Port number\n" - " -e, --expect=STRING <optional>\n" - " String to expect in first line of server response\n" - " -s, --send=STRING <optional>\n" - " String to send to the server when initiating the connection\n" - " -w, --warning=INTEGER <optional>\n" - " Response time to result in warning status (seconds)\n" - " -c, --critical=INTEGER <optional>\n" - " Response time to result in critical status (seconds)\n" - " -t, --timeout=INTEGER <optional>\n" - " Seconds before connection times out (default: %d)\n" - " -v, --verbose <optional>\n" - " Show details for command-line debugging (do not use with nagios server)\n" - " -h, --help\n" - " Print detailed help screen and exit\n" - " -V, --version\n" - " Print version information and exit\n", DEFAULT_SOCKET_TIMEOUT); -} diff --git a/plugins/check_ups.c b/plugins/check_ups.c index b077d31f..499b9222 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c @@ -1,70 +1,97 @@ /****************************************************************************** -* -* CHECK_UPS.C -* -* Program: UPS monitor plugin for Nagios -* License: GPL -* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) -* -* Last Modified: $Date$ -* -* Command line: CHECK_UPS <host_address> [-u ups] [-p port] [-v variable] \ -* [-wv warn_value] [-cv crit_value] [-to to_sec] -* -* Description: -* - -* This plugin attempts to determine the status of an UPS -* (Uninterruptible Power Supply) on a remote host (or the local host) -* that is being monitored with Russel Kroll's "Smarty UPS Tools" -* package. If the UPS is online or calibrating, the plugin will -* return an OK state. If the battery is on it will return a WARNING -* state. If the UPS is off or has a low battery the plugin will -* return a CRITICAL state. You may also specify a variable to check -* (such as temperature, utility voltage, battery load, etc.) as well -* as warning and critical thresholds for the value of that variable. -* If the remote host has multiple UPS that are being monitored you -* will have to use the [ups] option to specify which UPS to check. -* -* Notes: -* -* This plugin requires that the UPSD daemon distributed with Russel -* Kroll's "Smart UPS Tools" be installed on the remote host. If you -* don't have the package installed on your system, you can download -* it from http://www.exploits.org/nut -* -* License Information: -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -* + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + ******************************************************************************/ -#include "config.h" +const char *progname = "check_ups"; +const char *revision = "$Revision$"; +const char *copyright = "2000-2002"; +const char *email = "nagiosplug-devel@lists.sourceforge.net"; + #include "common.h" #include "netutils.h" #include "utils.h" -const char *progname = "check_ups"; -#define REVISION "$Revision$" -#define COPYRIGHT "1999-2002" -#define AUTHOR "Ethan Galstad" -#define EMAIL "nagios@nagios.org" +enum { + PORT = 3493 +}; + +void +print_usage (void) +{ + printf (_("\ +Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n\ + [-t timeout] [-v]\n"), progname); + printf (_(UT_HLP_VRS), progname, progname); +} + +void +print_help (void) +{ + char *myport; + asprintf (&myport, "%d", PORT); + + print_revision (progname, revision); + + printf (_("Copyright (c) 2000 Tom Shields")); + printf (_(COPYRIGHT), copyright, email); + + printf (_("This plugin tests the UPS service on the specified host.\n\ +Network UPS Tools from www.exploits.org must be running for this plugin to\n\ +work.\n\n")); + + print_usage (); + + printf (_(UT_HELP_VRSN)); + + printf (_(UT_HOST_PORT), 'p', myport); + + printf (_("\ + -u, --ups=STRING\n\ + Name of UPS\n")); + + printf (_(UT_WARN_CRIT)); -#define CHECK_NONE 0 + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); -#define PORT 3493 + printf (_(UT_VERBOSE)); + + printf (_("\ +This plugin attempts to determine the status of a UPS (Uninterruptible Power\n\ +Supply) on a local or remote host. If the UPS is online or calibrating, the\n\ +plugin will return an OK state. If the battery is on it will return a WARNING\n\ +state. If the UPS is off or has a low battery the plugin will return a CRITICAL\n\ +state.\n\n")); + + printf (_("\ +You may also specify a variable to check [such as temperature, utility voltage,\n\ +battery load, etc.] as well as warning and critical thresholds for the value of\n\ +that variable. If the remote host has multiple UPS that are being monitored you\n\ +will have to use the [ups] option to specify which UPS to check.\n\n")); + + printf (_("Notes:\n\n\ +This plugin requires that the UPSD daemon distributed with Russel Kroll's\n\ +Smart UPS Tools be installed on the remote host. If you do not have the\n\ +package installed on your system, you can download it from\n\ +http://www.exploits.org/nut\n\n")); + + printf (_(UT_SUPPORT)); +} + +#define CHECK_NONE 0 #define UPS_NONE 0 /* no supported options */ #define UPS_UTILITY 1 /* supports utility line voltage */ @@ -85,18 +112,18 @@ const char *progname = "check_ups"; int server_port = PORT; char *server_address = "127.0.0.1"; char *ups_name = NULL; -double warning_value = 0.0L; -double critical_value = 0.0L; +double warning_value = 0.0; +double critical_value = 0.0; int check_warning_value = FALSE; int check_critical_value = FALSE; int check_variable = UPS_NONE; int supported_options = UPS_NONE; int status = UPSSTATUS_NONE; -double ups_utility_voltage = 0.0L; -double ups_battery_percent = 0.0L; -double ups_load_percent = 0.0L; -double ups_temperature = 0.0L; +double ups_utility_voltage = 0.0; +double ups_battery_percent = 0.0; +double ups_load_percent = 0.0; +double ups_temperature = 0.0; char *ups_status = "N/A"; int determine_status (void); @@ -105,8 +132,6 @@ int get_ups_variable (const char *, char *, int); int process_arguments (int, char **); int validate_arguments (void); -void print_help (void); -void print_usage (void); int main (int argc, char **argv) @@ -115,7 +140,7 @@ main (int argc, char **argv) char *message; char temp_buffer[MAX_INPUT_BUFFER]; - double ups_utility_deviation = 0.0L; + double ups_utility_deviation = 0.0; if (process_arguments (argc, argv) != OK) usage ("Invalid command arguments supplied\n"); @@ -556,53 +581,3 @@ validate_arguments (void) { return OK; } - - - - - -void -print_help (void) -{ - print_revision (progname, "$Revision$"); - printf - ("Copyright (c) 2000 Tom Shields/Karl DeBisschop\n\n" - "This plugin tests the UPS service on the specified host.\n" - "Newtork UPS Tools for www.exploits.org must be running for this plugin to work.\n\n"); - print_usage (); - printf - ("\nOptions:\n" - " -H, --hostname=STRING or IPADDRESS\n" - " Check server on the indicated host\n" - " -p, --port=INTEGER\n" - " Make connection on the indicated port (default: %d)\n" - " -u, --ups=STRING\n" - " Name of UPS\n" - " -w, --warning=INTEGER\n" - " Seconds necessary to result in a warning status\n" - " -c, --critical=INTEGER\n" - " Seconds necessary to result in a critical status\n" - " -t, --timeout=INTEGER\n" - " Seconds before connection attempt times out (default: %d)\n" - " -v, --verbose\n" - " Print extra information (command-line use only)\n" - " -h, --help\n" - " Print detailed help screen\n" - " -V, --version\n" - " Print version information\n\n", PORT, DEFAULT_SOCKET_TIMEOUT); - support (); -} - - - - - -void -print_usage (void) -{ - printf - ("Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n" - " [-t timeout] [-v]\n" - " %s --help\n" - " %s --version\n", progname, progname, progname); -} diff --git a/plugins/negate.c b/plugins/negate.c index d1fcb5dd..faf81b34 100644 --- a/plugins/negate.c +++ b/plugins/negate.c @@ -1,68 +1,79 @@ /****************************************************************************** - * - * Program: Inverting plugin wrapper for Nagios - * License: GPL - * - * License Information: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - * - *****************************************************************************/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +******************************************************************************/ const char *progname = "negate"; -#define REVISION "$Revision$" -#define COPYRIGHT "2002" -#define AUTHOR "Karl DeBisschop" -#define EMAIL "kdebisschop@users.sourceforge.net" -#define SUMMARY "Negates the status of a plugin (returns OK for CRITICAL, and vice-versa).\n" +const char *revision = "$Revision$"; +const char *copyright = "2002-2003"; +const char *email = "nagiosplug-devel@lists.sourceforge.net"; + +#define DEFAULT_TIMEOUT 9 + +#include "common.h" +#include "utils.h" +#include "popen.h" + +void +print_usage (void) +{ + printf (_("Usage: %s [-t timeout] <definition of wrapped plugin>\n"), + progname); + printf (_(UT_HLP_VRS), progname, progname); +} + +void +print_help (void) +{ + print_revision (progname, revision); + + printf (_(COPYRIGHT), copyright, email); + + printf (_("\ +Negates the status of a plugin (returns OK for CRITICAL, and vice-versa).\n\ +\n")); + + print_usage (); -#define OPTIONS "\ -[-t timeout] <definition of wrapped plugin>" + printf (_(UT_HELP_VRSN)); -#define LONGOPTIONS "\ - -t, --timeout=INTEGER\n\ - Terminate test if timeout limit is exceeded (default: %d)\n\ - [keep this less than the plugin timeout to retain CRITICAL status]\n" + printf (_(UT_TIMEOUT), DEFAULT_TIMEOUT); -#define EXAMPLES "\ + printf (_("\ + [keep timeout than the plugin timeout to retain CRITICAL status]\n")); + + printf (_("\ negate \"/usr/local/nagios/libexec/check_ping -H host\"\n\ Run check_ping and invert result. Must use full path to plugin\n\ negate \"/usr/local/nagios/libexec/check_procs -a 'vi negate.c'\"\n\ - Use single quotes if you need to retain spaces\n" + Use single quotes if you need to retain spaces\n")); -#define DESCRIPTION "\ + printf (_("\ This plugin is a wrapper to take the output of another plugin and invert it.\n\ If the wrapped plugin returns STATE_OK, the wrapper will return STATE_CRITICAL.\n\ If the wrapped plugin returns STATE_CRITICAL, the wrapper will return STATE_OK.\n\ -Otherwise, the output state of the wrapped plugin is unchanged.\n" - -#define DEFAULT_TIMEOUT 9 - -#include "common.h" -#include "utils.h" -#include "popen.h" +Otherwise, the output state of the wrapped plugin is unchanged.\n")); + printf (_(UT_SUPPORT)); +} + char *command_line; int process_arguments (int, char **); int validate_arguments (void); -void print_usage (void); -void print_help (void); - /****************************************************************************** The (psuedo?)literate programming XML is contained within \@\@\- <XML> \-\@\@ @@ -123,21 +134,21 @@ main (int argc, char **argv) char input_buffer[MAX_INPUT_BUFFER]; if (process_arguments (argc, argv) == ERROR) - usage ("Could not parse arguments\n"); + usage (_("Could not parse arguments\n")); /* Set signal handling and alarm */ if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) - terminate (STATE_UNKNOWN, "Cannot catch SIGALRM"); + terminate (STATE_UNKNOWN, _("Cannot catch SIGALRM")); (void) alarm ((unsigned) timeout_interval); child_process = spopen (command_line); if (child_process == NULL) - terminate (STATE_UNKNOWN, "Could not open pipe: %s\n", command_line); + terminate (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); + printf (_("Could not open stderr for %s\n"), command_line); } while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { @@ -153,7 +164,7 @@ main (int argc, char **argv) if (!found) terminate (STATE_UNKNOWN,\ - "%s problem - No data recieved from host\nCMD: %s\n",\ + _("%s problem - No data recieved from host\nCMD: %s\n"),\ argv[0], command_line); /* close the pipe */ @@ -176,32 +187,6 @@ main (int argc, char **argv) - -void -print_help (void) -{ - print_revision (progname, REVISION); - printf - ("Copyright (c) %s %s <%s>\n\n%s\n", - COPYRIGHT, AUTHOR, EMAIL, SUMMARY); - print_usage (); - printf - ("\nOptions:\n" LONGOPTIONS "\n" "Examples:\n" EXAMPLES "\n" - DESCRIPTION "\n", DEFAULT_TIMEOUT); - support (); -} - -void -print_usage (void) -{ - printf ("Usage:\n" " %s %s\n" - " %s (-h | --help) for detailed help\n" - " %s (-V | --version) for version information\n", - progname, OPTIONS, progname, progname); -} - - - /****************************************************************************** @@- <sect3> @@ -240,16 +225,16 @@ process_arguments (int argc, char **argv) switch (c) { case '?': /* help */ - usage3 ("Unknown argument", optopt); + usage3 (_("Unknown argument"), optopt); case 'h': /* help */ print_help (); exit (EXIT_SUCCESS); case 'V': /* version */ - print_revision (progname, REVISION); + print_revision (progname, revision); exit (EXIT_SUCCESS); case 't': /* timeout period */ if (!is_integer (optarg)) - usage2 ("Timeout Interval must be an integer", optarg); + usage2 (_("Timeout Interval must be an integer"), optarg); timeout_interval = atoi (optarg); break; } |