From bc7cf8d0d01955030b5fe7ec7a41e4fdb20f1326 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Renard?= Date: Fri, 4 Jun 2010 18:25:52 +0200 Subject: [PATCH] Varnish plugin: Added 'fetch' monitoring --- src/collectd.conf.in | 1 + src/types.db | 1 + src/varnish.c | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/collectd.conf.in b/src/collectd.conf.in index d2f7bfbf..efa2af4c 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -848,6 +848,7 @@ # MonitorConnections yes # MonitorESI yes # MonitorBackend yes +# MonitorFetch yes # # diff --git a/src/types.db b/src/types.db index 99e96e98..375ac7ce 100644 --- a/src/types.db +++ b/src/types.db @@ -164,6 +164,7 @@ 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 +varnish_fetch 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 3fe9f93f..14e18f12 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -25,7 +25,7 @@ #include -#define USER_CONFIG_INIT {0, 0, 0, 0} +#define USER_CONFIG_INIT {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 */ @@ -34,6 +34,7 @@ struct user_config_s { int monitor_connections; int monitor_esi; int monitor_backend; + int monitor_fetch; }; typedef struct user_config_s user_config_t; /* }}} */ @@ -47,6 +48,7 @@ static const char *config_keys[] = "MonitorConnections", "MonitorESI", "MonitorBackend", + "MonitorFetch" }; static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); /* }}} */ @@ -57,6 +59,7 @@ static int varnish_config(const char *key, const char *value) /* {{{ */ SET_MONITOR_FLAG("MonitorConnections", monitor_connections, value); SET_MONITOR_FLAG("MonitorESI", monitor_esi, value); SET_MONITOR_FLAG("MonitorBackend", monitor_backend, value); + SET_MONITOR_FLAG("MonitorFetch", monitor_fetch, value); return (0); } /* }}} */ @@ -111,6 +114,19 @@ static void varnish_monitor(struct varnish_stats *VSL_stats) /* {{{ */ 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 */ } + + if(user_config.monitor_fetch == 1) + { + varnish_submit("varnish_fetch", "fetch_head" , VSL_stats->fetch_head); /* Fetch head */ + varnish_submit("varnish_fetch", "fetch_length" , VSL_stats->fetch_length); /* Fetch with length */ + varnish_submit("varnish_fetch", "fetch_chunked" , VSL_stats->fetch_chunked); /* Fetch chunked */ + varnish_submit("varnish_fetch", "fetch_eof" , VSL_stats->fetch_eof); /* Fetch EOF */ + varnish_submit("varnish_fetch", "fetch_bad-headers", VSL_stats->fetch_bad); /* Fetch bad headers */ + varnish_submit("varnish_fetch", "fetch_close" , VSL_stats->fetch_close); /* Fetch wanted close */ + varnish_submit("varnish_fetch", "fetch_oldhttp" , VSL_stats->fetch_oldhttp); /* Fetch pre HTTP/1.1 closed */ + 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 */ + } } /* }}} */ static int varnish_read(void) /* {{{ */ -- 2.30.2