X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fvarnish.c;h=0ea8c7f7e902b8c90a5f80d494a4d1dd59dc5c3d;hb=08a2128ac248150b50f9c54c9c71f573e54df3c3;hp=bdff16a95f53e1de0d213c6a1c3cbbdd4eb74404;hpb=e937457838e63cc0422396222552020ff72c0d75;p=collectd.git diff --git a/src/varnish.c b/src/varnish.c index bdff16a9..0ea8c7f7 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -78,6 +78,9 @@ struct user_config_s { #endif _Bool collect_vcl; _Bool collect_workers; +#if HAVE_VARNISH_V4 + _Bool collect_vsm; +#endif }; typedef struct user_config_s user_config_t; /* }}} */ @@ -271,7 +274,10 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */ #endif /* HTTP header overflows */ varnish_submit_derive (conf->instance, "objects", "total_objects", "header_overflow", stats->losthdr); -#if !HAVE_VARNISH_V4 +#if HAVE_VARNISH_V4 + /* N purged objects */ + varnish_submit_derive (conf->instance, "objects", "total_objects", "purged", stats->n_obj_purged); +#else /* Objects sent with sendfile */ varnish_submit_derive (conf->instance, "objects", "total_objects", "sent_sendfile", stats->n_objsendfile); /* Objects sent with write */ @@ -481,6 +487,8 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */ varnish_submit_derive (conf->instance, "totals", "total_bytes", "pipe_in", stats->s_pipe_in); /* Piped bytes to client */ varnish_submit_derive (conf->instance, "totals", "total_bytes", "pipe_out", stats->s_pipe_out); + /* Number of purge operations */ + varnish_submit_derive (conf->instance, "totals", "total_operations", "purges", stats->n_purges); #else /* Total header bytes */ varnish_submit_derive (conf->instance, "totals", "total_bytes", "header-bytes", stats->s_hdrbytes); @@ -542,7 +550,7 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */ /* worker threads limited */ varnish_submit_derive (conf->instance, "workers", "total_threads", "limited", stats->n_wrk_max); /* dropped work requests */ - varnish_submit_derive (conf->instance, "workers", "total_requests", "dropped", stats->n_wrk_drop); + varnish_submit_derive (conf->instance, "workers", "total_threads", "dropped", stats->n_wrk_drop); #ifdef HAVE_VARNISH_V2 /* queued work requests */ varnish_submit_derive (conf->instance, "workers", "total_requests", "queued", stats->n_wrk_queue); @@ -556,6 +564,23 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */ #endif #endif } + +#if HAVE_VARNISH_V4 + if (conf->collect_vsm) + { + /* Free VSM space */ + varnish_submit_gauge (conf->instance, "vsm", "bytes", "free", stats->vsm_free); + /* Used VSM space */ + varnish_submit_gauge (conf->instance, "vsm", "bytes", "used", stats->vsm_used); + /* Cooling VSM space */ + varnish_submit_gauge (conf->instance, "vsm", "bytes", "cooling", stats->vsm_cooling); + /* Overflow VSM space */ + varnish_submit_gauge (conf->instance, "vsm", "bytes", "overflow", stats->vsm_overflow); + /* Total overflowed VSM space */ + varnish_submit_derive (conf->instance, "vsm", "total_bytes", "overflowed", stats->vsm_overflowed); + } +#endif + } /* }}} void varnish_monitor */ #if HAVE_VARNISH_V3 || HAVE_VARNISH_V4 @@ -683,6 +708,9 @@ static int varnish_config_apply_default (user_config_t *conf) /* {{{ */ #endif conf->collect_vcl = 0; conf->collect_workers = 0; +#if HAVE_VARNISH_V4 + conf->collect_vsm = 0; +#endif return (0); } /* }}} int varnish_config_apply_default */ @@ -711,7 +739,7 @@ static int varnish_init (void) /* {{{ */ plugin_register_complex_read (/* group = */ "varnish", /* name = */ "varnish/localhost", /* callback = */ varnish_read, - /* interval = */ NULL, + /* interval = */ 0, /* user data = */ &ud); return (0); @@ -810,6 +838,10 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ cf_util_get_boolean (child, &conf->collect_vcl); else if (strcasecmp ("CollectWorkers", child->key) == 0) cf_util_get_boolean (child, &conf->collect_workers); +#if HAVE_VARNISH_V4 + else if (strcasecmp ("CollectVSM", child->key) == 0) + cf_util_get_boolean (child, &conf->collect_vsm); +#endif else { WARNING ("Varnish plugin: Ignoring unknown " @@ -848,7 +880,11 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ && !conf->collect_uptime #endif && !conf->collect_vcl - && !conf->collect_workers) + && !conf->collect_workers +#if HAVE_VARNISH_V4 + && !conf->collect_vsm +#endif + ) { WARNING ("Varnish plugin: No metric has been configured for " "instance \"%s\". Disabling this instance.", @@ -865,7 +901,7 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ plugin_register_complex_read (/* group = */ "varnish", /* name = */ callback_name, /* callback = */ varnish_read, - /* interval = */ NULL, + /* interval = */ 0, /* user data = */ &ud); have_instance = 1;