r1767 - trunk/varnish-tools/nagios

des at projects.linpro.no des at projects.linpro.no
Wed Jul 25 13:13:32 CEST 2007


Author: des
Date: 2007-07-25 13:13:32 +0200 (Wed, 25 Jul 2007)
New Revision: 1767

Modified:
   trunk/varnish-tools/nagios/check_varnish.c
Log:
Add a "usage" parameter which reports cache file usage.


Modified: trunk/varnish-tools/nagios/check_varnish.c
===================================================================
--- trunk/varnish-tools/nagios/check_varnish.c	2007-07-25 11:10:59 UTC (rev 1766)
+++ trunk/varnish-tools/nagios/check_varnish.c	2007-07-25 11:13:32 UTC (rev 1767)
@@ -99,6 +99,15 @@
 		level = check_threshold(ratio, w, c, less);
 		message_and_exit(level, ratio, "Cache hit ratio");
 	}
+	if (strcmp(param, "usage") == 0) {
+		intmax_t total = VSL_stats->sm_balloc + VSL_stats->sm_bfree;
+		double ratio = 0;
+
+		if (total > 0)
+			ratio = 100.0 * VSL_stats->sm_balloc / total;
+		level = check_threshold(ratio, w, c, less);
+		message_and_exit(level, ratio, "Cache file usage");
+	}
 #define MAC_STAT(n, t, f, d) \
 	else if (strcmp(param, #n) == 0) { \
 		intmax_t val = VSL_stats->n; \
@@ -135,6 +144,7 @@
 	    "\n"
 	    "ratio   The cache hit ratio expressed as a percentage of hits to\n"
 	    "        hits + misses.  Default thresholds are 95 and 90.\n"
+	    "usage   Cache file usage as a percentage of the total cache space.\n"
 	);
 	exit(0);
 }




More information about the varnish-commit mailing list