From: Florian Forster Date: Mon, 7 Jun 2010 16:24:52 +0000 (+0200) Subject: Varnish plugin: Set the instance name as plugin instance. X-Git-Tag: collectd-5.0.0-beta0~103^2~15 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=25e6243a3854f8820959f210592384b48a7ad7d5;p=collectd.git Varnish plugin: Set the instance name as plugin instance. --- diff --git a/src/varnish.c b/src/varnish.c index aa204447..dc69ff53 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -129,9 +129,6 @@ #include -#define USER_CONFIG_INIT {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -#define SET_MONITOR_FLAG(name, flag, value) if((strcasecmp(name, key) == 0) && IS_TRUE(value)) user_config.flag = 1 - /* {{{ user_config_s */ struct user_config_s { char *instance; @@ -151,7 +148,8 @@ typedef struct user_config_s user_config_t; /* }}} */ static _Bool have_instance = 0; -static void varnish_submit(const char *type, const char *type_instance, gauge_t value) /* {{{ */ +static void varnish_submit (const char *plugin_instance, /* {{{ */ + const char *type, const char *type_instance, gauge_t value) { value_t values[1]; value_list_t vl = VALUE_LIST_INIT; @@ -162,6 +160,9 @@ static void varnish_submit(const char *type, const char *type_instance, gauge_t sstrncpy(vl.host , hostname_g , sizeof(vl.host)); sstrncpy(vl.plugin , "varnish" , sizeof(vl.plugin)); + if (plugin_instance != NULL) + sstrncpy (vl.plugin_instance, plugin_instance, + sizeof (vl.plugin_instance)); sstrncpy(vl.type , type , sizeof(vl.type)); sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance)); @@ -172,89 +173,89 @@ static void varnish_monitor(const user_config_t *conf, struct varnish_stats *VSL { if(conf->monitor_cache) { - varnish_submit("varnish_cache_ratio", "cache_hit" , VSL_stats->cache_hit); /* Cache hits */ - varnish_submit("varnish_cache_ratio", "cache_miss" , VSL_stats->cache_miss); /* Cache misses */ - varnish_submit("varnish_cache_ratio", "cache_hitpass", VSL_stats->cache_hitpass); /* Cache hits for pass */ + varnish_submit (conf->instance, "varnish_cache_ratio", "cache_hit" , VSL_stats->cache_hit); /* Cache hits */ + varnish_submit (conf->instance, "varnish_cache_ratio", "cache_miss" , VSL_stats->cache_miss); /* Cache misses */ + varnish_submit (conf->instance, "varnish_cache_ratio", "cache_hitpass", VSL_stats->cache_hitpass); /* Cache hits for pass */ } if(conf->monitor_connections) { - varnish_submit("varnish_connections", "client_connections-accepted", VSL_stats->client_conn); /* Client connections accepted */ - varnish_submit("varnish_connections", "client_connections-dropped" , VSL_stats->client_drop); /* Connection dropped, no sess */ - varnish_submit("varnish_connections", "client_connections-received", VSL_stats->client_req); /* Client requests received */ + varnish_submit (conf->instance, "varnish_connections", "client_connections-accepted", VSL_stats->client_conn); /* Client connections accepted */ + varnish_submit (conf->instance, "varnish_connections", "client_connections-dropped" , VSL_stats->client_drop); /* Connection dropped, no sess */ + varnish_submit (conf->instance, "varnish_connections", "client_connections-received", VSL_stats->client_req); /* Client requests received */ } if(conf->monitor_esi) { - varnish_submit("varnish_esi", "esi_parsed", VSL_stats->esi_parse); /* Objects ESI parsed (unlock) */ - varnish_submit("varnish_esi", "esi_errors", VSL_stats->esi_errors); /* ESI parse errors (unlock) */ + varnish_submit (conf->instance, "varnish_esi", "esi_parsed", VSL_stats->esi_parse); /* Objects ESI parsed (unlock) */ + varnish_submit (conf->instance, "varnish_esi", "esi_errors", VSL_stats->esi_errors); /* ESI parse errors (unlock) */ } if(conf->monitor_backend) { - varnish_submit("varnish_backend_connections", "backend_connections-success" , VSL_stats->backend_conn); /* Backend conn. success */ - varnish_submit("varnish_backend_connections", "backend_connections-not-attempted", VSL_stats->backend_unhealthy); /* Backend conn. not attempted */ - varnish_submit("varnish_backend_connections", "backend_connections-too-many" , VSL_stats->backend_busy); /* Backend conn. too many */ - varnish_submit("varnish_backend_connections", "backend_connections-failures" , VSL_stats->backend_fail); /* Backend conn. failures */ - varnish_submit("varnish_backend_connections", "backend_connections-reuses" , VSL_stats->backend_reuse); /* Backend conn. reuses */ - varnish_submit("varnish_backend_connections", "backend_connections-was-closed" , VSL_stats->backend_toolate); /* Backend conn. was closed */ - varnish_submit("varnish_backend_connections", "backend_connections-recycles" , VSL_stats->backend_recycle); /* Backend conn. recycles */ - varnish_submit("varnish_backend_connections", "backend_connections-unused" , VSL_stats->backend_unused); /* Backend conn. unused */ + varnish_submit (conf->instance, "varnish_backend_connections", "backend_connections-success" , VSL_stats->backend_conn); /* Backend conn. success */ + varnish_submit (conf->instance, "varnish_backend_connections", "backend_connections-not-attempted", VSL_stats->backend_unhealthy); /* Backend conn. not attempted */ + varnish_submit (conf->instance, "varnish_backend_connections", "backend_connections-too-many" , VSL_stats->backend_busy); /* Backend conn. too many */ + varnish_submit (conf->instance, "varnish_backend_connections", "backend_connections-failures" , VSL_stats->backend_fail); /* Backend conn. failures */ + varnish_submit (conf->instance, "varnish_backend_connections", "backend_connections-reuses" , VSL_stats->backend_reuse); /* Backend conn. reuses */ + varnish_submit (conf->instance, "varnish_backend_connections", "backend_connections-was-closed" , VSL_stats->backend_toolate); /* Backend conn. was closed */ + varnish_submit (conf->instance, "varnish_backend_connections", "backend_connections-recycles" , VSL_stats->backend_recycle); /* Backend conn. recycles */ + varnish_submit (conf->instance, "varnish_backend_connections", "backend_connections-unused" , VSL_stats->backend_unused); /* Backend conn. unused */ } if(conf->monitor_fetch) { - varnish_submit("varnish_fetch", "fetch_head" , VSL_stats->fetch_head); /* Fetch head */ - varnish_submit("varnish_fetch", "fetch_length" , VSL_stats->fetch_length); /* Fetch with length */ - varnish_submit("varnish_fetch", "fetch_chunked" , VSL_stats->fetch_chunked); /* Fetch chunked */ - varnish_submit("varnish_fetch", "fetch_eof" , VSL_stats->fetch_eof); /* Fetch EOF */ - varnish_submit("varnish_fetch", "fetch_bad-headers", VSL_stats->fetch_bad); /* Fetch bad headers */ - varnish_submit("varnish_fetch", "fetch_close" , VSL_stats->fetch_close); /* Fetch wanted close */ - varnish_submit("varnish_fetch", "fetch_oldhttp" , VSL_stats->fetch_oldhttp); /* Fetch pre HTTP/1.1 closed */ - varnish_submit("varnish_fetch", "fetch_zero" , VSL_stats->fetch_zero); /* Fetch zero len */ - varnish_submit("varnish_fetch", "fetch_failed" , VSL_stats->fetch_failed); /* Fetch failed */ + varnish_submit (conf->instance, "varnish_fetch", "fetch_head" , VSL_stats->fetch_head); /* Fetch head */ + varnish_submit (conf->instance, "varnish_fetch", "fetch_length" , VSL_stats->fetch_length); /* Fetch with length */ + varnish_submit (conf->instance, "varnish_fetch", "fetch_chunked" , VSL_stats->fetch_chunked); /* Fetch chunked */ + varnish_submit (conf->instance, "varnish_fetch", "fetch_eof" , VSL_stats->fetch_eof); /* Fetch EOF */ + varnish_submit (conf->instance, "varnish_fetch", "fetch_bad-headers", VSL_stats->fetch_bad); /* Fetch bad headers */ + varnish_submit (conf->instance, "varnish_fetch", "fetch_close" , VSL_stats->fetch_close); /* Fetch wanted close */ + varnish_submit (conf->instance, "varnish_fetch", "fetch_oldhttp" , VSL_stats->fetch_oldhttp); /* Fetch pre HTTP/1.1 closed */ + varnish_submit (conf->instance, "varnish_fetch", "fetch_zero" , VSL_stats->fetch_zero); /* Fetch zero len */ + varnish_submit (conf->instance, "varnish_fetch", "fetch_failed" , VSL_stats->fetch_failed); /* Fetch failed */ } if(conf->monitor_hcb) { - varnish_submit("varnish_hcb", "hcb_nolock", VSL_stats->hcb_nolock); /* HCB Lookups without lock */ - varnish_submit("varnish_hcb", "hcb_lock" , VSL_stats->hcb_lock); /* HCB Lookups with lock */ - varnish_submit("varnish_hcb", "hcb_insert", VSL_stats->hcb_insert); /* HCB Inserts */ + varnish_submit (conf->instance, "varnish_hcb", "hcb_nolock", VSL_stats->hcb_nolock); /* HCB Lookups without lock */ + varnish_submit (conf->instance, "varnish_hcb", "hcb_lock" , VSL_stats->hcb_lock); /* HCB Lookups with lock */ + varnish_submit (conf->instance, "varnish_hcb", "hcb_insert", VSL_stats->hcb_insert); /* HCB Inserts */ } if(conf->monitor_shm) { - varnish_submit("varnish_shm", "shm_records" , VSL_stats->shm_records); /* SHM records */ - varnish_submit("varnish_shm", "shm_writes" , VSL_stats->shm_writes); /* SHM writes */ - varnish_submit("varnish_shm", "shm_flushes" , VSL_stats->shm_flushes); /* SHM flushes due to overflow */ - varnish_submit("varnish_shm", "shm_contention", VSL_stats->shm_cont); /* SHM MTX contention */ - varnish_submit("varnish_shm", "shm_cycles" , VSL_stats->shm_cycles); /* SHM cycles through buffer */ + varnish_submit (conf->instance, "varnish_shm", "shm_records" , VSL_stats->shm_records); /* SHM records */ + varnish_submit (conf->instance, "varnish_shm", "shm_writes" , VSL_stats->shm_writes); /* SHM writes */ + varnish_submit (conf->instance, "varnish_shm", "shm_flushes" , VSL_stats->shm_flushes); /* SHM flushes due to overflow */ + varnish_submit (conf->instance, "varnish_shm", "shm_contention", VSL_stats->shm_cont); /* SHM MTX contention */ + varnish_submit (conf->instance, "varnish_shm", "shm_cycles" , VSL_stats->shm_cycles); /* SHM cycles through buffer */ } if(conf->monitor_sma) { - varnish_submit("varnish_sma", "sma_req" , VSL_stats->sma_nreq); /* SMA allocator requests */ - varnish_submit("varnish_sma", "sma_nobj" , VSL_stats->sma_nobj); /* SMA outstanding allocations */ - varnish_submit("varnish_sma", "sma_nbytes", VSL_stats->sma_nbytes); /* SMA outstanding bytes */ - varnish_submit("varnish_sma", "sma_balloc", VSL_stats->sma_balloc); /* SMA bytes allocated */ - varnish_submit("varnish_sma", "sma_bfree" , VSL_stats->sma_bfree); /* SMA bytes free */ + varnish_submit (conf->instance, "varnish_sma", "sma_req" , VSL_stats->sma_nreq); /* SMA allocator requests */ + varnish_submit (conf->instance, "varnish_sma", "sma_nobj" , VSL_stats->sma_nobj); /* SMA outstanding allocations */ + varnish_submit (conf->instance, "varnish_sma", "sma_nbytes", VSL_stats->sma_nbytes); /* SMA outstanding bytes */ + varnish_submit (conf->instance, "varnish_sma", "sma_balloc", VSL_stats->sma_balloc); /* SMA bytes allocated */ + varnish_submit (conf->instance, "varnish_sma", "sma_bfree" , VSL_stats->sma_bfree); /* SMA bytes free */ } if(conf->monitor_sms) { - varnish_submit("varnish_sms", "sms_nreq" , VSL_stats->sms_nreq); /* SMS allocator requests */ - varnish_submit("varnish_sms", "sms_nobj" , VSL_stats->sms_nobj); /* SMS outstanding allocations */ - varnish_submit("varnish_sms", "sms_nbytes", VSL_stats->sms_nbytes); /* SMS outstanding bytes */ - varnish_submit("varnish_sms", "sms_balloc", VSL_stats->sms_balloc); /* SMS bytes allocated */ - varnish_submit("varnish_sms", "sms_bfree" , VSL_stats->sms_bfree); /* SMS bytes freed */ + varnish_submit (conf->instance, "varnish_sms", "sms_nreq" , VSL_stats->sms_nreq); /* SMS allocator requests */ + varnish_submit (conf->instance, "varnish_sms", "sms_nobj" , VSL_stats->sms_nobj); /* SMS outstanding allocations */ + varnish_submit (conf->instance, "varnish_sms", "sms_nbytes", VSL_stats->sms_nbytes); /* SMS outstanding bytes */ + varnish_submit (conf->instance, "varnish_sms", "sms_balloc", VSL_stats->sms_balloc); /* SMS bytes allocated */ + varnish_submit (conf->instance, "varnish_sms", "sms_bfree" , VSL_stats->sms_bfree); /* SMS bytes freed */ } if(conf->monitor_sm) { - varnish_submit("varnish_sm", "sm_nreq" , VSL_stats->sm_nreq); /* allocator requests */ - varnish_submit("varnish_sm", "sm_nobj" , VSL_stats->sm_nobj); /* outstanding allocations */ - varnish_submit("varnish_sm", "sm_balloc", VSL_stats->sm_balloc); /* bytes allocated */ - varnish_submit("varnish_sm", "sm_bfree" , VSL_stats->sm_bfree); /* bytes free */ + varnish_submit (conf->instance, "varnish_sm", "sm_nreq" , VSL_stats->sm_nreq); /* allocator requests */ + varnish_submit (conf->instance, "varnish_sm", "sm_nobj" , VSL_stats->sm_nobj); /* outstanding allocations */ + varnish_submit (conf->instance, "varnish_sm", "sm_balloc", VSL_stats->sm_balloc); /* bytes allocated */ + varnish_submit (conf->instance, "varnish_sm", "sm_bfree" , VSL_stats->sm_bfree); /* bytes free */ } } /* }}} */