Code

Varnish plugin: Added backend monitoring
authorJérôme Renard <jerome.renard@gmail.com>
Fri, 4 Jun 2010 16:08:22 +0000 (18:08 +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 92de8976919d3b0ed42c55bcf88a79f1b12bc5ec..d2f7bfbfa77c97f9c034935f68f24f0b407d6964 100644 (file)
 #  MonitorCache yes
 #  MonitorConnections yes
 #  MonitorESI yes
+#  MonitorBackend yes
 #</Plugin>
 
 #<Plugin vmem>
index 495de961a6d09d9e690b44f1f29aebbffc2281b7..99e96e9809c1f5b3f4fa85f376be22f7391b3233 100644 (file)
@@ -163,6 +163,7 @@ users                       users:GAUGE:0:65535
 varnish_cache_ratio    value:GAUGE:0:U
 varnish_connections    value:GAUGE:0:U
 varnish_esi            value:GAUGE:0:U
+varnish_backend_connections     value:GAUGE:0:U
 virt_cpu_total         ns:COUNTER:0:256000000000
 virt_vcpu              ns:COUNTER:0:1000000000
 vmpage_action          value:COUNTER:0:4294967295
index 4329687e8e9bf54740516cf5f3774743d78e16bf..4bea1228421b3955652dd7edd6554325e7503656 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <varnish/varnishapi.h>
 
-#define USER_CONFIG_INIT {0, 0, 0}
+#define USER_CONFIG_INIT {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 */
@@ -33,6 +33,7 @@ struct user_config_s {
        int monitor_cache;
        int monitor_connections;
        int monitor_esi;
+       int monitor_backend;
 };
 
 typedef struct user_config_s user_config_t; /* }}} */
@@ -44,7 +45,8 @@ static const char *config_keys[] =
 {
   "MonitorCache",
   "MonitorConnections",
-  "MonitorESI"
+  "MonitorESI",
+  "MonitorBackend",
 };
 
 static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); /* }}} */
@@ -54,6 +56,7 @@ static int varnish_config(const char *key, const char *value) /* {{{ */
        SET_MONITOR_FLAG("MonitorCache", monitor_cache, value);
        SET_MONITOR_FLAG("MonitorConnections", monitor_connections, value);
        SET_MONITOR_FLAG("MonitorESI", monitor_esi, value);
+       SET_MONITOR_FLAG("MonitorBackend", monitor_backend, value);
 
        return (0);
 } /* }}} */
@@ -96,6 +99,18 @@ static void varnish_monitor(struct varnish_stats *VSL_stats) /* {{{ */
                varnish_submit("varnish_esi", "esi_parsed", VSL_stats->esi_parse);
                varnish_submit("varnish_esi", "esi_errors", VSL_stats->esi_errors);
        }
+
+       if(user_config.monitor_backend == 1)
+       {
+               varnish_submit("varnish_backend_connections", "backend_connections-success"      , VSL_stats->backend_conn);      /* Backend conn. success       */
+               varnish_submit("varnish_backend_connections", "backend_connections-not-attempted", VSL_stats->backend_unhealthy); /* Backend conn. not attempted */
+               varnish_submit("varnish_backend_connections", "backend_connections-too-many"     , VSL_stats->backend_busy);      /* Backend conn. too many      */
+               varnish_submit("varnish_backend_connections", "backend_connections-failures"     , VSL_stats->backend_fail);      /* Backend conn. failures      */
+               varnish_submit("varnish_backend_connections", "backend_connections-reuses"       , VSL_stats->backend_reuse);     /* Backend conn. reuses        */
+               varnish_submit("varnish_backend_connections", "backend_connections-was-closed"   , VSL_stats->backend_toolate);   /* Backend conn. was closed    */
+               varnish_submit("varnish_backend_connections", "backend_connections-recycles"     , VSL_stats->backend_recycle);   /* Backend conn. recycles      */
+               varnish_submit("varnish_backend_connections", "backend_connections-unused"       , VSL_stats->backend_unused);    /* Backend conn. unused        */
+       }
 } /* }}} */
 
 static int varnish_read(void) /* {{{ */