From: des Date: Wed, 25 Jul 2007 11:13:32 +0000 (+0000) Subject: Add a "usage" parameter which reports cache file usage. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b563427834f981c3340600a0f44dfc059af80f2;p=varnish Add a "usage" parameter which reports cache file usage. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1767 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-tools/nagios/check_varnish.c b/varnish-tools/nagios/check_varnish.c index 2b701baf..886ac872 100644 --- a/varnish-tools/nagios/check_varnish.c +++ b/varnish-tools/nagios/check_varnish.c @@ -99,6 +99,15 @@ check_stats(struct varnish_stats *VSL_stats, char *param, int w, int c, int less 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 @@ help(void) "\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); }