summaryrefslogtreecommitdiffstats
path: root/plugins/negate.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-04 07:42:24 +0000
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-04 07:42:24 +0000
commit55def28f6619ab0f9807a0195aa01da5d6ff1dc0 (patch)
treef0762811e1ff964e874d88bd4448b64213bcbd45 /plugins/negate.c
parent04b3d4554b829531ee4859859e7dd25fe660bba8 (diff)
downloadmonitoring-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/negate.c')
-rw-r--r--plugins/negate.c147
1 files changed, 66 insertions, 81 deletions
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 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2
3 * Program: Inverting plugin wrapper for Nagios 3 This program is free software; you can redistribute it and/or modify
4 * License: GPL 4 it under the terms of the GNU General Public License as published by
5 * 5 the Free Software Foundation; either version 2 of the License, or
6 * License Information: 6 (at your option) any later version.
7 * 7
8 * This program is free software; you can redistribute it and/or modify 8 This program is distributed in the hope that it will be useful,
9 * it under the terms of the GNU General Public License as published by 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * the Free Software Foundation; either version 2 of the License, or 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * (at your option) any later version. 11 GNU General Public License for more details.
12 * 12
13 * This program is distributed in the hope that it will be useful, 13 You should have received a copy of the GNU General Public License
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 along with this program; if not, write to the Free Software
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 * GNU General Public License for more details. 16
17 * 17******************************************************************************/
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * $Id$
23 *
24 *****************************************************************************/
25 18
26const char *progname = "negate"; 19const char *progname = "negate";
27#define REVISION "$Revision$" 20const char *revision = "$Revision$";
28#define COPYRIGHT "2002" 21const char *copyright = "2002-2003";
29#define AUTHOR "Karl DeBisschop" 22const char *email = "nagiosplug-devel@lists.sourceforge.net";
30#define EMAIL "kdebisschop@users.sourceforge.net" 23
31#define SUMMARY "Negates the status of a plugin (returns OK for CRITICAL, and vice-versa).\n" 24#define DEFAULT_TIMEOUT 9
25
26#include "common.h"
27#include "utils.h"
28#include "popen.h"
29
30void
31print_usage (void)
32{
33 printf (_("Usage: %s [-t timeout] <definition of wrapped plugin>\n"),
34 progname);
35 printf (_(UT_HLP_VRS), progname, progname);
36}
37
38void
39print_help (void)
40{
41 print_revision (progname, revision);
42
43 printf (_(COPYRIGHT), copyright, email);
44
45 printf (_("\
46Negates the status of a plugin (returns OK for CRITICAL, and vice-versa).\n\
47\n"));
48
49 print_usage ();
32 50
33#define OPTIONS "\ 51 printf (_(UT_HELP_VRSN));
34[-t timeout] <definition of wrapped plugin>"
35 52
36#define LONGOPTIONS "\ 53 printf (_(UT_TIMEOUT), DEFAULT_TIMEOUT);
37 -t, --timeout=INTEGER\n\
38 Terminate test if timeout limit is exceeded (default: %d)\n\
39 [keep this less than the plugin timeout to retain CRITICAL status]\n"
40 54
41#define EXAMPLES "\ 55 printf (_("\
56 [keep timeout than the plugin timeout to retain CRITICAL status]\n"));
57
58 printf (_("\
42 negate \"/usr/local/nagios/libexec/check_ping -H host\"\n\ 59 negate \"/usr/local/nagios/libexec/check_ping -H host\"\n\
43 Run check_ping and invert result. Must use full path to plugin\n\ 60 Run check_ping and invert result. Must use full path to plugin\n\
44 negate \"/usr/local/nagios/libexec/check_procs -a 'vi negate.c'\"\n\ 61 negate \"/usr/local/nagios/libexec/check_procs -a 'vi negate.c'\"\n\
45 Use single quotes if you need to retain spaces\n" 62 Use single quotes if you need to retain spaces\n"));
46 63
47#define DESCRIPTION "\ 64 printf (_("\
48This plugin is a wrapper to take the output of another plugin and invert it.\n\ 65This plugin is a wrapper to take the output of another plugin and invert it.\n\
49If the wrapped plugin returns STATE_OK, the wrapper will return STATE_CRITICAL.\n\ 66If the wrapped plugin returns STATE_OK, the wrapper will return STATE_CRITICAL.\n\
50If the wrapped plugin returns STATE_CRITICAL, the wrapper will return STATE_OK.\n\ 67If the wrapped plugin returns STATE_CRITICAL, the wrapper will return STATE_OK.\n\
51Otherwise, the output state of the wrapped plugin is unchanged.\n" 68Otherwise, the output state of the wrapped plugin is unchanged.\n"));
52
53#define DEFAULT_TIMEOUT 9
54
55#include "common.h"
56#include "utils.h"
57#include "popen.h"
58 69
70 printf (_(UT_SUPPORT));
71}
72
59char *command_line; 73char *command_line;
60 74
61int process_arguments (int, char **); 75int process_arguments (int, char **);
62int validate_arguments (void); 76int validate_arguments (void);
63void print_usage (void);
64void print_help (void);
65
66/****************************************************************************** 77/******************************************************************************
67 78
68The (psuedo?)literate programming XML is contained within \@\@\- <XML> \-\@\@ 79The (psuedo?)literate programming XML is contained within \@\@\- <XML> \-\@\@
@@ -123,21 +134,21 @@ main (int argc, char **argv)
123 char input_buffer[MAX_INPUT_BUFFER]; 134 char input_buffer[MAX_INPUT_BUFFER];
124 135
125 if (process_arguments (argc, argv) == ERROR) 136 if (process_arguments (argc, argv) == ERROR)
126 usage ("Could not parse arguments\n"); 137 usage (_("Could not parse arguments\n"));
127 138
128 /* Set signal handling and alarm */ 139 /* Set signal handling and alarm */
129 if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) 140 if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR)
130 terminate (STATE_UNKNOWN, "Cannot catch SIGALRM"); 141 terminate (STATE_UNKNOWN, _("Cannot catch SIGALRM"));
131 142
132 (void) alarm ((unsigned) timeout_interval); 143 (void) alarm ((unsigned) timeout_interval);
133 144
134 child_process = spopen (command_line); 145 child_process = spopen (command_line);
135 if (child_process == NULL) 146 if (child_process == NULL)
136 terminate (STATE_UNKNOWN, "Could not open pipe: %s\n", command_line); 147 terminate (STATE_UNKNOWN, _("Could not open pipe: %s\n"), command_line);
137 148
138 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); 149 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
139 if (child_stderr == NULL) { 150 if (child_stderr == NULL) {
140 printf ("Could not open stderr for %s\n", command_line); 151 printf (_("Could not open stderr for %s\n"), command_line);
141 } 152 }
142 153
143 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { 154 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
@@ -153,7 +164,7 @@ main (int argc, char **argv)
153 164
154 if (!found) 165 if (!found)
155 terminate (STATE_UNKNOWN,\ 166 terminate (STATE_UNKNOWN,\
156 "%s problem - No data recieved from host\nCMD: %s\n",\ 167 _("%s problem - No data recieved from host\nCMD: %s\n"),\
157 argv[0], command_line); 168 argv[0], command_line);
158 169
159 /* close the pipe */ 170 /* close the pipe */
@@ -176,32 +187,6 @@ main (int argc, char **argv)
176 187
177 188
178 189
179
180void
181print_help (void)
182{
183 print_revision (progname, REVISION);
184 printf
185 ("Copyright (c) %s %s <%s>\n\n%s\n",
186 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
187 print_usage ();
188 printf
189 ("\nOptions:\n" LONGOPTIONS "\n" "Examples:\n" EXAMPLES "\n"
190 DESCRIPTION "\n", DEFAULT_TIMEOUT);
191 support ();
192}
193
194void
195print_usage (void)
196{
197 printf ("Usage:\n" " %s %s\n"
198 " %s (-h | --help) for detailed help\n"
199 " %s (-V | --version) for version information\n",
200 progname, OPTIONS, progname, progname);
201}
202
203
204
205/****************************************************************************** 190/******************************************************************************
206@@- 191@@-
207<sect3> 192<sect3>
@@ -240,16 +225,16 @@ process_arguments (int argc, char **argv)
240 225
241 switch (c) { 226 switch (c) {
242 case '?': /* help */ 227 case '?': /* help */
243 usage3 ("Unknown argument", optopt); 228 usage3 (_("Unknown argument"), optopt);
244 case 'h': /* help */ 229 case 'h': /* help */
245 print_help (); 230 print_help ();
246 exit (EXIT_SUCCESS); 231 exit (EXIT_SUCCESS);
247 case 'V': /* version */ 232 case 'V': /* version */
248 print_revision (progname, REVISION); 233 print_revision (progname, revision);
249 exit (EXIT_SUCCESS); 234 exit (EXIT_SUCCESS);
250 case 't': /* timeout period */ 235 case 't': /* timeout period */
251 if (!is_integer (optarg)) 236 if (!is_integer (optarg))
252 usage2 ("Timeout Interval must be an integer", optarg); 237 usage2 (_("Timeout Interval must be an integer"), optarg);
253 timeout_interval = atoi (optarg); 238 timeout_interval = atoi (optarg);
254 break; 239 break;
255 } 240 }