From: Florian Forster Date: Sat, 12 Jun 2010 10:15:36 +0000 (+0200) Subject: Varnish plugin: Apply the default setting to empty blocks. X-Git-Tag: collectd-5.0.0-beta0~103^2~5 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d14e0f75aefc86eb465fef9ea9ffa75d051311f4;p=collectd.git Varnish plugin: Apply the default setting to empty blocks. --- diff --git a/src/varnish.c b/src/varnish.c index 94085420..33c57ec9 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -385,6 +385,19 @@ static void varnish_config_free (void *ptr) /* {{{ */ sfree (conf); } /* }}} */ +static int varnish_config_apply_default (user_config_t *conf) /* {{{ */ +{ + if (conf == NULL) + return (EINVAL); + + conf->collect_cache = 1; + conf->collect_backend = 1; + conf->collect_connections = 1; + conf->collect_shm = 1; + + return (0); +} /* }}} int varnish_config_apply_default */ + static int varnish_init (void) /* {{{ */ { user_config_t *conf; @@ -400,10 +413,8 @@ static int varnish_init (void) /* {{{ */ /* Default settings: */ conf->instance = NULL; - conf->collect_cache = 1; - conf->collect_backend = 1; - conf->collect_connections = 1; - conf->collect_shm = 1; + + varnish_config_apply_default (conf); ud.data = conf; ud.free_func = varnish_config_free; @@ -501,10 +512,7 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ && !conf->collect_sm && !conf->collect_totals) { - WARNING ("Varnish plugin: No metric has been configured for " - "instance \"%s\". Disabling this instance.", - (conf->instance == NULL) ? "localhost" : conf->instance); - return (EINVAL); + varnish_config_apply_default (conf); } ssnprintf (callback_name, sizeof (callback_name), "varnish/%s",