From f4a9ab03c1268d1030039483f1721a3e1dbbd051 Mon Sep 17 00:00:00 2001 From: Ismael Puerto Date: Sat, 28 Dec 2019 00:43:57 +0100 Subject: [PATCH] Add counter for vmod-goto, only for Varnish Plus 6 --- src/collectd.conf.in | 1 + src/collectd.conf.pod | 4 ++++ src/varnish.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/src/collectd.conf.in b/src/collectd.conf.in index de2843875..b55af5a08 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -1842,6 +1842,7 @@ # CollectSMF false # Varnish 4 and above # CollectVBE false # Varnish 4 and above # CollectMSE false # Varnish-Plus only +# CollectGOTO false # Varnish-Plus 6 only # # diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 87e90928b..321a9e8e3 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -10077,6 +10077,10 @@ Varnish, replacing the traditional malloc and file storages. Only available with Varnish-Plus 4.x and above. Note: SMA, SMF and MSE share counters, enable only the one used by the Varnish instance. False by default. +=item B B|B + +vmod-goto counters. Only available with Varnish Plus 6.x. False by default. + =back =head2 Plugin C diff --git a/src/varnish.c b/src/varnish.c index 6331af12c..50578bf6e 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -92,6 +92,9 @@ struct user_config_s { bool collect_vbe; bool collect_mse; #endif +#if HAVE_VARNISH_V6 + bool collect_goto; +#endif }; typedef struct user_config_s user_config_t; /* }}} */ @@ -1022,6 +1025,20 @@ static int varnish_monitor(void *priv, #endif +#if HAVE_VARNISH_V6 + if (conf->collect_goto) { + if (strcmp(name, "goto_dns_cache_hits") == 0) + return varnish_submit_derive(conf->instance, "goto", "total_operations", + "dns_cache_hits", val); + else if (strcmp(name, "goto_dns_lookups") == 0) + return varnish_submit_derive(conf->instance, "goto", "total_operations", + "dns_lookups", val); + else if (strcmp(name, "goto_dns_lookup_fails") == 0) + return varnish_submit_derive(conf->instance, "goto", "total_operations", + "dns_lookup_fails", val); + } +#endif + return 0; } /* }}} static int varnish_monitor */ @@ -1560,6 +1577,9 @@ static int varnish_config_apply_default(user_config_t *conf) /* {{{ */ conf->collect_vbe = false; conf->collect_mse = false; #endif +#if HAVE_VARNISH_V6 + conf->collect_goto = false; +#endif return 0; } /* }}} int varnish_config_apply_default */ @@ -1754,6 +1774,13 @@ static int varnish_config_instance(const oconfig_item_t *ci) /* {{{ */ #else WARNING("Varnish plugin: \"%s\" is available for Varnish %s only.", child->key, "Plus v4"); +#endif + else if (strcasecmp("CollectGOTO", child->key) == 0) +#if HAVE_VARNISH_V6 + cf_util_get_boolean(child, &conf->collect_goto); +#else + WARNING("Varnish plugin: \"%s\" is available for Varnish %s only.", + child->key, "v6"); #endif else { WARNING("Varnish plugin: Ignoring unknown " @@ -1794,6 +1821,9 @@ static int varnish_config_instance(const oconfig_item_t *ci) /* {{{ */ && !conf->collect_vbe && !conf->collect_smf && !conf->collect_mgt && !conf->collect_lck && !conf->collect_mempool && !conf->collect_mse +#endif +#if HAVE_VARNISH_V6 + && !conf->collect_goto #endif ) { WARNING("Varnish plugin: No metric has been configured for " -- 2.47.2