summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-07-30 04:07:53 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-07-30 04:07:53 (GMT)
commitccead7695f4c31401283b95547e9f9703a4c43f2 (patch)
tree56bbdd9ee3f9ee81ad16ee3e8c012851ed159852 /plugins
parent1cb0499adcc043515c2b62bbf62dc4d6b10f8cc9 (diff)
downloadmonitoring-plugins-ccead7695f4c31401283b95547e9f9703a4c43f2.tar.gz
markup for translation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@620 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_dig.c183
-rw-r--r--plugins/check_pgsql.c13
-rw-r--r--plugins/check_swap.c24
-rw-r--r--plugins/check_tcp.c4
-rw-r--r--plugins/utils.h10
5 files changed, 135 insertions, 99 deletions
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index 6e04087..a22a68a 100644
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
@@ -16,45 +16,75 @@
16* 16*
17*****************************************************************************/ 17*****************************************************************************/
18 18
19#include "config.h"
20#include "common.h"
21#include "netutils.h"
22#include "utils.h"
23#include "popen.h"
24
25int process_arguments (int, char **);
26int validate_arguments (void);
27void print_help (void);
28void print_usage (void);
29
19const char *progname = "check_dig"; 30const char *progname = "check_dig";
20const char *revision = "$Revision$"; 31const char *revision = "$Revision$";
21const char *copyright = "2002-2003"; 32const char *copyright = "2002-2003";
22const char *authors = "Nagios Plugin Development Team";
23const char *email = "nagiosplug-devel@lists.sourceforge.net"; 33const char *email = "nagiosplug-devel@lists.sourceforge.net";
24 34
25const char *summary = "Test the DNS service on the specified host using dig\n"; 35enum {
36 DEFAULT_PORT = 53
37};
38
39void
40print_usage (void)
41{
42 printf (_("\
43Usage: %s -H host -l lookup [-p <server port>] [-w <warning interval>]\n\
44 [-c <critical interval>] [-t <timeout>] [-v]\n"),
45 progname);
46 printf (" %s (-h|--help)\n", progname);
47 printf (" %s (-V|--version)\n", progname);
48}
49
50void
51print_help (void)
52{
53 char *myport;
54
55 asprintf (&myport, "%d", DEFAULT_PORT);
56
57 print_revision (progname, revision);
26 58
27const char *option_summary = "-H host -l lookup [-t timeout] [-v]"; 59 printf (_(COPYRIGHT), copyright, email);
28 60
29const char *options = "\ 61 printf (_("Test the DNS service on the specified host using dig\n\n"));
30 -H, --hostname=STRING or IPADDRESS\n\ 62
31 Check server on the indicated host\n\ 63 print_usage ();
64
65 printf (_(HELP_VRSN));
66
67 printf (_(HOST_PORT), 'P', myport);
68
69 printf (_("\
32 -l, --lookup=STRING\n\ 70 -l, --lookup=STRING\n\
33 machine name to lookup\n\ 71 machine name to lookup\n"));
34 -t, --timeout=INTEGER\n\
35 Seconds before connection attempt times out (default: %d)\n\
36 -v, --verbose\n\
37 Print extra information (command-line use only)\n";
38
39const char *standard_options = "\
40 -h, --help\n\
41 Print detailed help screen\n\
42 -V, --version\n\
43 Print version information\n\n";
44 72
45#include "config.h" 73 printf (_(WARN_CRIT_TO), DEFAULT_SOCKET_TIMEOUT);
46#include "common.h"
47#include "utils.h"
48#include "popen.h"
49 74
50int process_arguments (int, char **); 75 printf (_(VRBS));
51int validate_arguments (void); 76
52void print_help (void); 77 support ();
53void print_usage (void); 78}
79
54 80
55char *query_address = NULL; 81char *query_address = NULL;
56char *dns_server = NULL; 82char *dns_server = NULL;
57int verbose = FALSE; 83int verbose = FALSE;
84int server_port = DEFAULT_PORT;
85int warning_interval = -1;
86int critical_interval = -1;
87
58 88
59int 89int
60main (int argc, char **argv) 90main (int argc, char **argv)
@@ -66,13 +96,14 @@ main (int argc, char **argv)
66 96
67 /* Set signal handling and alarm */ 97 /* Set signal handling and alarm */
68 if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) 98 if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR)
69 usage ("Cannot catch SIGALRM\n"); 99 usage (_("Cannot catch SIGALRM\n"));
70 100
71 if (process_arguments (argc, argv) != OK) 101 if (process_arguments (argc, argv) != OK)
72 usage ("Could not parse arguments\n"); 102 usage (_("Could not parse arguments\n"));
73 103
74 /* get the command to run */ 104 /* get the command to run */
75 asprintf (&command_line, "%s @%s %s", PATH_TO_DIG, dns_server, query_address); 105 asprintf (&command_line, "%s @%s -p %d %s",
106 PATH_TO_DIG, dns_server, server_port, query_address);
76 107
77 alarm (timeout_interval); 108 alarm (timeout_interval);
78 time (&start_time); 109 time (&start_time);
@@ -82,13 +113,13 @@ main (int argc, char **argv)
82 /* run the command */ 113 /* run the command */
83 child_process = spopen (command_line); 114 child_process = spopen (command_line);
84 if (child_process == NULL) { 115 if (child_process == NULL) {
85 printf ("Could not open pipe: %s\n", command_line); 116 printf (_("Could not open pipe: %s\n"), command_line);
86 return STATE_UNKNOWN; 117 return STATE_UNKNOWN;
87 } 118 }
88 119
89 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); 120 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
90 if (child_stderr == NULL) 121 if (child_stderr == NULL)
91 printf ("Could not open stderr for %s\n", command_line); 122 printf (_("Could not open stderr for %s\n"), command_line);
92 123
93 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { 124 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
94 125
@@ -107,7 +138,7 @@ main (int argc, char **argv)
107 result = STATE_OK; 138 result = STATE_OK;
108 } 139 }
109 else { 140 else {
110 asprintf (&output, "Server not found in ANSWER SECTION"); 141 asprintf (&output, _("Server not found in ANSWER SECTION"));
111 result = STATE_WARNING; 142 result = STATE_WARNING;
112 } 143 }
113 144
@@ -117,7 +148,7 @@ main (int argc, char **argv)
117 } 148 }
118 149
119 if (result != STATE_OK) { 150 if (result != STATE_OK) {
120 asprintf (&output, "No ANSWER SECTION found"); 151 asprintf (&output, _("No ANSWER SECTION found"));
121 } 152 }
122 153
123 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { 154 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
@@ -134,23 +165,23 @@ main (int argc, char **argv)
134 if (spclose (child_process)) { 165 if (spclose (child_process)) {
135 result = max_state (result, STATE_WARNING); 166 result = max_state (result, STATE_WARNING);
136 if (strlen (output) == 0) 167 if (strlen (output) == 0)
137 asprintf (&output, "dig returned error status"); 168 asprintf (&output, _("dig returned error status"));
138 } 169 }
139 170
140 (void) time (&end_time); 171 (void) time (&end_time);
141 172
142 if (output == NULL || strlen (output) == 0) 173 if (output == NULL || strlen (output) == 0)
143 asprintf (&output, " Probably a non-existent host/domain"); 174 asprintf (&output, _(" Probably a non-existent host/domain"));
144 175
145 if (result == STATE_OK) 176 if (result == STATE_OK)
146 printf ("DNS OK - %d seconds response time (%s)\n", 177 printf (_("DNS OK - %d seconds response time (%s)\n"),
147 (int) (end_time - start_time), output); 178 (int) (end_time - start_time), output);
148 else if (result == STATE_WARNING) 179 else if (result == STATE_WARNING)
149 printf ("DNS WARNING - %s\n", output); 180 printf (_("DNS WARNING - %s\n"), output);
150 else if (result == STATE_CRITICAL) 181 else if (result == STATE_CRITICAL)
151 printf ("DNS CRITICAL - %s\n", output); 182 printf (_("DNS CRITICAL - %s\n"), output);
152 else 183 else
153 printf ("DNS problem - %s\n", output); 184 printf (_("DNS problem - %s\n"), output);
154 185
155 return result; 186 return result;
156} 187}
@@ -182,35 +213,59 @@ process_arguments (int argc, char **argv)
182 213
183 switch (c) { 214 switch (c) {
184 case '?': /* help */ 215 case '?': /* help */
185 usage3 ("Unknown argument", optopt); 216 usage3 (_("Unknown argument"), optopt);
217 case 'h': /* help */
218 print_help ();
219 exit (STATE_OK);
220 case 'V': /* version */
221 print_revision (progname, "$Revision$");
222 exit (STATE_OK);
186 case 'H': /* hostname */ 223 case 'H': /* hostname */
187 if (is_host (optarg)) { 224 if (is_host (optarg)) {
188 dns_server = optarg; 225 dns_server = optarg;
189 } 226 }
190 else { 227 else {
191 usage ("Invalid host name\n"); 228 usage2 (_("Invalid host name"), optarg);
229 }
230 break;
231 case 'p':
232 if (is_intpos (optarg)) {
233 server_port = atoi (optarg);
234 }
235 else {
236 usage2 (_("Server port must be a nonnegative integer\n"), optarg);
192 } 237 }
193 break; 238 break;
194 case 'l': /* username */ 239 case 'l': /* username */
195 query_address = optarg; 240 query_address = optarg;
196 break; 241 break;
197 case 'v': /* verbose */ 242 case 'w': /* timeout */
198 verbose = TRUE; 243 if (is_intnonneg (optarg)) {
244 warning_interval = atoi (optarg);
245 }
246 else {
247 usage2 (_("Warning interval must be a nonnegative integer\n"), optarg);
248 }
249 break;
250 case 'c': /* timeout */
251 if (is_intnonneg (optarg)) {
252 critical_interval = atoi (optarg);
253 }
254 else {
255 usage2 (_("Critical interval must be a nonnegative integer\n"), optarg);
256 }
199 break; 257 break;
200 case 't': /* timeout */ 258 case 't': /* timeout */
201 if (is_intnonneg (optarg)) { 259 if (is_intnonneg (optarg)) {
202 timeout_interval = atoi (optarg); 260 timeout_interval = atoi (optarg);
203 } 261 }
204 else { 262 else {
205 usage ("Time interval must be a nonnegative integer\n"); 263 usage2 (_("Time interval must be a nonnegative integer\n"), optarg);
206 } 264 }
207 break; 265 break;
208 case 'V': /* version */ 266 case 'v': /* verbose */
209 print_revision (progname, "$Revision$"); 267 verbose = TRUE;
210 exit (STATE_OK); 268 break;
211 case 'h': /* help */
212 print_help ();
213 exit (STATE_OK);
214 } 269 }
215 } 270 }
216 271
@@ -221,7 +276,7 @@ process_arguments (int argc, char **argv)
221 dns_server = argv[c]; 276 dns_server = argv[c];
222 } 277 }
223 else { 278 else {
224 usage ("Invalid host name"); 279 usage2 (_("Invalid host name"), argv[c]);
225 } 280 }
226 } 281 }
227 else { 282 else {
@@ -242,31 +297,3 @@ validate_arguments (void)
242 return OK; 297 return OK;
243} 298}
244 299
245
246
247
248
249void
250print_help (void)
251{
252 print_revision (progname, revision);
253 printf ("Copyright (c) %s %s\n\t<%s>\n\n", copyright, authors, email);
254 printf (summary);
255 print_usage ();
256 printf ("\nOptions:\n");
257 printf (options, DEFAULT_SOCKET_TIMEOUT);
258 printf (standard_options);
259 support ();
260}
261
262
263
264
265
266void
267print_usage (void)
268{
269 printf ("Usage: %s %s\n", progname, option_summary);
270 printf (" %s (-h|--help)\n", progname);
271 printf (" %s (-V|--version)\n", progname);
272}
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index b532d68..2d2f6d3 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -29,8 +29,7 @@
29enum { 29enum {
30 DEFAULT_PORT = 5432, 30 DEFAULT_PORT = 5432,
31 DEFAULT_WARN = 2, 31 DEFAULT_WARN = 2,
32 DEFAULT_CRIT = 8, 32 DEFAULT_CRIT = 8
33 DEFAULT_TIMEOUT = 30
34}; 33};
35 34
36#include "config.h" 35#include "config.h"
@@ -125,6 +124,10 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
125void 124void
126print_help (void) 125print_help (void)
127{ 126{
127 char *myport;
128
129 asprintf (&myport, "%d", DEFAULT_PORT);
130
128 print_revision (progname, revision); 131 print_revision (progname, revision);
129 132
130 printf (_(COPYRIGHT), copyright, email); 133 printf (_(COPYRIGHT), copyright, email);
@@ -135,7 +138,9 @@ print_help (void)
135 138
136 printf (_(HELP_VRSN)); 139 printf (_(HELP_VRSN));
137 140
138 printf (_(HOST_PORT_46), 'P', "5432"); 141 printf (_(HOST_PORT), 'P', myport);
142
143 printf (_(IPv46));
139 144
140 printf (S_("\ 145 printf (S_("\
141 -d, --database=STRING\n\ 146 -d, --database=STRING\n\
@@ -143,7 +148,7 @@ print_help (void)
143 -l, --logname = STRING\n\ 148 -l, --logname = STRING\n\
144 Login name of user\n\ 149 Login name of user\n\
145 -p, --password = STRING\n\ 150 -p, --password = STRING\n\
146 Password (BIG SECURITY ISSUE)\n\n"), DEFAULT_DB); 151 Password (BIG SECURITY ISSUE)\n"), DEFAULT_DB);
147 152
148 printf (_(WARN_CRIT_TO), DEFAULT_SOCKET_TIMEOUT); 153 printf (_(WARN_CRIT_TO), DEFAULT_SOCKET_TIMEOUT);
149 154
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 5edb806..6dd2e08 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -124,7 +124,7 @@ main (int argc, char **argv)
124 char *status = ""; 124 char *status = "";
125 125
126 if (process_arguments (argc, argv) != OK) 126 if (process_arguments (argc, argv) != OK)
127 usage ("Invalid command arguments supplied\n"); 127 usage (_("Invalid command arguments supplied\n"));
128 128
129#ifdef HAVE_PROC_MEMINFO 129#ifdef HAVE_PROC_MEMINFO
130 fp = fopen (PROC_MEMINFO, "r"); 130 fp = fopen (PROC_MEMINFO, "r");
@@ -147,19 +147,19 @@ main (int argc, char **argv)
147 } 147 }
148 148
149 if (verbose >= 2) 149 if (verbose >= 2)
150 printf ("Command: %s\n", swap_command); 150 printf (_("Command: %s\n"), swap_command);
151 if (verbose >= 3) 151 if (verbose >= 3)
152 printf ("Format: %s\n", swap_format); 152 printf ("_(Format: %s\n"), swap_format);
153 153
154 child_process = spopen (swap_command); 154 child_process = spopen (swap_command);
155 if (child_process == NULL) { 155 if (child_process == NULL) {
156 printf ("Could not open pipe: %s\n", swap_command); 156 printf (_("Could not open pipe: %s\n"), swap_command);
157 return STATE_UNKNOWN; 157 return STATE_UNKNOWN;
158 } 158 }
159 159
160 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); 160 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
161 if (child_stderr == NULL) 161 if (child_stderr == NULL)
162 printf ("Could not open stderr for %s\n", swap_command); 162 printf (_("Could not open stderr for %s\n"), swap_command);
163 163
164 sprintf (str, "%s", ""); 164 sprintf (str, "%s", "");
165 /* read 1st line */ 165 /* read 1st line */
@@ -189,7 +189,7 @@ main (int argc, char **argv)
189 dsktotal = dsktotal / conv_factor; 189 dsktotal = dsktotal / conv_factor;
190 dskfree = dskfree / conv_factor; 190 dskfree = dskfree / conv_factor;
191 if (verbose >= 3) 191 if (verbose >= 3)
192 printf ("total=%d, free=%d\n", dsktotal, dskfree); 192 printf (_("total=%d, free=%d\n"), dsktotal, dskfree);
193 193
194 dskused = dsktotal - dskfree; 194 dskused = dsktotal - dskfree;
195#endif 195#endif
@@ -206,7 +206,7 @@ main (int argc, char **argv)
206 } 206 }
207 percent_used = 100 * ((double) used_swap) / ((double) total_swap); 207 percent_used = 100 * ((double) used_swap) / ((double) total_swap);
208 result = max_state (result, check_swap (percent_used, free_swap)); 208 result = max_state (result, check_swap (percent_used, free_swap));
209 asprintf (&status, " %d%% free (%lu MB out of %lu MB)%s", 209 asprintf (&status, _(" %d%% free (%lu MB out of %lu MB)%s"),
210 (100 - percent_used), free_swap, total_swap, status); 210 (100 - percent_used), free_swap, total_swap, status);
211 211
212#ifdef HAVE_PROC_MEMINFO 212#ifdef HAVE_PROC_MEMINFO
@@ -294,7 +294,7 @@ process_arguments (int argc, char **argv)
294 break; 294 break;
295 } 295 }
296 else { 296 else {
297 usage ("Warning threshold must be integer or percentage!\n"); 297 usage (_("Warning threshold must be integer or percentage!\n"));
298 } 298 }
299 wc++; 299 wc++;
300 case 'c': /* critical time threshold */ 300 case 'c': /* critical time threshold */
@@ -312,7 +312,7 @@ process_arguments (int argc, char **argv)
312 break; 312 break;
313 } 313 }
314 else { 314 else {
315 usage ("Critical threshold must be integer or percentage!\n"); 315 usage (_("Critical threshold must be integer or percentage!\n"));
316 } 316 }
317 cc++; 317 cc++;
318 case 'a': /* all swap */ 318 case 'a': /* all swap */
@@ -328,7 +328,7 @@ process_arguments (int argc, char **argv)
328 print_help (); 328 print_help ();
329 exit (STATE_OK); 329 exit (STATE_OK);
330 case '?': /* help */ 330 case '?': /* help */
331 usage ("Invalid argument\n"); 331 usage (_("Invalid argument\n"));
332 } 332 }
333 } 333 }
334 334
@@ -369,11 +369,11 @@ validate_arguments (void)
369 } 369 }
370 else if (warn_percent < crit_percent) { 370 else if (warn_percent < crit_percent) {
371 usage 371 usage
372 ("Warning percentage should be more than critical percentage\n"); 372 (_("Warning percentage should be more than critical percentage\n"));
373 } 373 }
374 else if (warn_size < crit_size) { 374 else if (warn_size < crit_size) {
375 usage 375 usage
376 ("Warning free space should be more than critical free space\n"); 376 (_("Warning free space should be more than critical free space\n"));
377 } 377 }
378 return OK; 378 return OK;
379} 379}
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index eb31774..39f9022 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -118,7 +118,9 @@ print_help (void)
118 118
119 printf (_(HELP_VRSN)); 119 printf (_(HELP_VRSN));
120 120
121 printf (_(HOST_PORT_46), 'p', "none"); 121 printf (_(HOST_PORT), 'p', "none");
122
123 printf (_(IPv46));
122 124
123 printf (_("\ 125 printf (_("\
124 -s, --send=STRING\n\ 126 -s, --send=STRING\n\
diff --git a/plugins/utils.h b/plugins/utils.h
index 292c3df..8a6ffa1 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -99,11 +99,13 @@ char *state_text (int result);
99 -V, --version\n\ 99 -V, --version\n\
100 Print version information\n" 100 Print version information\n"
101 101
102#define HOST_PORT_46 "\ 102#define HOST_PORT "\
103 -H, --hostname=ADDRESS\n\ 103 -H, --hostname=ADDRESS\n\
104 Host name or IP Address%s\n\ 104 Host name or IP Address\n\
105 -%c, --port=INTEGER\n\ 105 -%c, --port=INTEGER\n\
106 Port number (default: %s)\n\ 106 Port number (default: %s)\n"
107
108#define IPv46 "\
107 -4, --use-ipv4\n\ 109 -4, --use-ipv4\n\
108 Use IPv4 connection\n\ 110 Use IPv4 connection\n\
109 -6, --use-ipv6\n\ 111 -6, --use-ipv6\n\
@@ -119,4 +121,4 @@ char *state_text (int result);
119 -c, --critical=DOUBLE\n\ 121 -c, --critical=DOUBLE\n\
120 Response time to result in critical status (seconds)\n\ 122 Response time to result in critical status (seconds)\n\
121 -t, --timeout=INTEGER\n\ 123 -t, --timeout=INTEGER\n\
122 Seconds before connection times out (default: %s)\n" 124 Seconds before connection times out (default: %d)\n"