diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-03 14:24:33 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-03 14:24:33 +0000 |
commit | 04b3d4554b829531ee4859859e7dd25fe660bba8 (patch) | |
tree | ad89b04ac227fc814e30925de6cb0a99a2e41397 /plugins | |
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')
-rw-r--r-- | plugins/check_ldap.c | 31 | ||||
-rw-r--r-- | plugins/check_mrtg.c | 162 | ||||
-rw-r--r-- | plugins/check_mrtgtraf.c | 210 |
3 files changed, 180 insertions, 223 deletions
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index ee0b8d66..f6e0fca0 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | |
3 | * This program is free software; you can redistribute it and/or modify | 3 | This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by | 4 | it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or | 5 | the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. | 6 | (at your option) any later version. |
7 | * | 7 | |
8 | * This program is distributed in the hope that it will be useful, | 8 | This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. | 11 | GNU General Public License for more details. |
12 | * | 12 | |
13 | * You should have received a copy of the GNU General Public License | 13 | You should have received a copy of the GNU General Public License |
14 | * along with this program; if not, write to the Free Software | 14 | along with this program; if not, write to the Free Software |
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | * | 16 | |
17 | ******************************************************************************/ | 17 | ******************************************************************************/ |
18 | 18 | ||
19 | const char *progname = "check_ldap"; | 19 | const char *progname = "check_ldap"; |
@@ -21,7 +21,6 @@ const char *revision = "$Revision$"; | |||
21 | const char *copyright = "2000-2003"; | 21 | const char *copyright = "2000-2003"; |
22 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | 22 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; |
23 | 23 | ||
24 | #include "config.h" | ||
25 | #include "common.h" | 24 | #include "common.h" |
26 | #include "netutils.h" | 25 | #include "netutils.h" |
27 | #include "utils.h" | 26 | #include "utils.h" |
diff --git a/plugins/check_mrtg.c b/plugins/check_mrtg.c index 095dcbc8..88c8e490 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 | } | ||
diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c index 21791ae9..c99e4213 100644 --- a/plugins/check_mrtgtraf.c +++ b/plugins/check_mrtgtraf.c | |||
@@ -1,63 +1,83 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | |
3 | * CHECK_MRTGTRAF.C | 3 | This program is free software; you can redistribute it and/or modify |
4 | * | 4 | it under the terms of the GNU General Public License as published by |
5 | * Program: MRTG (Multi-Router Traffic Grapher) traffic plugin for Nagios | 5 | the Free Software Foundation; either version 2 of the License, or |
6 | * License: GPL | 6 | (at your option) any later version. |
7 | * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) | 7 | |
8 | * | 8 | This program is distributed in the hope that it will be useful, |
9 | * Last Modified: $Date$ | 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * Command line: CHECK_MRTGTRAF <log_file> <expire_minutes> <AVG|MAX> <iwl> <icl> <owl> <ocl> | 11 | GNU General Public License for more details. |
12 | * | 12 | |
13 | * Description: | 13 | You should have received a copy of the GNU General Public License |
14 | * | 14 | along with this program; if not, write to the Free Software |
15 | * This plugin will check the incoming/outgoing transfer rates of a | 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | * router, switch, etc recorded in an MRTG log. If the newest log | 16 | |
17 | * entry is older than <expire_minutes>, a WARNING status is returned. | 17 | ******************************************************************************/ |
18 | * If either the incoming or outgoing rates exceed the <icl> or <ocl> | 18 | |
19 | * thresholds (in Bytes/sec), a CRITICAL status results. If either of | ||
20 | * the rates exceed the <iwl> or <owl> thresholds (in Bytes/sec), a | ||
21 | * WARNING status results. | ||
22 | * | ||
23 | * Notes: | ||
24 | * - MRTG stands for the Multi Router Traffic Grapher. It can be | ||
25 | * downloaded from | ||
26 | * http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html | ||
27 | * - While MRTG can monitor things other than traffic rates, this | ||
28 | * plugin probably won't work with much else without modification. | ||
29 | * - The calculated i/o rates are a little off from what MRTG actually | ||
30 | * reports. I'm not sure why this is right now, but will look into it | ||
31 | * for future enhancements of this plugin. | ||
32 | * | ||
33 | * License Information: | ||
34 | * | ||
35 | * This program is free software; you can redistribute it and/or modify | ||
36 | * it under the terms of the GNU General Public License as published by | ||
37 | * the Free Software Foundation; either version 2 of the License, or | ||
38 | * (at your option) any later version. | ||
39 | * | ||
40 | * This program is distributed in the hope that it will be useful, | ||
41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
43 | * GNU General Public License for more details. | ||
44 | * | ||
45 | * You should have received a copy of the GNU General Public License | ||
46 | * along with this program; if not, write to the Free Software | ||
47 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
48 | * | ||
49 | *****************************************************************************/ | ||
50 | |||
51 | #include "config.h" | ||
52 | #include "common.h" | 19 | #include "common.h" |
53 | #include "utils.h" | 20 | #include "utils.h" |
54 | 21 | ||
55 | const char *progname = "check_mrtgtraf"; | 22 | const char *progname = "check_mrtgtraf"; |
23 | const char *revision = "$Revision$"; | ||
24 | const char *copyright = "1999-2003"; | ||
25 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | ||
56 | 26 | ||
27 | void | ||
28 | print_usage (void) | ||
29 | { | ||
30 | printf (_("\ | ||
31 | Usage: %s -F <log_file> -a <AVG | MAX> -v <variable> -w <warning_pair> -c <critical_pair>\n\ | ||
32 | [-e expire_minutes] [-t timeout] [-v]\n"), progname); | ||
33 | printf (_(UT_HLP_VRS), progname, progname); | ||
34 | } | ||
35 | |||
36 | void | ||
37 | print_help (void) | ||
38 | { | ||
39 | print_revision (progname, revision); | ||
40 | |||
41 | printf (_(COPYRIGHT), copyright, email); | ||
42 | |||
43 | print_usage (); | ||
44 | |||
45 | printf (_(UT_HELP_VRSN)); | ||
46 | |||
47 | printf (_("\ | ||
48 | -F, --filename=STRING\n\ | ||
49 | File to read log from\n\ | ||
50 | -e, --expires=INTEGER\n\ | ||
51 | Minutes after which log expires\n\ | ||
52 | -a, --aggregation=(AVG|MAX)\n\ | ||
53 | Test average or maximum\n\ | ||
54 | -w, --warning\n\ | ||
55 | Warning threshold pair \"<incoming>,<outgoing>\"\n\ | ||
56 | -c, --critical\n\ | ||
57 | Critical threshold pair \"<incoming>,<outgoing>\"\n")); | ||
58 | |||
59 | printf (_("\n\ | ||
60 | This plugin will check the incoming/outgoing transfer rates of a router,\n\ | ||
61 | switch, etc recorded in an MRTG log. If the newest log entry is older\n\ | ||
62 | than <expire_minutes>, a WARNING status is returned. If either the\n\ | ||
63 | incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in\n\ | ||
64 | Bytes/sec), a CRITICAL status results. If either of the rates exceed\n\ | ||
65 | the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results.\n\n")); | ||
66 | |||
67 | printf (_("Notes:\n\ | ||
68 | - MRTG stands for Multi Router Traffic Grapher. It can be downloaded from\n\ | ||
69 | http://ee-staff.ethz.ch/~oetiker/webtools/mrtg/mrtg.html\n\ | ||
70 | - While MRTG can monitor things other than traffic rates, this\n\ | ||
71 | plugin probably won't work with much else without modification.\n\ | ||
72 | - The calculated i/o rates are a little off from what MRTG actually\n\ | ||
73 | reports. I'm not sure why this is right now, but will look into it\n\ | ||
74 | for future enhancements of this plugin.\n")); | ||
75 | |||
76 | printf (_(UT_SUPPORT)); | ||
77 | } | ||
78 | |||
57 | int process_arguments (int, char **); | 79 | int process_arguments (int, char **); |
58 | int validate_arguments (void); | 80 | int validate_arguments (void); |
59 | void print_help (void); | ||
60 | void print_usage (void); | ||
61 | 81 | ||
62 | char *log_file = NULL; | 82 | char *log_file = NULL; |
63 | int expire_minutes = -1; | 83 | int expire_minutes = -1; |
@@ -90,12 +110,12 @@ main (int argc, char **argv) | |||
90 | char outgoing_speed_rating[8]; | 110 | char outgoing_speed_rating[8]; |
91 | 111 | ||
92 | if (process_arguments (argc, argv) != OK) | 112 | if (process_arguments (argc, argv) != OK) |
93 | usage ("Invalid command arguments supplied\n"); | 113 | usage (_("Invalid command arguments supplied\n")); |
94 | 114 | ||
95 | /* open the MRTG log file for reading */ | 115 | /* open the MRTG log file for reading */ |
96 | fp = fopen (log_file, "r"); | 116 | fp = fopen (log_file, "r"); |
97 | if (fp == NULL) | 117 | if (fp == NULL) |
98 | usage ("Unable to open MRTG log file\n"); | 118 | usage (_("Unable to open MRTG log file\n")); |
99 | 119 | ||
100 | line = 0; | 120 | line = 0; |
101 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) { | 121 | while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) { |
@@ -137,14 +157,14 @@ main (int argc, char **argv) | |||
137 | 157 | ||
138 | /* if we couldn't read enough data, return an unknown error */ | 158 | /* if we couldn't read enough data, return an unknown error */ |
139 | if (line <= 2) | 159 | if (line <= 2) |
140 | usage ("Unable to process MRTG log file\n"); | 160 | usage (_("Unable to process MRTG log file\n")); |
141 | 161 | ||
142 | /* make sure the MRTG data isn't too old */ | 162 | /* make sure the MRTG data isn't too old */ |
143 | time (¤t_time); | 163 | time (¤t_time); |
144 | if (expire_minutes > 0 | 164 | if (expire_minutes > 0 |
145 | && (current_time - timestamp) > | 165 | && (current_time - timestamp) > |
146 | (expire_minutes * 60)) terminate (STATE_WARNING, | 166 | (expire_minutes * 60)) terminate (STATE_WARNING, |
147 | "MRTG data has expired (%d minutes old)\n", | 167 | _("MRTG data has expired (%d minutes old)\n"), |
148 | (int) ((current_time - timestamp) / | 168 | (int) ((current_time - timestamp) / |
149 | 60)); | 169 | 60)); |
150 | 170 | ||
@@ -197,34 +217,30 @@ main (int argc, char **argv) | |||
197 | if (incoming_rate > incoming_critical_threshold | 217 | if (incoming_rate > incoming_critical_threshold |
198 | || outgoing_rate > outgoing_critical_threshold) { | 218 | || outgoing_rate > outgoing_critical_threshold) { |
199 | result = STATE_CRITICAL; | 219 | result = STATE_CRITICAL; |
200 | asprintf (&error_message, "Traffic CRITICAL %s. In = %0.1f %s, %s. Out = %0.1f %s", | 220 | asprintf (&error_message, _("Traffic CRITICAL %s. In = %0.1f %s, %s. Out = %0.1f %s"), |
201 | (use_average == TRUE) ? "Avg" : "Max", adjusted_incoming_rate, | 221 | (use_average == TRUE) ? _("Avg") : _("Max"), adjusted_incoming_rate, |
202 | incoming_speed_rating, (use_average == TRUE) ? "Avg" : "Max", | 222 | incoming_speed_rating, (use_average == TRUE) ? "Avg" : "Max", |
203 | adjusted_outgoing_rate, outgoing_speed_rating); | 223 | adjusted_outgoing_rate, outgoing_speed_rating); |
204 | } | 224 | } |
205 | else if (incoming_rate > incoming_warning_threshold | 225 | else if (incoming_rate > incoming_warning_threshold |
206 | || outgoing_rate > outgoing_warning_threshold) { | 226 | || outgoing_rate > outgoing_warning_threshold) { |
207 | result = STATE_WARNING; | 227 | result = STATE_WARNING; |
208 | asprintf (&error_message, "Traffic WARNING %s. In = %0.1f %s, %s. Out = %0.1f %s", | 228 | asprintf (&error_message, _("Traffic WARNING %s. In = %0.1f %s, %s. Out = %0.1f %s"), |
209 | (use_average == TRUE) ? "Avg" : "Max", adjusted_incoming_rate, | 229 | (use_average == TRUE) ? _("Avg") : _("Max"), adjusted_incoming_rate, |
210 | incoming_speed_rating, (use_average == TRUE) ? "Avg" : "Max", | 230 | incoming_speed_rating, (use_average == TRUE) ? _("Avg") : _("Max"), |
211 | adjusted_outgoing_rate, outgoing_speed_rating); | 231 | adjusted_outgoing_rate, outgoing_speed_rating); |
212 | } | 232 | } |
213 | else if (result == STATE_OK) | 233 | else if (result == STATE_OK) |
214 | printf ("Traffic OK - %s. In = %0.1f %s, %s. Out = %0.1f %s\n", | 234 | printf (_("Traffic OK - %s. In = %0.1f %s, %s. Out = %0.1f %s\n"), |
215 | (use_average == TRUE) ? "Avg" : "Max", adjusted_incoming_rate, | 235 | (use_average == TRUE) ? _("Avg") : _("Max"), adjusted_incoming_rate, |
216 | incoming_speed_rating, (use_average == TRUE) ? "Avg" : "Max", | 236 | incoming_speed_rating, (use_average == TRUE) ? _("Avg") : _("Max"), |
217 | adjusted_outgoing_rate, outgoing_speed_rating); | 237 | adjusted_outgoing_rate, outgoing_speed_rating); |
218 | else | 238 | else |
219 | printf ("UNKNOWN %s\n", error_message); | 239 | printf (_("UNKNOWN %s\n"), error_message); |
220 | 240 | ||
221 | return result; | 241 | return result; |
222 | } | 242 | } |
223 | 243 | ||
224 | |||
225 | |||
226 | |||
227 | |||
228 | /* process command-line arguments */ | 244 | /* process command-line arguments */ |
229 | int | 245 | int |
230 | process_arguments (int argc, char **argv) | 246 | process_arguments (int argc, char **argv) |
@@ -285,13 +301,13 @@ process_arguments (int argc, char **argv) | |||
285 | &outgoing_warning_threshold); | 301 | &outgoing_warning_threshold); |
286 | break; | 302 | break; |
287 | case 'V': /* version */ | 303 | case 'V': /* version */ |
288 | print_revision (progname, "$Revision$"); | 304 | print_revision (progname, revision); |
289 | exit (STATE_OK); | 305 | exit (STATE_OK); |
290 | case 'h': /* help */ | 306 | case 'h': /* help */ |
291 | print_help (); | 307 | print_help (); |
292 | exit (STATE_OK); | 308 | exit (STATE_OK); |
293 | case '?': /* help */ | 309 | case '?': /* help */ |
294 | usage ("Invalid argument\n"); | 310 | usage (_("Invalid argument\n")); |
295 | } | 311 | } |
296 | } | 312 | } |
297 | 313 | ||
@@ -341,47 +357,3 @@ validate_arguments (void) | |||
341 | { | 357 | { |
342 | return OK; | 358 | return OK; |
343 | } | 359 | } |
344 | |||
345 | |||
346 | |||
347 | |||
348 | |||
349 | void | ||
350 | print_help (void) | ||
351 | { | ||
352 | print_revision (progname, "$Revision$"); | ||
353 | printf | ||
354 | ("Copyright (c) 2000 Tom Shields/Karl DeBisschop\n\n" | ||
355 | "This plugin tests the UPS service on the specified host.\n\n"); | ||
356 | print_usage (); | ||
357 | printf | ||
358 | ("\nOptions:\n" | ||
359 | " -F, --filename=STRING\n" | ||
360 | " File to read log from\n" | ||
361 | " -e, --expires=INTEGER\n" | ||
362 | " Minutes after which log expires\n" | ||
363 | " -a, --aggregation=(AVG|MAX)\n" | ||
364 | " Test average or maximum" | ||
365 | " -w, --warning\n" | ||
366 | " Warning threshold pair \"<incoming>,<outgoing>\"\n" | ||
367 | " -c, --critical\n" | ||
368 | " Critical threshold pair \"<incoming>,<outgoing>\"\n" | ||
369 | " -h, --help\n" | ||
370 | " Print detailed help screen\n" | ||
371 | " -V, --version\n" " Print version information\n\n"); | ||
372 | support (); | ||
373 | } | ||
374 | |||
375 | |||
376 | |||
377 | |||
378 | |||
379 | void | ||
380 | print_usage (void) | ||
381 | { | ||
382 | printf | ||
383 | ("Usage: %s -F <log_file> -a <AVG | MAX> -v <variable> -w <warning_pair> -c <critical_pair>\n" | ||
384 | " [-e expire_minutes] [-t timeout] [-v]\n" | ||
385 | " %s --help\n" | ||
386 | " %s --version\n", progname, progname, progname); | ||
387 | } | ||