From: Jérôme Renard Date: Fri, 4 Jun 2010 16:08:22 +0000 (+0200) Subject: Varnish plugin: Added backend monitoring X-Git-Tag: collectd-5.0.0-beta0~103^2~30 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=7c8f188d6f36542b70081017201561228187d17e;p=collectd.git Varnish plugin: Added backend monitoring --- diff --git a/src/collectd.conf.in b/src/collectd.conf.in index 92de8976..d2f7bfbf 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -847,6 +847,7 @@ # MonitorCache yes # MonitorConnections yes # MonitorESI yes +# MonitorBackend yes # # diff --git a/src/types.db b/src/types.db index 495de961..99e96e98 100644 --- a/src/types.db +++ b/src/types.db @@ -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 diff --git a/src/varnish.c b/src/varnish.c index 4329687e..4bea1228 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -25,7 +25,7 @@ #include -#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) /* {{{ */