#endif
_Bool collect_vcl;
_Bool collect_workers;
+#if HAVE_VARNISH_V4
+ _Bool collect_vsm;
+#endif
};
typedef struct user_config_s user_config_t; /* }}} */
/* 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);
#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
status = VSM_n_Arg (vd, conf->instance);
if (status < 0)
{
+ VSM_Delete (vd);
ERROR ("varnish plugin: VSM_n_Arg (\"%s\") failed "
"with status %i.",
conf->instance, status);
if (VSM_Open (vd))
#endif
{
- ERROR ("varnish plugin: Unable to load statistics.");
+ VSM_Delete (vd);
+ ERROR ("varnish plugin: Unable to open connection.");
return (-1);
}
#else /* if HAVE_VARNISH_V4 */
stats = VSC_Main(vd, NULL);
#endif
+ if (!stats)
+ {
+ VSM_Delete (vd);
+ ERROR ("varnish plugin: Unable to get statistics.");
+
+ return (-1);
+ }
+
varnish_monitor (conf, stats);
- VSM_Close (vd);
+ VSM_Delete (vd);
return (0);
} /* }}} */
#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 */
plugin_register_complex_read (/* group = */ "varnish",
/* name = */ "varnish/localhost",
/* callback = */ varnish_read,
- /* interval = */ NULL,
+ /* interval = */ 0,
/* user data = */ &ud);
return (0);
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 "
&& !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.",
plugin_register_complex_read (/* group = */ "varnish",
/* name = */ callback_name,
/* callback = */ varnish_read,
- /* interval = */ NULL,
+ /* interval = */ 0,
/* user data = */ &ud);
have_instance = 1;