if (plugin_instance == NULL)
plugin_instance = "default";
- ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s-%s",
- plugin_instance, category);
+ snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s-%s",
+ plugin_instance, category);
sstrncpy(vl.type, type, sizeof(vl.type));
if (type_instance != NULL)
sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));
- return (plugin_dispatch_values(&vl));
+ return plugin_dispatch_values(&vl);
} /* }}} int varnish_submit */
static int varnish_submit_gauge(const char *plugin_instance, /* {{{ */
const char *category, const char *type,
const char *type_instance,
uint64_t gauge_value) {
- return (varnish_submit(plugin_instance, category, type, type_instance,
- (value_t){.gauge = (gauge_t)gauge_value}));
+ return varnish_submit(plugin_instance, category, type, type_instance,
+ (value_t){
+ .gauge = (gauge_t)gauge_value,
+ });
} /* }}} int varnish_submit_gauge */
static int varnish_submit_derive(const char *plugin_instance, /* {{{ */
const char *category, const char *type,
const char *type_instance,
uint64_t derive_value) {
- return (varnish_submit(plugin_instance, category, type, type_instance,
- (value_t){.derive = (derive_t)derive_value}));
+ return varnish_submit(plugin_instance, category, type, type_instance,
+ (value_t){
+ .derive = (derive_t)derive_value,
+ });
} /* }}} int varnish_submit_derive */
#if HAVE_VARNISH_V3 || HAVE_VARNISH_V4
const char *name;
if (pt == NULL)
- return (0);
+ return 0;
conf = priv;
name = pt->desc->name;
if (strcmp(class, "MAIN") != 0)
- return (0);
+ return 0;
#elif HAVE_VARNISH_V3
class = pt->class;
name = pt->name;
if (strcmp(class, "") != 0)
- return (0);
+ return 0;
#endif
val = *(const volatile uint64_t *)pt->ptr;
}
#endif
- return (0);
+ return 0;
} /* }}} static int varnish_monitor */
#else /* if HAVE_VARNISH_V2 */
user_config_t *conf;
if ((ud == NULL) || (ud->data == NULL))
- return (EINVAL);
+ return EINVAL;
conf = ud->data;
ERROR("varnish plugin: VSM_n_Arg (\"%s\") failed "
"with status %i.",
conf->instance, status);
- return (-1);
+ return -1;
}
}
VSM_Delete(vd);
ERROR("varnish plugin: Unable to open connection.");
- return (-1);
+ return -1;
}
#if HAVE_VARNISH_V3
VSM_Delete(vd);
ERROR("varnish plugin: Unable to get statistics.");
- return (-1);
+ return -1;
}
#if HAVE_VARNISH_V3
#endif
VSM_Delete(vd);
- return (0);
+ return 0;
} /* }}} */
#else /* if HAVE_VARNISH_V2 */
static int varnish_read(user_data_t *ud) /* {{{ */
user_config_t *conf;
if ((ud == NULL) || (ud->data == NULL))
- return (EINVAL);
+ return EINVAL;
conf = ud->data;
if (stats == NULL) {
ERROR("Varnish plugin : unable to load statistics");
- return (-1);
+ return -1;
}
varnish_monitor(conf, stats);
- return (0);
+ return 0;
} /* }}} */
#endif
static int varnish_config_apply_default(user_config_t *conf) /* {{{ */
{
if (conf == NULL)
- return (EINVAL);
+ return EINVAL;
conf->collect_backend = 1;
conf->collect_cache = 1;
conf->collect_vsm = 0;
#endif
- return (0);
+ return 0;
} /* }}} int varnish_config_apply_default */
static int varnish_init(void) /* {{{ */
user_config_t *conf;
if (have_instance)
- return (0);
+ return 0;
conf = calloc(1, sizeof(*conf));
if (conf == NULL)
- return (ENOMEM);
+ return ENOMEM;
/* Default settings: */
conf->instance = NULL;
/* group = */ "varnish",
/* name = */ "varnish/localhost",
/* callback = */ varnish_read,
- /* interval = */ 0, &(user_data_t){
- .data = conf, .free_func = varnish_config_free,
- });
+ /* interval = */ 0,
+ &(user_data_t){
+ .data = conf, .free_func = varnish_config_free,
+ });
- return (0);
+ return 0;
} /* }}} int varnish_init */
static int varnish_config_instance(const oconfig_item_t *ci) /* {{{ */
conf = calloc(1, sizeof(*conf));
if (conf == NULL)
- return (ENOMEM);
+ return ENOMEM;
conf->instance = NULL;
varnish_config_apply_default(conf);
status = cf_util_get_string(ci, &conf->instance);
if (status != 0) {
sfree(conf);
- return (status);
+ return status;
}
assert(conf->instance != NULL);
WARNING("Varnish plugin: \"Instance\" blocks accept only "
"one argument.");
sfree(conf);
- return (EINVAL);
+ return EINVAL;
}
for (int i = 0; i < ci->children_num; i++) {
"instance \"%s\". Disabling this instance.",
(conf->instance == NULL) ? "localhost" : conf->instance);
sfree(conf);
- return (EINVAL);
+ return EINVAL;
}
- ssnprintf(callback_name, sizeof(callback_name), "varnish/%s",
- (conf->instance == NULL) ? "localhost" : conf->instance);
+ snprintf(callback_name, sizeof(callback_name), "varnish/%s",
+ (conf->instance == NULL) ? "localhost" : conf->instance);
plugin_register_complex_read(
/* group = */ "varnish",
/* name = */ callback_name,
/* callback = */ varnish_read,
- /* interval = */ 0, &(user_data_t){
- .data = conf, .free_func = varnish_config_free,
- });
+ /* interval = */ 0,
+ &(user_data_t){
+ .data = conf, .free_func = varnish_config_free,
+ });
have_instance = 1;
- return (0);
+ return 0;
} /* }}} int varnish_config_instance */
static int varnish_config(oconfig_item_t *ci) /* {{{ */
}
}
- return (0);
+ return 0;
} /* }}} int varnish_config */
void module_register(void) /* {{{ */