]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Add counter for vmod-goto, only for Varnish Plus 6
authorIsmael Puerto <ipuertofreire@gmail.com>
Fri, 27 Dec 2019 23:43:57 +0000 (23:43 +0000)
committerIsmael Puerto <ipuertofreire@gmail.com>
Fri, 27 Dec 2019 23:43:57 +0000 (23:43 +0000)
src/collectd.conf.in
src/collectd.conf.pod
src/varnish.c

index 9b4ad80b6620a5348d58b3f28d1147715f6680e4..67756093122afc1a2ec9d149b464bd501f0e570f 100644 (file)
 #      CollectSMF false
 #      CollectVBE false
 #      CollectMSE false           # Varnish-Plus only
+#      CollectGOTO false           # Varnish-Plus 6 only
 #   </Instance>
 #</Plugin>
 
index 9dba70905663283527e47811a951daab3be8f581..edb3fb1833c28422c732b5e973a6f2122e7e7c86 100644 (file)
@@ -9390,6 +9390,10 @@ Varnish, replacing the traditional malloc and file storages. Only available
 with Varnish-Plus 4.x. Note: SMA, SMF and MSE share counters, enable only the
 one used by the Varnish instance. False by default.
 
+=item B<CollectGOTO> B<true>|B<false>
+
+vmod-goto counters. Only available with Varnish Plus 6.x. False by default.
+
 =back
 
 =head2 Plugin C<virt>
index e8d8ec347cb93941f450f9a606edcf59eab97e17..d4f3c5ac719ae8759675f0471dad8bb50ebf05fe 100644 (file)
@@ -63,6 +63,9 @@ struct user_config_s {
   bool collect_smf;
   bool collect_vbe;
   bool collect_mse;
+#if HAVE_VARNISH_V6
+  bool collect_goto;
+#endif
 };
 typedef struct user_config_s user_config_t; /* }}} */
 
@@ -933,6 +936,20 @@ static int varnish_monitor(void *priv,
                                    "total_operations", "sniped_objects", val);
   }
 
+#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 */
@@ -1078,6 +1095,9 @@ static int varnish_config_apply_default(user_config_t *conf) /* {{{ */
   conf->collect_smf = false;
   conf->collect_vbe = false;
   conf->collect_mse = false;
+#if HAVE_VARNISH_V6
+  conf->collect_goto = false;
+#endif
 
   return 0;
 } /* }}} int varnish_config_apply_default */
@@ -1202,6 +1222,13 @@ static int varnish_config_instance(const oconfig_item_t *ci) /* {{{ */
       cf_util_get_boolean(child, &conf->collect_vbe);
     else if (strcasecmp("CollectMSE", child->key) == 0)
       cf_util_get_boolean(child, &conf->collect_mse);
+    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 "
               "configuration option: \"%s\". Did "
@@ -1221,7 +1248,11 @@ static int varnish_config_instance(const oconfig_item_t *ci) /* {{{ */
       && !conf->collect_vsm
 #endif
       && !conf->collect_vbe && !conf->collect_smf && !conf->collect_mgt &&
-      !conf->collect_lck && !conf->collect_mempool && !conf->collect_mse) {
+      !conf->collect_lck && !conf->collect_mempool && !conf->collect_mse
+#if HAVE_VARNISH_V6
+      && !conf->collect_goto
+#endif
+  ) {
     WARNING("Varnish plugin: No metric has been configured for "
             "instance \"%s\". Disabling this instance.",
             (conf->instance == NULL) ? "localhost" : conf->instance);