[nagiosplug] Fixed SF.net bug 3602586, added timeout option ...

Nagios Plugin Development nagios-plugins at users.sourceforge.net
Mon Mar 25 23:40:18 CET 2013


    Module: nagiosplug
    Branch: master
    Commit: fe5fa2a4802215bbc33132b8fc2cc25201c00109
    Author: Richard Leitner <me at g0hl1n.net>
 Committer: Holger Weiss <holger at zedat.fu-berlin.de>
      Date: Sun Mar 17 14:06:30 2013 +0100
       URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=fe5fa2a

Fixed SF.net bug 3602586, added timeout option for check_nagios

---

 plugins/check_nagios.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c
index c8cdbc0..4fd6342 100644
--- a/plugins/check_nagios.c
+++ b/plugins/check_nagios.c
@@ -205,6 +205,7 @@ process_arguments (int argc, char **argv)
 		{"filename", required_argument, 0, 'F'},
 		{"expires", required_argument, 0, 'e'},
 		{"command", required_argument, 0, 'C'},
+		{"timeout", optional_argument, 0, 't'},
 		{"version", no_argument, 0, 'V'},
 		{"help", no_argument, 0, 'h'},
 		{"verbose", no_argument, 0, 'v'},
@@ -226,7 +227,7 @@ process_arguments (int argc, char **argv)
 	}
 
 	while (1) {
-		c = getopt_long (argc, argv, "+hVvF:C:e:", longopts, &option);
+		c = getopt_long (argc, argv, "+hVvF:C:e:t:", longopts, &option);
 
 		if (c == -1 || c == EOF || c == 1)
 			break;
@@ -251,6 +252,13 @@ process_arguments (int argc, char **argv)
 				die (STATE_UNKNOWN,
 				     _("Expiration time must be an integer (seconds)\n"));
 			break;
+		case 't':									/* timeout */
+			if (is_intnonneg (optarg))
+				timeout_interval = atoi (optarg);
+			else
+				die (STATE_UNKNOWN,
+				     _("Timeout must be an integer (seconds)\n"));
+			break;
 		case 'v':
 			verbose++;
 			break;
@@ -296,11 +304,13 @@ print_help (void)
   printf ("    %s\n", _("Minutes aging after which logfile is considered stale"));
   printf (" %s\n", "-C, --command=STRING");
   printf ("    %s\n", _("Substring to search for in process arguments"));
+  printf (" %s\n", "-t, --timeout=INTEGER");
+  printf ("    %s\n", _("Timeout for the plugin in seconds"));
   printf (UT_VERBOSE);
 
   printf ("\n");
   printf ("%s\n", _("Examples:"));
-  printf (" %s\n", "check_nagios -e 5 -F /usr/local/nagios/var/status.log -C /usr/local/nagios/bin/nagios");
+  printf (" %s\n", "check_nagios -t 20 -e 5 -F /usr/local/nagios/var/status.log -C /usr/local/nagios/bin/nagios");
 
   printf (UT_SUPPORT);
 }
@@ -311,5 +321,5 @@ void
 print_usage (void)
 {
   printf ("%s\n", _("Usage:"));
-	printf ("%s -F <status log file> -e <expire_minutes> -C <process_string>\n", progname);
+	printf ("%s -F <status log file> -t <timeout_seconds> -e <expire_minutes> -C <process_string>\n", progname);
 }





More information about the Commits mailing list