r4010 - trunk/varnish-tools/nagios

tfheen at projects.linpro.no tfheen at projects.linpro.no
Mon Mar 30 13:31:09 CEST 2009


Author: tfheen
Date: 2009-03-30 13:31:08 +0200 (Mon, 30 Mar 2009)
New Revision: 4010

Modified:
   trunk/varnish-tools/nagios/check_varnish.c
Log:
Add -p uptime to check_varnish

Modified: trunk/varnish-tools/nagios/check_varnish.c
===================================================================
--- trunk/varnish-tools/nagios/check_varnish.c	2009-03-30 11:31:06 UTC (rev 4009)
+++ trunk/varnish-tools/nagios/check_varnish.c	2009-03-30 11:31:08 UTC (rev 4010)
@@ -38,6 +38,7 @@
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
+#include <sys/time.h>
 
 #include "shmlog.h"
 #include "varnishapi.h"
@@ -165,10 +166,18 @@
 check_stats(struct varnish_stats *VSL_stats, char *param)
 {
 	const char *info;
+	struct timeval tv;
+	double up;
 	intmax_t value;
 	int status;
 
-	if (strcmp(param, "ratio") == 0) {
+	gettimeofday(&tv, NULL);
+	up = tv.tv_sec - VSL_stats->start_time;
+	if (strcmp(param, "uptime") == 0) {
+		value = up;
+		info = "Uptime";
+	}
+	else if (strcmp(param, "ratio") == 0) {
 		intmax_t total = VSL_stats->cache_hit + VSL_stats->cache_miss;
 
 		value = total ? (100 * VSL_stats->cache_hit / total) : 0;
@@ -215,6 +224,7 @@
 	    "identifier listed in the left column by 'varnishstat -l'.  In\n"
 	    "addition, the following parameters are available:\n"
 	    "\n"
+	    "uptime  How long the cache has been running (in seconds)\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"



More information about the varnish-commit mailing list