diff options
Diffstat (limited to 'plugins/check_nagios.c')
| -rw-r--r-- | plugins/check_nagios.c | 106 |
1 files changed, 58 insertions, 48 deletions
diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c index a678e2a4..5b21ba1d 100644 --- a/plugins/check_nagios.c +++ b/plugins/check_nagios.c | |||
| @@ -25,48 +25,9 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; | |||
| 25 | #include "popen.h" | 25 | #include "popen.h" |
| 26 | #include "utils.h" | 26 | #include "utils.h" |
| 27 | 27 | ||
| 28 | void | ||
| 29 | print_usage (void) | ||
| 30 | { | ||
| 31 | printf (_("\ | ||
| 32 | Usage: %s -F <status log file> -e <expire_minutes> -C <process_string>\n"), | ||
| 33 | progname); | ||
| 34 | } | ||
| 35 | |||
| 36 | void | ||
| 37 | print_help (void) | ||
| 38 | { | ||
| 39 | print_revision (progname, revision); | ||
| 40 | |||
| 41 | printf (_(COPYRIGHT), copyright, email); | ||
| 42 | |||
| 43 | printf (_("\ | ||
| 44 | This plugin attempts to check the status of the Nagios process on the local\n\ | ||
| 45 | machine. The plugin will check to make sure the Nagios status log is no older\n\ | ||
| 46 | than the number of minutes specified by the <expire_minutes> option. It also\n\ | ||
| 47 | uses the /bin/ps command to check for a process matching whatever you specify\n\ | ||
| 48 | by the <process_string> argument.\n")); | ||
| 49 | |||
| 50 | print_usage (); | ||
| 51 | |||
| 52 | printf (_(UT_HELP_VRSN)); | ||
| 53 | |||
| 54 | printf (_("\ | ||
| 55 | -F, --filename=FILE\n\ | ||
| 56 | Name of the log file to check\n\ | ||
| 57 | -e, --expires=INTEGER\n\ | ||
| 58 | Seconds aging afterwhich logfile is condsidered stale\n\ | ||
| 59 | -C, --command=STRING\n\ | ||
| 60 | Command to search for in process table\n")); | ||
| 61 | |||
| 62 | printf (_("\ | ||
| 63 | Example:\n\ | ||
| 64 | ./check_nagios -e 5 \\\ | ||
| 65 | -F /usr/local/nagios/var/status.log \\\ | ||
| 66 | -C /usr/local/nagios/bin/nagios\n")); | ||
| 67 | } | ||
| 68 | |||
| 69 | int process_arguments (int, char **); | 28 | int process_arguments (int, char **); |
| 29 | void print_help (void); | ||
| 30 | void print_usage (void); | ||
| 70 | 31 | ||
| 71 | char *status_log = NULL; | 32 | char *status_log = NULL; |
| 72 | char *process_string = NULL; | 33 | char *process_string = NULL; |
| @@ -198,8 +159,8 @@ process_arguments (int argc, char **argv) | |||
| 198 | { | 159 | { |
| 199 | int c; | 160 | int c; |
| 200 | 161 | ||
| 201 | int option_index = 0; | 162 | int option = 0; |
| 202 | static struct option long_options[] = { | 163 | static struct option longopts[] = { |
| 203 | {"filename", required_argument, 0, 'F'}, | 164 | {"filename", required_argument, 0, 'F'}, |
| 204 | {"expires", required_argument, 0, 'e'}, | 165 | {"expires", required_argument, 0, 'e'}, |
| 205 | {"command", required_argument, 0, 'C'}, | 166 | {"command", required_argument, 0, 'C'}, |
| @@ -225,7 +186,7 @@ process_arguments (int argc, char **argv) | |||
| 225 | } | 186 | } |
| 226 | 187 | ||
| 227 | while (1) { | 188 | while (1) { |
| 228 | c = getopt_long (argc, argv, "+hVvF:C:e:", long_options, &option_index); | 189 | c = getopt_long (argc, argv, "+hVvF:C:e:", longopts, &option); |
| 229 | 190 | ||
| 230 | if (c == -1 || c == EOF || c == 1) | 191 | if (c == -1 || c == EOF || c == 1) |
| 231 | break; | 192 | break; |
| @@ -252,8 +213,8 @@ process_arguments (int argc, char **argv) | |||
| 252 | expire_minutes = atoi (optarg); | 213 | expire_minutes = atoi (optarg); |
| 253 | else | 214 | else |
| 254 | die (STATE_UNKNOWN, | 215 | die (STATE_UNKNOWN, |
| 255 | _("Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n"), | 216 | _("Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n"), |
| 256 | progname); | 217 | progname); |
| 257 | break; | 218 | break; |
| 258 | case 'v': | 219 | case 'v': |
| 259 | verbose++; | 220 | verbose++; |
| @@ -264,8 +225,8 @@ process_arguments (int argc, char **argv) | |||
| 264 | 225 | ||
| 265 | if (status_log == NULL) | 226 | if (status_log == NULL) |
| 266 | die (STATE_UNKNOWN, | 227 | die (STATE_UNKNOWN, |
| 267 | _("You must provide the status_log\nType '%s -h' for additional help\n"), | 228 | _("You must provide the status_log\nType '%s -h' for additional help\n"), |
| 268 | progname); | 229 | progname); |
| 269 | else if (process_string == NULL) | 230 | else if (process_string == NULL) |
| 270 | die (STATE_UNKNOWN, | 231 | die (STATE_UNKNOWN, |
| 271 | _("You must provide a process string\nType '%s -h' for additional help\n"), | 232 | _("You must provide a process string\nType '%s -h' for additional help\n"), |
| @@ -273,3 +234,52 @@ process_arguments (int argc, char **argv) | |||
| 273 | 234 | ||
| 274 | return OK; | 235 | return OK; |
| 275 | } | 236 | } |
| 237 | |||
| 238 | |||
| 239 | |||
| 240 | |||
| 241 | |||
| 242 | |||
| 243 | void | ||
| 244 | print_help (void) | ||
| 245 | { | ||
| 246 | print_revision (progname, revision); | ||
| 247 | |||
| 248 | printf (_(COPYRIGHT), copyright, email); | ||
| 249 | |||
| 250 | printf (_("\ | ||
| 251 | This plugin attempts to check the status of the Nagios process on the local\n\ | ||
| 252 | machine. The plugin will check to make sure the Nagios status log is no older\n\ | ||
| 253 | than the number of minutes specified by the <expire_minutes> option. It also\n\ | ||
| 254 | uses the /bin/ps command to check for a process matching whatever you specify\n\ | ||
| 255 | by the <process_string> argument.\n")); | ||
| 256 | |||
| 257 | print_usage (); | ||
| 258 | |||
| 259 | printf (_(UT_HELP_VRSN)); | ||
| 260 | |||
| 261 | printf (_("\ | ||
| 262 | -F, --filename=FILE\n\ | ||
| 263 | Name of the log file to check\n\ | ||
| 264 | -e, --expires=INTEGER\n\ | ||
| 265 | Seconds aging afterwhich logfile is condsidered stale\n\ | ||
| 266 | -C, --command=STRING\n\ | ||
| 267 | Command to search for in process table\n")); | ||
| 268 | |||
| 269 | printf (_("\ | ||
| 270 | Example:\n\ | ||
| 271 | ./check_nagios -e 5 \\\ | ||
| 272 | -F /usr/local/nagios/var/status.log \\\ | ||
| 273 | -C /usr/local/nagios/bin/nagios\n")); | ||
| 274 | } | ||
| 275 | |||
| 276 | |||
| 277 | |||
| 278 | |||
| 279 | void | ||
| 280 | print_usage (void) | ||
| 281 | { | ||
| 282 | printf (_("\ | ||
| 283 | Usage: %s -F <status log file> -e <expire_minutes> -C <process_string>\n"), | ||
| 284 | progname); | ||
| 285 | } | ||
