diff options
-rw-r--r-- | plugins/check_dig.c | 17 | ||||
-rw-r--r-- | plugins/check_tcp.c | 16 | ||||
-rw-r--r-- | plugins/check_users.c | 123 |
3 files changed, 73 insertions, 83 deletions
diff --git a/plugins/check_dig.c b/plugins/check_dig.c index f80a9dc..6e04087 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c | |||
@@ -21,6 +21,7 @@ const char *revision = "$Revision$"; | |||
21 | const char *copyright = "2002-2003"; | 21 | const char *copyright = "2002-2003"; |
22 | const char *authors = "Nagios Plugin Development Team"; | 22 | const char *authors = "Nagios Plugin Development Team"; |
23 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | 23 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; |
24 | |||
24 | const char *summary = "Test the DNS service on the specified host using dig\n"; | 25 | const char *summary = "Test the DNS service on the specified host using dig\n"; |
25 | 26 | ||
26 | const char *option_summary = "-H host -l lookup [-t timeout] [-v]"; | 27 | const char *option_summary = "-H host -l lookup [-t timeout] [-v]"; |
@@ -33,11 +34,13 @@ const char *options = "\ | |||
33 | -t, --timeout=INTEGER\n\ | 34 | -t, --timeout=INTEGER\n\ |
34 | Seconds before connection attempt times out (default: %d)\n\ | 35 | Seconds before connection attempt times out (default: %d)\n\ |
35 | -v, --verbose\n\ | 36 | -v, --verbose\n\ |
36 | Print extra information (command-line use only)\n\ | 37 | Print extra information (command-line use only)\n"; |
38 | |||
39 | const char *standard_options = "\ | ||
37 | -h, --help\n\ | 40 | -h, --help\n\ |
38 | Print detailed help screen\n\ | 41 | Print detailed help screen\n\ |
39 | -V, --version\n\ | 42 | -V, --version\n\ |
40 | Print version information\n\n"; | 43 | Print version information\n\n"; |
41 | 44 | ||
42 | #include "config.h" | 45 | #include "config.h" |
43 | #include "common.h" | 46 | #include "common.h" |
@@ -238,7 +241,7 @@ validate_arguments (void) | |||
238 | { | 241 | { |
239 | return OK; | 242 | return OK; |
240 | } | 243 | } |
241 | 244 | ||
242 | 245 | ||
243 | 246 | ||
244 | 247 | ||
@@ -247,12 +250,12 @@ void | |||
247 | print_help (void) | 250 | print_help (void) |
248 | { | 251 | { |
249 | print_revision (progname, revision); | 252 | print_revision (progname, revision); |
250 | printf | 253 | printf ("Copyright (c) %s %s\n\t<%s>\n\n", copyright, authors, email); |
251 | ("Copyright (c) %s %s <%s>\n\n%s\n", | 254 | printf (summary); |
252 | copyright, authors, email, summary); | ||
253 | print_usage (); | 255 | print_usage (); |
254 | printf ("\nOptions:\n"); | 256 | printf ("\nOptions:\n"); |
255 | printf (options, DEFAULT_SOCKET_TIMEOUT); | 257 | printf (options, DEFAULT_SOCKET_TIMEOUT); |
258 | printf (standard_options); | ||
256 | support (); | 259 | support (); |
257 | } | 260 | } |
258 | 261 | ||
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index 62efc8c..1057fdc 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c | |||
@@ -57,7 +57,7 @@ const char *standard_options = "\ | |||
57 | -h, --help\n\ | 57 | -h, --help\n\ |
58 | Print detailed help screen\n\ | 58 | Print detailed help screen\n\ |
59 | -V, --version\n\ | 59 | -V, --version\n\ |
60 | Print version information"; | 60 | Print version information\n\n"; |
61 | 61 | ||
62 | #include "config.h" | 62 | #include "config.h" |
63 | #include "common.h" | 63 | #include "common.h" |
@@ -358,10 +358,7 @@ main (int argc, char **argv) | |||
358 | 358 | ||
359 | return result; | 359 | return result; |
360 | } | 360 | } |
361 | 361 | ||
362 | |||
363 | |||
364 | |||
365 | 362 | ||
366 | 363 | ||
367 | 364 | ||
@@ -513,13 +510,15 @@ process_arguments (int argc, char **argv) | |||
513 | 510 | ||
514 | return OK; | 511 | return OK; |
515 | } | 512 | } |
513 | |||
514 | |||
515 | |||
516 | 516 | ||
517 | void | 517 | void |
518 | print_help (void) | 518 | print_help (void) |
519 | { | 519 | { |
520 | print_revision (progname, revision); | 520 | print_revision (progname, revision); |
521 | printf ("Copyright (c) %s %s\n\t<%s>\n\n", | 521 | printf ("Copyright (c) %s %s\n\t<%s>\n\n", copyright, authors, email); |
522 | copyright, authors, email); | ||
523 | printf (summary, SERVICE); | 522 | printf (summary, SERVICE); |
524 | print_usage (); | 523 | print_usage (); |
525 | printf ("\nOptions:\n"); | 524 | printf ("\nOptions:\n"); |
@@ -535,6 +534,9 @@ print_usage (void) | |||
535 | printf (" %s (-h|--help)\n", progname); | 534 | printf (" %s (-h|--help)\n", progname); |
536 | printf (" %s (-V|--version)\n", progname); | 535 | printf (" %s (-V|--version)\n", progname); |
537 | } | 536 | } |
537 | |||
538 | |||
539 | |||
538 | 540 | ||
539 | #ifdef HAVE_SSL | 541 | #ifdef HAVE_SSL |
540 | int | 542 | int |
diff --git a/plugins/check_users.c b/plugins/check_users.c index 58e8c13..5085107 100644 --- a/plugins/check_users.c +++ b/plugins/check_users.c | |||
@@ -1,58 +1,48 @@ | |||
1 | /****************************************************************************** | 1 | /***************************************************************************** |
2 | * | 2 | * |
3 | * CHECK_USERS.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: Current users 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 | * Modifications: | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * | 11 | * GNU General Public License for more details. |
12 | * 1999-11-17 Karl DeBisschop | 12 | * |
13 | * - check stderr and status from spoen/spclose | 13 | * You should have received a copy of the GNU General Public License |
14 | * - reformat commenst to fit 80-cahr screen | 14 | * along with this program; if not, write to the Free Software |
15 | * - set default result to STATE_UNKNOWN | 15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | * - initialize users at -1, eliminate 'found' variable | 16 | * |
17 | * | 17 | *****************************************************************************/ |
18 | * Command line: CHECK_USERS <wusers> <cusers> | ||
19 | * | ||
20 | * Description: | ||
21 | * | ||
22 | * This plugin will use the /usr/bin/who command to check the number | ||
23 | * of users currently logged into the system. If number of logged in | ||
24 | * user exceeds the number specified by the <cusers> option, a | ||
25 | * STATE_CRITICAL is return. It it exceeds <wusers>, a STATE_WARNING | ||
26 | * is returned. Errors reading the output from the who command result | ||
27 | * in a STATE_UNKNOWN error. | ||
28 | * | ||
29 | * License Information: | ||
30 | * | ||
31 | * This program is free software; you can redistribute it and/or modify | ||
32 | * it under the terms of the GNU General Public License as published by | ||
33 | * the Free Software Foundation; either version 2 of the License, or | ||
34 | * (at your option) any later version. | ||
35 | * | ||
36 | * This program is distributed in the hope that it will be useful, | ||
37 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
38 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
39 | * GNU General Public License for more details. | ||
40 | * | ||
41 | * You should have received a copy of the GNU General Public License | ||
42 | * along with this program; if not, write to the Free Software | ||
43 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
44 | * | ||
45 | *****************************************************************************/ | ||
46 | 18 | ||
47 | #include "common.h" | 19 | #include "common.h" |
48 | #include "popen.h" | 20 | #include "popen.h" |
49 | #include "utils.h" | 21 | #include "utils.h" |
50 | 22 | ||
51 | const char *progname = "check_users"; | 23 | const char *progname = "check_users"; |
52 | #define REVISION "$Revision$" | 24 | const char *revision = "$Revision$"; |
53 | #define COPYRIGHT "1999-2002" | 25 | const char *copyright = "2002-2003"; |
54 | #define AUTHOR "Ethan Galstad" | 26 | const char *authors = "Nagios Plugin Development Team"; |
55 | #define EMAIL "nagios@nagios.org" | 27 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; |
28 | |||
29 | const char *summary = "\ | ||
30 | This plugin checks the number of users currently logged in on the local\n\ | ||
31 | system and generates an error if the number exceeds the thresholds specified.\n"; | ||
32 | |||
33 | const char *option_summary = "-w <users> -c <users>"; | ||
34 | |||
35 | const char *options = "\ | ||
36 | -w, --warning=INTEGER\n\ | ||
37 | Set WARNING status if more than INTEGER users are logged in\n\ | ||
38 | -c, --critical=INTEGER\n\ | ||
39 | Set CRITICAL status if more than INTEGER users are logged in\n"; | ||
40 | |||
41 | const char *standard_options = "\ | ||
42 | -h, --help\n\ | ||
43 | Print detailed help screen\n\ | ||
44 | -V, --version\n\ | ||
45 | Print version information\n\n"; | ||
56 | 46 | ||
57 | #define possibly_set(a,b) ((a) == 0 ? (b) : 0) | 47 | #define possibly_set(a,b) ((a) == 0 ? (b) : 0) |
58 | 48 | ||
@@ -163,7 +153,7 @@ process_arguments (int argc, char **argv) | |||
163 | print_help (); | 153 | print_help (); |
164 | exit (STATE_OK); | 154 | exit (STATE_OK); |
165 | case 'V': /* version */ | 155 | case 'V': /* version */ |
166 | print_revision (progname, REVISION); | 156 | print_revision (progname, revision); |
167 | exit (STATE_OK); | 157 | exit (STATE_OK); |
168 | case 'c': /* critical */ | 158 | case 'c': /* critical */ |
169 | if (!is_intnonneg (optarg)) | 159 | if (!is_intnonneg (optarg)) |
@@ -193,15 +183,22 @@ process_arguments (int argc, char **argv) | |||
193 | 183 | ||
194 | return OK; | 184 | return OK; |
195 | } | 185 | } |
196 | 186 | ||
197 | 187 | ||
198 | 188 | ||
199 | 189 | ||
200 | 190 | ||
201 | void | 191 | void |
202 | print_usage (void) | 192 | print_help (void) |
203 | { | 193 | { |
204 | printf ("Usage: %s -w <users> -c <users>\n", progname); | 194 | print_revision (progname, revision); |
195 | printf ("Copyright (c) %s %s\n\t<%s>\n\n", copyright, authors, email); | ||
196 | printf (summary); | ||
197 | print_usage (); | ||
198 | printf ("\nOptions:\n"); | ||
199 | printf (options); | ||
200 | printf (standard_options); | ||
201 | support (); | ||
205 | } | 202 | } |
206 | 203 | ||
207 | 204 | ||
@@ -209,21 +206,9 @@ print_usage (void) | |||
209 | 206 | ||
210 | 207 | ||
211 | void | 208 | void |
212 | print_help (void) | 209 | print_usage (void) |
213 | { | 210 | { |
214 | print_revision (progname, REVISION); | 211 | printf ("Usage: %s %s\n", progname, option_summary); |
215 | printf | 212 | printf (" %s (-h|--help)\n", progname); |
216 | ("Copyright (c) " COPYRIGHT " " AUTHOR "(" EMAIL ")\n\n" | 213 | printf (" %s (-V|--version)\n", progname); |
217 | "This plugin checks the number of users currently logged in on the local\n" | ||
218 | "system and generates an error if the number exceeds the thresholds specified.\n"); | ||
219 | print_usage (); | ||
220 | printf | ||
221 | ("Options:\n" | ||
222 | " -w, --warning=INTEGER\n" | ||
223 | " Set WARNING status if more than INTEGER users are logged in\n" | ||
224 | " -c, --critical=INTEGER\n" | ||
225 | " Set CRITICAL status if more than INTEGER users are logged in\n" | ||
226 | " -h, --help\n" | ||
227 | " Print detailed help screen\n" | ||
228 | " -V, --version\n" " Print version information\n"); | ||
229 | } | 214 | } |