diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-03 14:24:33 (GMT) |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-03 14:24:33 (GMT) |
commit | 04b3d4554b829531ee4859859e7dd25fe660bba8 (patch) | |
tree | ad89b04ac227fc814e30925de6cb0a99a2e41397 /plugins/check_mrtg.c | |
parent | 52f987d585d8c568f891a1cf59bb6a9477dd5b25 (diff) | |
download | monitoring-plugins-04b3d4554b829531ee4859859e7dd25fe660bba8.tar.gz |
markup for translation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@642 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_mrtg.c')
-rw-r--r-- | plugins/check_mrtg.c | 162 |
1 files changed, 74 insertions, 88 deletions
diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c index 095dcbc..88c8e49 100644 --- a/plugins/check_mrtg.c +++ b/plugins/check_mrtg.c | |||
@@ -1,43 +1,57 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | |
3 | * Program: MRTG (Multi-Router Traffic Grapher) generic plugin 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 | ||
26 | const char *progname = "check_mrtg"; | 19 | const char *progname = "check_mrtg"; |
27 | #define REVISION "$Revision$" | 20 | const char *revision = "$Revision$"; |
28 | #define COPYRIGHT "Copyright (c) 1999-2001 Ethan Galstad" | 21 | const char *copyright = "1999-2001"; |
22 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | ||
29 | 23 | ||
30 | #define SUMMARY "\ | 24 | #include "common.h" |
31 | This plugin will check either the average or maximum value of one of the\n\ | 25 | #include "utils.h" |
32 | two variables recorded in an MRTG log file.\n" | ||
33 | 26 | ||
34 | /* old command line: | 27 | /* original command line: |
35 | <log_file> <expire_minutes> <AVG|MAX> <variable> <vwl> <vcl> <label> [units] */ | 28 | <log_file> <expire_minutes> <AVG|MAX> <variable> <vwl> <vcl> <label> [units] */ |
36 | #define OPTIONS "\ | ||
37 | -F log_file -a <AVG | MAX> -v variable -w warning -c critical\n\ | ||
38 | [-l label] [-u units] [-e expire_minutes] [-t timeout] [-v]" | ||
39 | 29 | ||
40 | #define LONGOPTIONS "\ | 30 | void |
31 | print_usage (void) | ||
32 | { | ||
33 | printf (_("\ | ||
34 | Usage: %s -F log_file -a <AVG | MAX> -v variable -w warning -c critical\n\ | ||
35 | [-l label] [-u units] [-e expire_minutes] [-t timeout] [-v]\n"), progname); | ||
36 | printf (_(UT_HLP_VRS), progname, progname); | ||
37 | } | ||
38 | |||
39 | void | ||
40 | print_help (void) | ||
41 | { | ||
42 | print_revision (progname, revision); | ||
43 | |||
44 | printf (_(COPYRIGHT), copyright, email); | ||
45 | |||
46 | printf(_("\ | ||
47 | This plugin will check either the average or maximum value of one of the\n\ | ||
48 | two variables recorded in an MRTG log file.\n")); | ||
49 | |||
50 | print_usage (); | ||
51 | |||
52 | printf (_(UT_HELP_VRSN)); | ||
53 | |||
54 | printf (_("\ | ||
41 | -F, --logfile=FILE\n\ | 55 | -F, --logfile=FILE\n\ |
42 | The MRTG log file containing the data you want to monitor\n\ | 56 | The MRTG log file containing the data you want to monitor\n\ |
43 | -e, --expires=MINUTES\n\ | 57 | -e, --expires=MINUTES\n\ |
@@ -45,50 +59,45 @@ two variables recorded in an MRTG log file.\n" | |||
45 | -a, --aggregation=AVG|MAX\n\ | 59 | -a, --aggregation=AVG|MAX\n\ |
46 | Should we check average or maximum values?\n\ | 60 | Should we check average or maximum values?\n\ |
47 | -v, --variable=INTEGER\n\ | 61 | -v, --variable=INTEGER\n\ |
48 | Which variable set should we inspect? 1 or 2?\n\ | 62 | Which variable set should we inspect? (1 or 2)\n\ |
49 | -w, --warning=INTEGER\n\ | 63 | -w, --warning=INTEGER\n\ |
50 | Threshold value for data to result in WARNING status\n\ | 64 | Threshold value for data to result in WARNING status\n\ |
51 | -c, --critical=INTEGER\n\ | 65 | -c, --critical=INTEGER\n\ |
52 | Threshold value for data to result in CRITICAL status\n\ | 66 | Threshold value for data to result in CRITICAL status\n")); |
67 | |||
68 | printf (_("\ | ||
53 | -l, --label=STRING\n\ | 69 | -l, --label=STRING\n\ |
54 | Type label for data (Examples: Conns, \"Processor Load\", In, Out)\n\ | 70 | Type label for data (Examples: Conns, \"Processor Load\", In, Out)\n\ |
55 | -u, --units=STRING\n\ | 71 | -u, --units=STRING\n\ |
56 | Option units label for data (Example: Packets/Sec, Errors/Sec, \n\ | 72 | Option units label for data (Example: Packets/Sec, Errors/Sec, \n\ |
57 | \"Bytes Per Second\", \"%% Utilization\")\n\ | 73 | \"Bytes Per Second\", \"%% Utilization\")\n")); |
58 | -h, --help\n\ | ||
59 | Print detailed help screen\n\ | ||
60 | -V, --version\n\ | ||
61 | Print version information\n" | ||
62 | 74 | ||
63 | #define DESCRIPTION "\ | 75 | printf (_("\ |
64 | If the value exceeds the <vwl> threshold, a WARNING status is returned. If\n\ | 76 | If the value exceeds the <vwl> threshold, a WARNING status is returned. If\n\ |
65 | the value exceeds the <vcl> threshold, a CRITICAL status is returned. If\n\ | 77 | the value exceeds the <vcl> threshold, a CRITICAL status is returned. If\n\ |
66 | the data in the log file is older than <expire_minutes> old, a WARNING\n\ | 78 | the data in the log file is older than <expire_minutes> old, a WARNING\n\ |
67 | status is returned and a warning message is printed.\n\ | 79 | status is returned and a warning message is printed.\n\n")); |
68 | \n\ | 80 | |
69 | This plugin is useful for monitoring MRTG data that does not correspond to\n\ | 81 | printf(_("This plugin is useful for monitoring MRTG data that does not correspond to\n\ |
70 | bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth).\n\ | 82 | bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth).\n\ |
71 | It can be used to monitor any kind of data that MRTG is monitoring - errors,\n\ | 83 | It can be used to monitor any kind of data that MRTG is monitoring - errors,\n\ |
72 | packets/sec, etc. I use MRTG in conjuction with the Novell NLM that allows\n\ | 84 | packets/sec, etc. I use MRTG in conjuction with the Novell NLM that allows\n\ |
73 | me to track processor utilization, user connections, drive space, etc and\n\ | 85 | me to track processor utilization, user connections, drive space, etc and\n\ |
74 | this plugin works well for monitoring that kind of data as well.\n\ | 86 | this plugin works well for monitoring that kind of data as well.\n\n")); |
75 | \n\ | 87 | |
76 | Notes:\n\ | 88 | printf (_("Notes:\n\ |
77 | - This plugin only monitors one of the two variables stored in the MRTG log\n\ | 89 | - This plugin only monitors one of the two variables stored in the MRTG log\n\ |
78 | file. If you want to monitor both values you will have to define two\n\ | 90 | file. If you want to monitor both values you will have to define two\n\ |
79 | commands with different values for the <variable> argument. Of course,\n\ | 91 | commands with different values for the <variable> argument. Of course,\n\ |
80 | you can always hack the code to make this plugin work for you...\n\ | 92 | you can always hack the code to make this plugin work for you...\n\ |
81 | - MRTG stands for the Multi Router Traffic Grapher. It can be downloaded from\n\ | 93 | - MRTG stands for the Multi Router Traffic Grapher. It can be downloaded from\n\ |
82 | http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html\n" | 94 | http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html\n")); |
83 | 95 | ||
84 | #include "config.h" | 96 | printf (_(UT_SUPPORT)); |
85 | #include "common.h" | 97 | } |
86 | #include "utils.h" | ||
87 | 98 | ||
88 | int process_arguments (int, char **); | 99 | int process_arguments (int, char **); |
89 | int validate_arguments (void); | 100 | int validate_arguments (void); |
90 | void print_help (void); | ||
91 | void print_usage (void); | ||
92 | 101 | ||
93 | char *log_file = NULL; | 102 | char *log_file = NULL; |
94 | int expire_minutes = 0; | 103 | int expire_minutes = 0; |
@@ -115,12 +124,12 @@ main (int argc, char **argv) | |||
115 | unsigned long value_rate = 0L; | 124 | unsigned long value_rate = 0L; |
116 | 125 | ||
117 | if (process_arguments (argc, argv) != OK) | 126 | if (process_arguments (argc, argv) != OK) |
118 | usage ("Invalid command arguments supplied\n"); | 127 | usage (_("Invalid command arguments supplied\n")); |
119 | 128 | ||
120 | /* open the MRTG log file for reading */ | 129 | /* open the MRTG log file for reading */ |
121 | fp = fopen (log_file, "r"); | 130 | fp = fopen (log_file, "r"); |
122 | if (fp == NULL) { | 131 | if (fp == NULL) { |
123 | printf ("Unable to open MRTG log file\n"); | 132 | printf (_("Unable to open MRTG log file\n")); |
124 | return STATE_UNKNOWN; | 133 | return STATE_UNKNOWN; |
125 | } | 134 | } |
126 | 135 | ||
@@ -168,7 +177,7 @@ main (int argc, char **argv) | |||
168 | /* if we couldn't read enough data, return an unknown error */ | 177 | /* if we couldn't read enough data, return an unknown error */ |
169 | if (line <= 2) { | 178 | if (line <= 2) { |
170 | result = STATE_UNKNOWN; | 179 | result = STATE_UNKNOWN; |
171 | sprintf (error_message, "Unable to process MRTG log file\n"); | 180 | sprintf (error_message, _("Unable to process MRTG log file\n")); |
172 | } | 181 | } |
173 | 182 | ||
174 | /* make sure the MRTG data isn't too old */ | 183 | /* make sure the MRTG data isn't too old */ |
@@ -177,7 +186,7 @@ main (int argc, char **argv) | |||
177 | if (expire_minutes > 0 | 186 | if (expire_minutes > 0 |
178 | && (current_time - timestamp) > (expire_minutes * 60)) { | 187 | && (current_time - timestamp) > (expire_minutes * 60)) { |
179 | result = STATE_WARNING; | 188 | result = STATE_WARNING; |
180 | sprintf (error_message, "MRTG data has expired (%d minutes old)\n", | 189 | sprintf (error_message, _("MRTG data has expired (%d minutes old)\n"), |
181 | (int) ((current_time - timestamp) / 60)); | 190 | (int) ((current_time - timestamp) / 60)); |
182 | } | 191 | } |
183 | } | 192 | } |
@@ -197,17 +206,13 @@ main (int argc, char **argv) | |||
197 | } | 206 | } |
198 | 207 | ||
199 | sprintf (error_message, "%s. %s = %lu %s", | 208 | sprintf (error_message, "%s. %s = %lu %s", |
200 | (use_average == TRUE) ? "Ave" : "Max", value_label, value_rate, | 209 | (use_average == TRUE) ? _("Ave") : _("Max"), value_label, value_rate, |
201 | units_label); | 210 | units_label); |
202 | printf ("%s\n", error_message); | 211 | printf ("%s\n", error_message); |
203 | 212 | ||
204 | return result; | 213 | return result; |
205 | } | 214 | } |
206 | 215 | ||
207 | |||
208 | |||
209 | |||
210 | |||
211 | /* process command-line arguments */ | 216 | /* process command-line arguments */ |
212 | int | 217 | int |
213 | process_arguments (int argc, char **argv) | 218 | process_arguments (int argc, char **argv) |
@@ -265,7 +270,7 @@ process_arguments (int argc, char **argv) | |||
265 | case 'v': | 270 | case 'v': |
266 | variable_number = atoi (optarg); | 271 | variable_number = atoi (optarg); |
267 | if (variable_number < 1 || variable_number > 2) | 272 | if (variable_number < 1 || variable_number > 2) |
268 | usage ("Invalid variable number\n"); | 273 | usage (_("Invalid variable number\n")); |
269 | break; | 274 | break; |
270 | case 'w': /* critical time threshold */ | 275 | case 'w': /* critical time threshold */ |
271 | value_warning_threshold = strtoul (optarg, NULL, 10); | 276 | value_warning_threshold = strtoul (optarg, NULL, 10); |
@@ -280,13 +285,13 @@ process_arguments (int argc, char **argv) | |||
280 | units_label = optarg; | 285 | units_label = optarg; |
281 | break; | 286 | break; |
282 | case 'V': /* version */ | 287 | case 'V': /* version */ |
283 | print_revision (progname, REVISION); | 288 | print_revision (progname, revision); |
284 | exit (STATE_OK); | 289 | exit (STATE_OK); |
285 | case 'h': /* help */ | 290 | case 'h': /* help */ |
286 | print_help (); | 291 | print_help (); |
287 | exit (STATE_OK); | 292 | exit (STATE_OK); |
288 | case '?': /* help */ | 293 | case '?': /* help */ |
289 | usage ("Invalid argument\n"); | 294 | usage (_("Invalid argument\n")); |
290 | } | 295 | } |
291 | } | 296 | } |
292 | 297 | ||
@@ -300,7 +305,7 @@ process_arguments (int argc, char **argv) | |||
300 | expire_minutes = atoi (argv[c++]); | 305 | expire_minutes = atoi (argv[c++]); |
301 | else | 306 | else |
302 | terminate (STATE_UNKNOWN, | 307 | terminate (STATE_UNKNOWN, |
303 | "%s is not a valid expiration time\nUse '%s -h' for additional help\n", | 308 | _("%s is not a valid expiration time\nUse '%s -h' for additional help\n"), |
304 | argv[c], progname); | 309 | argv[c], progname); |
305 | } | 310 | } |
306 | 311 | ||
@@ -317,7 +322,7 @@ process_arguments (int argc, char **argv) | |||
317 | variable_number = atoi (argv[c++]); | 322 | variable_number = atoi (argv[c++]); |
318 | if (variable_number < 1 || variable_number > 2) { | 323 | if (variable_number < 1 || variable_number > 2) { |
319 | printf ("%s :", argv[c]); | 324 | printf ("%s :", argv[c]); |
320 | usage ("Invalid variable number\n"); | 325 | usage (_("Invalid variable number\n")); |
321 | } | 326 | } |
322 | } | 327 | } |
323 | 328 | ||
@@ -344,26 +349,7 @@ int | |||
344 | validate_arguments (void) | 349 | validate_arguments (void) |
345 | { | 350 | { |
346 | if (variable_number == -1) | 351 | if (variable_number == -1) |
347 | usage ("You must supply the variable number\n"); | 352 | usage (_("You must supply the variable number\n")); |
348 | 353 | ||
349 | return OK; | 354 | return OK; |
350 | } | 355 | } |
351 | |||
352 | void | ||
353 | print_help (void) | ||
354 | { | ||
355 | print_revision (progname, REVISION); | ||
356 | printf ("%s\n\n%s\n", COPYRIGHT, SUMMARY); | ||
357 | print_usage (); | ||
358 | printf ("\nOptions:\n" LONGOPTIONS "\n" DESCRIPTION "\n"); | ||
359 | support (); | ||
360 | } | ||
361 | |||
362 | void | ||
363 | print_usage (void) | ||
364 | { | ||
365 | printf ("Usage:\n" " %s %s\n" | ||
366 | " %s (-h | --help) for detailed help\n" | ||
367 | " %s (-V | --version) for version information\n", | ||
368 | progname, OPTIONS, progname, progname); | ||
369 | } | ||