summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-03 06:19:51 +0000
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-03 06:19:51 +0000
commit52f987d585d8c568f891a1cf59bb6a9477dd5b25 (patch)
tree7965cb4c8efd39632f0717a0caac9512187094d4 /plugins
parent59d594d7d3e2897a105365ef5ffa0cdb972c09ac (diff)
downloadmonitoring-plugins-52f987d585d8c568f891a1cf59bb6a9477dd5b25.tar.gz
markup for translation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@641 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_load.c134
1 files changed, 62 insertions, 72 deletions
diff --git a/plugins/check_load.c b/plugins/check_load.c
index ba1a5983..06334450 100644
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
@@ -24,9 +24,46 @@
24 * 24 *
25 *****************************************************************************/ 25 *****************************************************************************/
26 26
27#include "config.h" 27const char *progname = "check_load";
28const char *revision = "$Revision$";
29const char *copyright = "1999-2003";
30const char *email = "nagiosplug-devel@lists.sourceforge.net";
31
28#include "common.h" 32#include "common.h"
29#include "utils.h" 33#include "utils.h"
34#include "popen.h"
35
36void
37print_usage (void)
38{
39 printf (_("Usage: %s -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15\n"),
40 progname);
41 printf (_(UT_HLP_VRS), progname, progname);
42}
43
44void
45print_help (void)
46{
47 print_revision (progname, revision);
48
49 printf (_("Copyright (c) 1999 Felipe Gustavo de Almeida <galmeida@linux.ime.usp.br>\n"));
50 printf (_(COPYRIGHT), copyright, email);
51
52 printf (_("This plugin tests the current system load average.\n\n"));
53
54 print_usage ();
55
56 printf (_(UT_HELP_VRSN));
57
58 printf (_("\
59 -w, --warning=WLOAD1,WLOAD5,WLOAD15\n\
60 Exit with WARNING status if load average exceeds WLOADn\n\
61 -c, --critical=CLOAD1,CLOAD5,CLOAD15\n\
62 Exit with CRITICAL status if load average exceed CLOADn\n\n\
63the load average format is the same used by \"uptime\" and \"w\"\n\n"));
64
65 printf (_(UT_SUPPORT));
66}
30 67
31#ifdef HAVE_SYS_LOADAVG_H 68#ifdef HAVE_SYS_LOADAVG_H
32#include <sys/loadavg.h> 69#include <sys/loadavg.h>
@@ -39,17 +76,9 @@
39#define LOADAVG_15MIN 2 76#define LOADAVG_15MIN 2
40#endif /* !defined LOADAVG_1MIN */ 77#endif /* !defined LOADAVG_1MIN */
41 78
42#include "popen.h"
43#ifdef HAVE_PROC_LOADAVG
44
45#endif
46
47const char *progname = "check_load";
48 79
49int process_arguments (int argc, char **argv); 80int process_arguments (int argc, char **argv);
50int validate_arguments (void); 81int validate_arguments (void);
51void print_usage (void);
52void print_help (void);
53 82
54float wload1 = -1, wload5 = -1, wload15 = -1; 83float wload1 = -1, wload5 = -1, wload15 = -1;
55float cload1 = -1, cload5 = -1, cload15 = -1; 84float cload1 = -1, cload5 = -1, cload15 = -1;
@@ -86,7 +115,7 @@ main (int argc, char **argv)
86#elif HAVE_PROC_LOADAVG==1 115#elif HAVE_PROC_LOADAVG==1
87 fp = fopen (PROC_LOADAVG, "r"); 116 fp = fopen (PROC_LOADAVG, "r");
88 if (fp == NULL) { 117 if (fp == NULL) {
89 printf ("Error opening %s\n", PROC_LOADAVG); 118 printf (_("Error opening %s\n"), PROC_LOADAVG);
90 return STATE_UNKNOWN; 119 return STATE_UNKNOWN;
91 } 120 }
92 121
@@ -105,43 +134,43 @@ main (int argc, char **argv)
105#else 134#else
106 child_process = spopen (PATH_TO_UPTIME); 135 child_process = spopen (PATH_TO_UPTIME);
107 if (child_process == NULL) { 136 if (child_process == NULL) {
108 printf ("Error opening %s\n", PATH_TO_UPTIME); 137 printf (_("Error opening %s\n"), PATH_TO_UPTIME);
109 return STATE_UNKNOWN; 138 return STATE_UNKNOWN;
110 } 139 }
111 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); 140 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
112 if (child_stderr == NULL) { 141 if (child_stderr == NULL) {
113 printf ("Could not open stderr for %s\n", PATH_TO_UPTIME); 142 printf (_("Could not open stderr for %s\n"), PATH_TO_UPTIME);
114 } 143 }
115 fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); 144 fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process);
116 sscanf (input_buffer, "%*[^l]load average: %f, %f, %f", &la1, &la5, &la15); 145 sscanf (input_buffer, "%*[^l]load average: %f, %f, %f"), &la1, &la5, &la15);
117 146
118 result = spclose (child_process); 147 result = spclose (child_process);
119 if (result) { 148 if (result) {
120 printf ("Error code %d returned in %s\n", result, PATH_TO_UPTIME); 149 printf (_("Error code %d returned in %s\n"), result, PATH_TO_UPTIME);
121 return STATE_UNKNOWN; 150 return STATE_UNKNOWN;
122 } 151 }
123#endif 152#endif
124 153
125 if ((la1 == -1) || (la5 == -1) || (la15 == -1)) { 154 if ((la1 == -1) || (la5 == -1) || (la15 == -1)) {
126#if HAVE_GETLOADAVG==1 155#if HAVE_GETLOADAVG==1
127 printf ("Error in getloadavg()\n"); 156 printf (_("Error in getloadavg()\n"));
128#elif HAVE_PROC_LOADAVG==1 157#elif HAVE_PROC_LOADAVG==1
129 printf ("Error processing %s\n", PROC_LOADAVG); 158 printf (_("Error processing %s\n"), PROC_LOADAVG);
130#else 159#else
131 printf ("Error processing %s\n", PATH_TO_UPTIME); 160 printf (_("Error processing %s\n"), PATH_TO_UPTIME);
132#endif 161#endif
133 return STATE_UNKNOWN; 162 return STATE_UNKNOWN;
134 } 163 }
135 asprintf(&status_line, "load average: %.2f, %.2f, %.2f", la1, la5, la15); 164 asprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15);
136 if ((la1 >= cload1) || (la5 >= cload5) || (la15 >= cload15)) { 165 if ((la1 >= cload1) || (la5 >= cload5) || (la15 >= cload15)) {
137 printf("CRITICAL - %s\n", status_line); 166 printf(_("CRITICAL - %s\n"), status_line);
138 return STATE_CRITICAL; 167 return STATE_CRITICAL;
139 } 168 }
140 if ((la1 >= wload1) || (la5 >= wload5) || (la15 >= wload15)) { 169 if ((la1 >= wload1) || (la5 >= wload5) || (la15 >= wload15)) {
141 printf ("WARNING - %s\n", status_line); 170 printf (_("WARNING - %s\n"), status_line);
142 return STATE_WARNING; 171 return STATE_WARNING;
143 } 172 }
144 printf ("OK - %s\n", status_line); 173 printf (_("OK - %s\n"), status_line);
145 return STATE_OK; 174 return STATE_OK;
146} 175}
147 176
@@ -188,7 +217,7 @@ process_arguments (int argc, char **argv)
188 sscanf (optarg, "%f:%f:%f", &wload1, &wload5, &wload15) == 3) 217 sscanf (optarg, "%f:%f:%f", &wload1, &wload5, &wload15) == 3)
189 break; 218 break;
190 else 219 else
191 usage ("Warning threshold must be float or float triplet!\n"); 220 usage (_("Warning threshold must be float or float triplet!\n"));
192 break; 221 break;
193 case 'c': /* critical time threshold */ 222 case 'c': /* critical time threshold */
194 if (is_intnonneg (optarg)) { 223 if (is_intnonneg (optarg)) {
@@ -204,7 +233,7 @@ process_arguments (int argc, char **argv)
204 sscanf (optarg, "%f:%f:%f", &cload1, &cload5, &cload15) == 3) 233 sscanf (optarg, "%f:%f:%f", &cload1, &cload5, &cload15) == 3)
205 break; 234 break;
206 else 235 else
207 usage ("Critical threshold must be float or float triplet!\n"); 236 usage (_("Critical threshold must be float or float triplet!\n"));
208 break; 237 break;
209 case 'V': /* version */ 238 case 'V': /* version */
210 print_revision (progname, "$Revision$"); 239 print_revision (progname, "$Revision$");
@@ -213,7 +242,7 @@ process_arguments (int argc, char **argv)
213 print_help (); 242 print_help ();
214 exit (STATE_OK); 243 exit (STATE_OK);
215 case '?': /* help */ 244 case '?': /* help */
216 usage ("Invalid argument\n"); 245 usage (_("Invalid argument\n"));
217 } 246 }
218 } 247 }
219 248
@@ -259,61 +288,22 @@ int
259validate_arguments (void) 288validate_arguments (void)
260{ 289{
261 if (wload1 < 0) 290 if (wload1 < 0)
262 usage ("Warning threshold for 1-minute load average is not specified\n"); 291 usage (_("Warning threshold for 1-minute load average is not specified\n"));
263 if (wload5 < 0) 292 if (wload5 < 0)
264 usage ("Warning threshold for 5-minute load average is not specified\n"); 293 usage (_("Warning threshold for 5-minute load average is not specified\n"));
265 if (wload15 < 0) 294 if (wload15 < 0)
266 usage ("Warning threshold for 15-minute load average is not specified\n"); 295 usage (_("Warning threshold for 15-minute load average is not specified\n"));
267 if (cload1 < 0) 296 if (cload1 < 0)
268 usage ("Critical threshold for 1-minute load average is not specified\n"); 297 usage (_("Critical threshold for 1-minute load average is not specified\n"));
269 if (cload5 < 0) 298 if (cload5 < 0)
270 usage ("Critical threshold for 5-minute load average is not specified\n"); 299 usage (_("Critical threshold for 5-minute load average is not specified\n"));
271 if (cload15 < 0) 300 if (cload15 < 0)
272 usage ("Critical threshold for 15-minute load average is not specified\n"); 301 usage (_("Critical threshold for 15-minute load average is not specified\n"));
273 if (wload1 > cload1) 302 if (wload1 > cload1)
274 usage ("Parameter inconsistency: 1-minute \"warning load\" greater than \"critical load\".\n"); 303 usage (_("Parameter inconsistency: 1-minute \"warning load\" greater than \"critical load\".\n"));
275 if (wload5 > cload5) 304 if (wload5 > cload5)
276 usage ("Parameter inconsistency: 5-minute \"warning load\" greater than \"critical load\".\n"); 305 usage (_("Parameter inconsistency: 5-minute \"warning load\" greater than \"critical load\".\n"));
277 if (wload15 > cload15) 306 if (wload15 > cload15)
278 usage ("Parameter inconsistency: 15-minute \"warning load\" greater than \"critical load\".\n"); 307 usage (_("Parameter inconsistency: 15-minute \"warning load\" greater than \"critical load\".\n"));
279 return OK; 308 return OK;
280} 309}
281
282
283
284
285
286void
287print_usage (void)
288{
289 printf
290 ("Usage: check_load -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15\n"
291 " check_load --version\n" " check_load --help\n");
292}
293
294
295
296
297
298void
299print_help (void)
300{
301 print_revision (progname, "$Revision$");
302 printf
303 ("Copyright (c) 1999 Felipe Gustavo de Almeida <galmeida@linux.ime.usp.br>\n"
304 "Copyright (c) 2000 Karl DeBisschop\n\n"
305 "This plugin tests the current system load average.\n\n");
306 print_usage ();
307 printf
308 ("\nOptions:\n"
309 " -w, --warning=WLOAD1,WLOAD5,WLOAD15\n"
310 " Exit with WARNING status if load average exceeds WLOADn\n"
311 " -c, --critical=CLOAD1,CLOAD5,CLOAD15\n"
312 " Exit with CRITICAL status if load average exceed CLOADn\n"
313 " -h, --help\n"
314 " Print detailed help screen\n"
315 " -V, --version\n"
316 " Print version information\n\n"
317 "the load average format is the same used by \"uptime\" and \"w\"\n\n");
318 support ();
319}