[Nagiosplug-devel] [nagios-plugins-1.4.3] PATCH: fix check_mrtg to be useable

kabe at sra-tohoku.co.jp kabe at sra-tohoku.co.jp
Tue Apr 25 01:11:05 CEST 2006


Nagios plugin 'check_mrtg' never returned STATE_OK, so had been 
not much of any use. The pach fixes this.

The patch below will
- make check_mrtg command return STATE_OK (zero) if check succeeds.
- Tell use to explicitly set -w and -c in the help message,
  since default warn/crit threshold is zero which isn't anything useful.
- Delete --verbose option since it conflicts with "-v variable".
  Current check_mrtg doesn't have anything to say verbose now anyway.

-- 
kabe

--- nagios-plugins-1.4.2/plugins/check_mrtg.c.1.25	Mon Apr 24 11:05:09 2006
+++ nagios-plugins-1.4.2/plugins/check_mrtg.c	Mon Apr 24 11:52:46 2006
@@ -19,7 +19,7 @@
 ******************************************************************************/
 
 const char *progname = "check_mrtg";
-const char *revision =  "$Revision: 1.25 $";
+const char *revision =  "$Revision$"; 
 const char *copyright = "1999-2004";
 const char *email = "nagiosplug-devel at lists.sourceforge.net";
 
@@ -134,6 +134,8 @@
 		result = STATE_CRITICAL;
 	else if (rate > value_warning_threshold)
 		result = STATE_WARNING;
+	else
+		result = STATE_OK;	/*had never set to OK*/
 
 	printf("%s. %s = %lu %s|%s\n",
 	       (use_average == TRUE) ? _("Avg") : _("Max"),
@@ -164,7 +166,7 @@
 		{"warning", required_argument, 0, 'w'},
 		{"label", required_argument, 0, 'l'},
 		{"units", required_argument, 0, 'u'},
-		{"verbose", no_argument, 0, 'v'},
+		/*{"verbose", no_argument, 0, 'v'}, /*conflict --variable*/
 		{"version", no_argument, 0, 'V'},
 		{"help", no_argument, 0, 'h'},
 		{0, 0, 0, 0}
@@ -323,9 +325,9 @@
  -v, --variable=INTEGER\n\
    Which variable set should we inspect? (1 or 2)\n\
  -w, --warning=INTEGER\n\
-   Threshold value for data to result in WARNING status\n\
+   Threshold value for data to result in WARNING status (default 0)\n\
  -c, --critical=INTEGER\n\
-   Threshold value for data to result in CRITICAL status\n"));
+   Threshold value for data to result in CRITICAL status (default 0)\n"));
 
 	printf (_("\
  -l, --label=STRING\n\
@@ -335,6 +337,9 @@
    \"Bytes Per Second\", \"%% Utilization\")\n"));
 
 	printf (_("\
+\n\
+WARNING/CRITICAL threshold defaults to zero, so you MUST specify \n\
+nonzero -w <vwl> -c <vcl> to check anything useful. \n\
 If the value exceeds the <vwl> threshold, a WARNING status is returned.  If\n\
 the value exceeds the <vcl> threshold, a CRITICAL status is returned.  If\n\
 the data in the log file is older than <expire_minutes> old, a WARNING\n\
@@ -369,5 +374,5 @@
 	printf ("\
 Usage: %s -F log_file -a <AVG | MAX> -v variable -w warning -c critical\n\
                   [-l label] [-u units] [-e expire_minutes] [-t timeout]\n\
-                  [-v]\n", progname);
+                  ", progname);
 }




More information about the Devel mailing list