X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fvarnish.c;h=c0460ab042acc9ff9381765ab68a6e5d28b4b9de;hb=daa5c7a886b4406d5b8bfdbecd6f998f9ca07fea;hp=f7bca416880648a0e2a7843c8877a466a3149c96;hpb=8775392f037747cf06edc58a31750c9dcd895a73;p=collectd.git diff --git a/src/varnish.c b/src/varnish.c index f7bca416..c0460ab0 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -67,7 +67,9 @@ struct user_config_s { #endif _Bool collect_struct; _Bool collect_totals; +#ifdef HAVE_VARNISH_V3 _Bool collect_uptime; +#endif _Bool collect_vcl; _Bool collect_workers; }; @@ -381,10 +383,12 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */ varnish_submit_gauge (conf->instance, "struct", "current_sessions", "sess", stats->n_sess); /* N struct object */ varnish_submit_gauge (conf->instance, "struct", "objects", "object", stats->n_object); +#ifdef HAVE_VARNISH_V3 /* N unresurrected objects */ varnish_submit_gauge (conf->instance, "struct", "objects", "vampireobject", stats->n_vampireobject); /* N struct objectcore */ varnish_submit_gauge (conf->instance, "struct", "objects", "objectcore", stats->n_objectcore); +#endif /* N struct objecthead */ varnish_submit_gauge (conf->instance, "struct", "objects", "objecthead", stats->n_objecthead); #ifdef HAVE_VARNISH_V2 @@ -417,11 +421,13 @@ static void varnish_monitor (const user_config_t *conf, /* {{{ */ varnish_submit_derive (conf->instance, "totals", "total_bytes", "body-bytes", stats->s_bodybytes); } +#ifdef HAVE_VARNISH_V3 if (conf->collect_uptime) { /* Client uptime */ varnish_submit_gauge (conf->instance, "uptime", "uptime", "client_uptime", stats->uptime); } +#endif if (conf->collect_vcl) { @@ -499,7 +505,7 @@ static int varnish_read (user_data_t *ud) /* {{{ */ stats = VSC_Main(vd); varnish_monitor (conf, stats); - VSM_Close (vd); + VSM_Delete (vd); return (0); } /* }}} */ @@ -569,7 +575,9 @@ static int varnish_config_apply_default (user_config_t *conf) /* {{{ */ conf->collect_sms = 0; conf->collect_struct = 0; conf->collect_totals = 0; +#ifdef HAVE_VARNISH_V3 conf->collect_uptime = 0; +#endif conf->collect_vcl = 0; conf->collect_workers = 0; @@ -643,6 +651,7 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ { WARNING ("Varnish plugin: \"Instance\" blocks accept only " "one argument."); + sfree (conf); return (EINVAL); } @@ -691,8 +700,10 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ cf_util_get_boolean (child, &conf->collect_struct); else if (strcasecmp ("CollectTotals", child->key) == 0) cf_util_get_boolean (child, &conf->collect_totals); +#ifdef HAVE_VARNISH_V3 else if (strcasecmp ("CollectUptime", child->key) == 0) cf_util_get_boolean (child, &conf->collect_uptime); +#endif else if (strcasecmp ("CollectVCL", child->key) == 0) cf_util_get_boolean (child, &conf->collect_vcl); else if (strcasecmp ("CollectWorkers", child->key) == 0) @@ -700,7 +711,9 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ else { WARNING ("Varnish plugin: Ignoring unknown " - "configuration option: \"%s\"", + "configuration option: \"%s\". Did " + "you forget to add an " + "block around the configuration?", child->key); } } @@ -729,13 +742,16 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ #endif && !conf->collect_struct && !conf->collect_totals +#ifdef HAVE_VARNISH_V3 && !conf->collect_uptime +#endif && !conf->collect_vcl && !conf->collect_workers) { WARNING ("Varnish plugin: No metric has been configured for " "instance \"%s\". Disabling this instance.", (conf->instance == NULL) ? "localhost" : conf->instance); + sfree (conf); return (EINVAL); }