Code

Varnish plugin: Added HCB monitoring
authorJérôme Renard <jerome.renard@gmail.com>
Fri, 4 Jun 2010 16:38:31 +0000 (18:38 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 7 Jun 2010 12:40:47 +0000 (14:40 +0200)
src/collectd.conf.in
src/types.db
src/varnish.c

index efa2af4c1d4cc8568bff03454315f9ba2aff37ee..2ca0561f6d56349db2f0c10ef5bc375f0c20760f 100644 (file)
 #  MonitorESI yes
 #  MonitorBackend yes
 #  MonitorFetch yes
+#  MonitorHCB yes
 #</Plugin>
 
 #<Plugin vmem>
index 375ac7cee7fdf2d727c46023edb28ba3d974f768..10a7ff2d8dee829ebaa391bb77d593ac1f5f4bda 100644 (file)
@@ -165,6 +165,7 @@ varnish_connections value:GAUGE:0:U
 varnish_esi            value:GAUGE:0:U
 varnish_backend_connections     value:GAUGE:0:U
 varnish_fetch       value:GAUGE:0:U
+varnish_hcb         value:GAUGE:0:U
 virt_cpu_total         ns:COUNTER:0:256000000000
 virt_vcpu              ns:COUNTER:0:1000000000
 vmpage_action          value:COUNTER:0:4294967295
index 14e18f12f1db73264bf3be7c1fdc07e2c9e3ed4a..5fa36c9b8d8de760acf2fdfa49f6efb4f225dac6 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <varnish/varnishapi.h>
 
-#define USER_CONFIG_INIT {0, 0, 0, 0, 0}
+#define USER_CONFIG_INIT {0, 0, 0, 0, 0,0}
 #define SET_MONITOR_FLAG(name, flag, value) if((strcasecmp(name, key) == 0) && IS_TRUE(value)) user_config.flag = 1
 
 /* {{{ user_config_s */
@@ -35,6 +35,7 @@ struct user_config_s {
        int monitor_esi;
        int monitor_backend;
        int monitor_fetch;
+       int monitor_hcb;
 };
 
 typedef struct user_config_s user_config_t; /* }}} */
@@ -48,7 +49,8 @@ static const char *config_keys[] =
   "MonitorConnections",
   "MonitorESI",
   "MonitorBackend",
-  "MonitorFetch"
+  "MonitorFetch",
+  "MonitorHCB"
 };
 
 static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); /* }}} */
@@ -60,6 +62,7 @@ static int varnish_config(const char *key, const char *value) /* {{{ */
        SET_MONITOR_FLAG("MonitorESI", monitor_esi, value);
        SET_MONITOR_FLAG("MonitorBackend", monitor_backend, value);
        SET_MONITOR_FLAG("MonitorFetch", monitor_fetch, value);
+       SET_MONITOR_FLAG("MonitorHCB", monitor_hcb, value);
 
        return (0);
 } /* }}} */
@@ -127,6 +130,13 @@ static void varnish_monitor(struct varnish_stats *VSL_stats) /* {{{ */
                varnish_submit("varnish_fetch", "fetch_zero"       , VSL_stats->fetch_zero);    /* Fetch zero len            */
                varnish_submit("varnish_fetch", "fetch_failed"     , VSL_stats->fetch_failed);  /* Fetch failed              */
        }
+
+       if(user_config.monitor_hcb == 1)
+       {
+               varnish_submit("varnish_hcb", "hcb_nolock", VSL_stats->hcb_nolock); /* HCB Lookups without lock */
+               varnish_submit("varnish_hcb", "hcb_lock"  , VSL_stats->hcb_lock);   /* HCB Lookups with lock    */
+               varnish_submit("varnish_hcb", "hcb_insert", VSL_stats->hcb_insert); /* HCB Inserts              */
+       }
 } /* }}} */
 
 static int varnish_read(void) /* {{{ */