2 * collectd - src/varnish.c
3 * Copyright (C) 2010 Jérôme Renard
4 * Copyright (C) 2010 Marc Fournier
5 * Copyright (C) 2010-2012 Florian Forster
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; only version 2 of the License is applicable.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 * Jérôme Renard <jerome.renard at gmail.com>
22 * Marc Fournier <marc.fournier at camptocamp.com>
23 * Florian octo Forster <octo at collectd.org>
29 #include "configfile.h"
31 #include <varnish/varnishapi.h>
34 # include <varnish/vsc.h>
35 typedef struct VSC_C_main c_varnish_stats_t;
39 typedef struct varnish_stats c_varnish_stats_t;
42 /* {{{ user_config_s */
43 struct user_config_s {
47 _Bool collect_connections;
49 _Bool collect_backend;
50 #ifdef HAVE_VARNISH_V3
55 _Bool collect_objects;
61 _Bool collect_session;
72 _Bool collect_workers;
74 typedef struct user_config_s user_config_t; /* }}} */
76 static _Bool have_instance = 0;
78 static int varnish_submit (const char *plugin_instance, /* {{{ */
79 const char *category, const char *type, const char *type_instance, value_t value)
81 value_list_t vl = VALUE_LIST_INIT;
86 sstrncpy (vl.host, hostname_g, sizeof (vl.host));
88 sstrncpy (vl.plugin, "varnish", sizeof (vl.plugin));
90 if (plugin_instance == NULL)
91 plugin_instance = "default";
93 ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
94 "%s-%s", plugin_instance, category);
96 sstrncpy (vl.type, type, sizeof (vl.type));
98 if (type_instance != NULL)
99 sstrncpy (vl.type_instance, type_instance,
100 sizeof (vl.type_instance));
102 return (plugin_dispatch_values (&vl));
103 } /* }}} int varnish_submit */
105 static int varnish_submit_gauge (const char *plugin_instance, /* {{{ */
106 const char *category, const char *type, const char *type_instance,
107 uint64_t gauge_value)
111 value.gauge = (gauge_t) gauge_value;
113 return (varnish_submit (plugin_instance, category, type, type_instance, value));
114 } /* }}} int varnish_submit_gauge */
116 static int varnish_submit_derive (const char *plugin_instance, /* {{{ */
117 const char *category, const char *type, const char *type_instance,
118 uint64_t derive_value)
122 value.derive = (derive_t) derive_value;
124 return (varnish_submit (plugin_instance, category, type, type_instance, value));
125 } /* }}} int varnish_submit_derive */
127 static void varnish_monitor (const user_config_t *conf, /* {{{ */
128 const c_varnish_stats_t *stats)
130 if (conf->collect_cache)
133 varnish_submit_derive (conf->instance, "cache", "cache_result", "hit", stats->cache_hit);
135 varnish_submit_derive (conf->instance, "cache", "cache_result", "miss", stats->cache_miss);
136 /* Cache hits for pass */
137 varnish_submit_derive (conf->instance, "cache", "cache_result", "hitpass", stats->cache_hitpass);
140 if (conf->collect_connections)
142 /* Client connections accepted */
143 varnish_submit_derive (conf->instance, "connections", "connections", "accepted", stats->client_conn);
144 /* Connection dropped, no sess */
145 varnish_submit_derive (conf->instance, "connections", "connections", "dropped" , stats->client_drop);
146 /* Client requests received */
147 varnish_submit_derive (conf->instance, "connections", "connections", "received", stats->client_req);
150 #ifdef HAVE_VARNISH_V3
151 if (conf->collect_dirdns)
153 /* DNS director lookups */
154 varnish_submit_derive (conf->instance, "dirdns", "cache_operation", "lookups", stats->dir_dns_lookups);
155 /* DNS director failed lookups */
156 varnish_submit_derive (conf->instance, "dirdns", "cache_result", "failed", stats->dir_dns_failed);
157 /* DNS director cached lookups hit */
158 varnish_submit_derive (conf->instance, "dirdns", "cache_result", "hits", stats->dir_dns_hit);
159 /* DNS director full dnscache */
160 varnish_submit_derive (conf->instance, "dirdns", "cache_result", "cache_full", stats->dir_dns_cache_full);
164 if (conf->collect_esi)
166 /* ESI parse errors (unlock) */
167 varnish_submit_derive (conf->instance, "esi", "total_operations", "error", stats->esi_errors);
169 /* Objects ESI parsed (unlock) */
170 varnish_submit_derive (conf->instance, "esi", "total_operations", "parsed", stats->esi_parse);
172 /* ESI parse warnings (unlock) */
173 varnish_submit_derive (conf->instance, "esi", "total_operations", "warning", stats->esi_warnings);
177 if (conf->collect_backend)
179 /* Backend conn. success */
180 varnish_submit_derive (conf->instance, "backend", "connections", "success" , stats->backend_conn);
181 /* Backend conn. not attempted */
182 varnish_submit_derive (conf->instance, "backend", "connections", "not-attempted", stats->backend_unhealthy);
183 /* Backend conn. too many */
184 varnish_submit_derive (conf->instance, "backend", "connections", "too-many" , stats->backend_busy);
185 /* Backend conn. failures */
186 varnish_submit_derive (conf->instance, "backend", "connections", "failures" , stats->backend_fail);
187 /* Backend conn. reuses */
188 varnish_submit_derive (conf->instance, "backend", "connections", "reuses" , stats->backend_reuse);
189 /* Backend conn. was closed */
190 varnish_submit_derive (conf->instance, "backend", "connections", "was-closed" , stats->backend_toolate);
191 /* Backend conn. recycles */
192 varnish_submit_derive (conf->instance, "backend", "connections", "recycled" , stats->backend_recycle);
194 /* Backend conn. unused */
195 varnish_submit_derive (conf->instance, "backend", "connections", "unused" , stats->backend_unused);
197 /* Backend conn. retry */
198 varnish_submit_derive (conf->instance, "backend", "connections", "retries" , stats->backend_retry);
200 /* Backend requests mades */
201 varnish_submit_derive (conf->instance, "backend", "http_requests", "requests" , stats->backend_req);
203 varnish_submit_gauge (conf->instance, "backend", "backends", "n_backends" , stats->n_backend);
206 if (conf->collect_fetch)
209 varnish_submit_derive (conf->instance, "fetch", "http_requests", "head" , stats->fetch_head);
210 /* Fetch with length */
211 varnish_submit_derive (conf->instance, "fetch", "http_requests", "length" , stats->fetch_length);
213 varnish_submit_derive (conf->instance, "fetch", "http_requests", "chunked" , stats->fetch_chunked);
215 varnish_submit_derive (conf->instance, "fetch", "http_requests", "eof" , stats->fetch_eof);
216 /* Fetch bad headers */
217 varnish_submit_derive (conf->instance, "fetch", "http_requests", "bad_headers", stats->fetch_bad);
218 /* Fetch wanted close */
219 varnish_submit_derive (conf->instance, "fetch", "http_requests", "close" , stats->fetch_close);
220 /* Fetch pre HTTP/1.1 closed */
221 varnish_submit_derive (conf->instance, "fetch", "http_requests", "oldhttp" , stats->fetch_oldhttp);
223 varnish_submit_derive (conf->instance, "fetch", "http_requests", "zero" , stats->fetch_zero);
225 varnish_submit_derive (conf->instance, "fetch", "http_requests", "failed" , stats->fetch_failed);
227 /* Fetch no body (1xx) */
228 varnish_submit_derive (conf->instance, "fetch", "http_requests", "no_body_1xx", stats->fetch_1xx);
229 /* Fetch no body (204) */
230 varnish_submit_derive (conf->instance, "fetch", "http_requests", "no_body_204", stats->fetch_204);
231 /* Fetch no body (304) */
232 varnish_submit_derive (conf->instance, "fetch", "http_requests", "no_body_304", stats->fetch_304);
236 if (conf->collect_hcb)
238 /* HCB Lookups without lock */
239 varnish_submit_derive (conf->instance, "hcb", "cache_operation", "lookup_nolock", stats->hcb_nolock);
240 /* HCB Lookups with lock */
241 varnish_submit_derive (conf->instance, "hcb", "cache_operation", "lookup_lock", stats->hcb_lock);
243 varnish_submit_derive (conf->instance, "hcb", "cache_operation", "insert", stats->hcb_insert);
246 if (conf->collect_objects)
248 /* N expired objects */
249 varnish_submit_derive (conf->instance, "objects", "total_objects", "expired", stats->n_expired);
250 /* N LRU nuked objects */
251 varnish_submit_derive (conf->instance, "objects", "total_objects", "lru_nuked", stats->n_lru_nuked);
253 /* N LRU saved objects */
254 varnish_submit_derive (conf->instance, "objects", "total_objects", "lru_saved", stats->n_lru_saved);
256 /* N LRU moved objects */
257 varnish_submit_derive (conf->instance, "objects", "total_objects", "lru_moved", stats->n_lru_moved);
259 /* N objects on deathrow */
260 varnish_submit_derive (conf->instance, "objects", "total_objects", "deathrow", stats->n_deathrow);
262 /* HTTP header overflows */
263 varnish_submit_derive (conf->instance, "objects", "total_objects", "header_overflow", stats->losthdr);
264 /* Objects sent with sendfile */
265 varnish_submit_derive (conf->instance, "objects", "total_objects", "sent_sendfile", stats->n_objsendfile);
266 /* Objects sent with write */
267 varnish_submit_derive (conf->instance, "objects", "total_objects", "sent_write", stats->n_objwrite);
268 /* Objects overflowing workspace */
269 varnish_submit_derive (conf->instance, "objects", "total_objects", "workspace_overflow", stats->n_objoverflow);
273 if (conf->collect_purge)
275 /* N total active purges */
276 varnish_submit_derive (conf->instance, "purge", "total_operations", "total", stats->n_purge);
277 /* N new purges added */
278 varnish_submit_derive (conf->instance, "purge", "total_operations", "added", stats->n_purge_add);
279 /* N old purges deleted */
280 varnish_submit_derive (conf->instance, "purge", "total_operations", "deleted", stats->n_purge_retire);
281 /* N objects tested */
282 varnish_submit_derive (conf->instance, "purge", "total_operations", "objects_tested", stats->n_purge_obj_test);
283 /* N regexps tested against */
284 varnish_submit_derive (conf->instance, "purge", "total_operations", "regexps_tested", stats->n_purge_re_test);
285 /* N duplicate purges removed */
286 varnish_submit_derive (conf->instance, "purge", "total_operations", "duplicate", stats->n_purge_dups);
289 if (conf->collect_ban)
291 /* N total active bans */
292 varnish_submit_derive (conf->instance, "ban", "total_operations", "total", stats->n_ban);
293 /* N new bans added */
294 varnish_submit_derive (conf->instance, "ban", "total_operations", "added", stats->n_ban_add);
295 /* N old bans deleted */
296 varnish_submit_derive (conf->instance, "ban", "total_operations", "deleted", stats->n_ban_retire);
297 /* N objects tested */
298 varnish_submit_derive (conf->instance, "ban", "total_operations", "objects_tested", stats->n_ban_obj_test);
299 /* N regexps tested against */
300 varnish_submit_derive (conf->instance, "ban", "total_operations", "regexps_tested", stats->n_ban_re_test);
301 /* N duplicate bans removed */
302 varnish_submit_derive (conf->instance, "ban", "total_operations", "duplicate", stats->n_ban_dups);
306 if (conf->collect_session)
309 varnish_submit_derive (conf->instance, "session", "total_operations", "closed", stats->sess_closed);
310 /* Session Pipeline */
311 varnish_submit_derive (conf->instance, "session", "total_operations", "pipeline", stats->sess_pipeline);
312 /* Session Read Ahead */
313 varnish_submit_derive (conf->instance, "session", "total_operations", "readahead", stats->sess_readahead);
315 varnish_submit_derive (conf->instance, "session", "total_operations", "linger", stats->sess_linger);
317 varnish_submit_derive (conf->instance, "session", "total_operations", "herd", stats->sess_herd);
320 if (conf->collect_shm)
323 varnish_submit_derive (conf->instance, "shm", "total_operations", "records" , stats->shm_records);
325 varnish_submit_derive (conf->instance, "shm", "total_operations", "writes" , stats->shm_writes);
326 /* SHM flushes due to overflow */
327 varnish_submit_derive (conf->instance, "shm", "total_operations", "flushes" , stats->shm_flushes);
328 /* SHM MTX contention */
329 varnish_submit_derive (conf->instance, "shm", "total_operations", "contention", stats->shm_cont);
330 /* SHM cycles through buffer */
331 varnish_submit_derive (conf->instance, "shm", "total_operations", "cycles" , stats->shm_cycles);
335 if (conf->collect_sm)
337 /* allocator requests */
338 varnish_submit_derive (conf->instance, "sm", "total_requests", "nreq", stats->sm_nreq);
339 /* outstanding allocations */
340 varnish_submit_gauge (conf->instance, "sm", "requests", "outstanding", stats->sm_nobj);
341 /* bytes allocated */
342 varnish_submit_derive (conf->instance, "sm", "total_bytes", "allocated", stats->sm_balloc);
344 varnish_submit_derive (conf->instance, "sm", "total_bytes", "free", stats->sm_bfree);
347 if (conf->collect_sma)
349 /* SMA allocator requests */
350 varnish_submit_derive (conf->instance, "sma", "total_requests", "nreq", stats->sma_nreq);
351 /* SMA outstanding allocations */
352 varnish_submit_gauge (conf->instance, "sma", "requests", "outstanding", stats->sma_nobj);
353 /* SMA outstanding bytes */
354 varnish_submit_gauge (conf->instance, "sma", "bytes", "outstanding", stats->sma_nbytes);
355 /* SMA bytes allocated */
356 varnish_submit_derive (conf->instance, "sma", "total_bytes", "allocated", stats->sma_balloc);
358 varnish_submit_derive (conf->instance, "sma", "total_bytes", "free" , stats->sma_bfree);
362 if (conf->collect_sms)
364 /* SMS allocator requests */
365 varnish_submit_derive (conf->instance, "sms", "total_requests", "allocator", stats->sms_nreq);
366 /* SMS outstanding allocations */
367 varnish_submit_gauge (conf->instance, "sms", "requests", "outstanding", stats->sms_nobj);
368 /* SMS outstanding bytes */
369 varnish_submit_gauge (conf->instance, "sms", "bytes", "outstanding", stats->sms_nbytes);
370 /* SMS bytes allocated */
371 varnish_submit_derive (conf->instance, "sms", "total_bytes", "allocated", stats->sms_balloc);
372 /* SMS bytes freed */
373 varnish_submit_derive (conf->instance, "sms", "total_bytes", "free", stats->sms_bfree);
376 if (conf->collect_struct)
378 /* N struct sess_mem */
379 varnish_submit_gauge (conf->instance, "struct", "current_sessions", "sess_mem", stats->n_sess_mem);
381 varnish_submit_gauge (conf->instance, "struct", "current_sessions", "sess", stats->n_sess);
382 /* N struct object */
383 varnish_submit_gauge (conf->instance, "struct", "objects", "object", stats->n_object);
384 /* N unresurrected objects */
385 varnish_submit_gauge (conf->instance, "struct", "objects", "vampireobject", stats->n_vampireobject);
386 /* N struct objectcore */
387 varnish_submit_gauge (conf->instance, "struct", "objects", "objectcore", stats->n_objectcore);
388 /* N struct objecthead */
389 varnish_submit_gauge (conf->instance, "struct", "objects", "objecthead", stats->n_objecthead);
390 #ifdef HAVE_VARNISH_V2
392 varnish_submit_gauge (conf->instance, "struct", "objects", "smf", stats->n_smf);
393 /* N small free smf */
394 varnish_submit_gauge (conf->instance, "struct", "objects", "smf_frag", stats->n_smf_frag);
395 /* N large free smf */
396 varnish_submit_gauge (conf->instance, "struct", "objects", "smf_large", stats->n_smf_large);
397 /* N struct vbe_conn */
398 varnish_submit_gauge (conf->instance, "struct", "objects", "vbe_conn", stats->n_vbe_conn);
402 if (conf->collect_totals)
405 varnish_submit_derive (conf->instance, "totals", "total_sessions", "sessions", stats->s_sess);
407 varnish_submit_derive (conf->instance, "totals", "total_requests", "requests", stats->s_req);
409 varnish_submit_derive (conf->instance, "totals", "total_operations", "pipe", stats->s_pipe);
411 varnish_submit_derive (conf->instance, "totals", "total_operations", "pass", stats->s_pass);
413 varnish_submit_derive (conf->instance, "totals", "total_operations", "fetches", stats->s_fetch);
414 /* Total header bytes */
415 varnish_submit_derive (conf->instance, "totals", "total_bytes", "header-bytes", stats->s_hdrbytes);
416 /* Total body byte */
417 varnish_submit_derive (conf->instance, "totals", "total_bytes", "body-bytes", stats->s_bodybytes);
420 if (conf->collect_uptime)
423 varnish_submit_gauge (conf->instance, "uptime", "uptime", "client_uptime", stats->uptime);
426 if (conf->collect_vcl)
429 varnish_submit_gauge (conf->instance, "vcl", "vcl", "total_vcl", stats->n_vcl);
430 /* N vcl available */
431 varnish_submit_gauge (conf->instance, "vcl", "vcl", "avail_vcl", stats->n_vcl_avail);
432 /* N vcl discarded */
433 varnish_submit_gauge (conf->instance, "vcl", "vcl", "discarded_vcl", stats->n_vcl_discard);
436 if (conf->collect_workers)
439 varnish_submit_gauge (conf->instance, "workers", "threads", "worker", stats->n_wrk);
440 /* worker threads created */
441 varnish_submit_derive (conf->instance, "workers", "total_threads", "created", stats->n_wrk_create);
442 /* worker threads not created */
443 varnish_submit_derive (conf->instance, "workers", "total_threads", "failed", stats->n_wrk_failed);
444 /* worker threads limited */
445 varnish_submit_derive (conf->instance, "workers", "total_threads", "limited", stats->n_wrk_max);
446 /* dropped work requests */
447 varnish_submit_derive (conf->instance, "workers", "total_requests", "dropped", stats->n_wrk_drop);
448 #ifdef HAVE_VARNISH_V2
449 /* queued work requests */
450 varnish_submit_derive (conf->instance, "workers", "total_requests", "queued", stats->n_wrk_queue);
451 /* overflowed work requests */
452 varnish_submit_derive (conf->instance, "workers", "total_requests", "overflowed", stats->n_wrk_overflow);
454 /* queued work requests */
455 varnish_submit_derive (conf->instance, "workers", "total_requests", "queued", stats->n_wrk_queued);
456 /* work request queue length */
457 varnish_submit_derive (conf->instance, "workers", "total_requests", "queue_length", stats->n_wrk_lqueue);
460 } /* }}} void varnish_monitor */
463 static int varnish_read (user_data_t *ud) /* {{{ */
466 const c_varnish_stats_t *stats;
470 if ((ud == NULL) || (ud->data == NULL))
478 if (conf->instance != NULL)
482 status = VSM_n_Arg (vd, conf->instance);
485 ERROR ("varnish plugin: VSM_n_Arg (\"%s\") failed "
487 conf->instance, status);
492 if (VSC_Open (vd, /* diag = */ 1))
494 ERROR ("varnish plugin: Unable to load statistics.");
499 stats = VSC_Main(vd);
501 varnish_monitor (conf, stats);
506 #else /* if HAVE_VARNISH_V2 */
507 static int varnish_read (user_data_t *ud) /* {{{ */
509 const c_varnish_stats_t *stats;
513 if ((ud == NULL) || (ud->data == NULL))
518 stats = VSL_OpenStats (conf->instance);
521 ERROR ("Varnish plugin : unable to load statistics");
526 varnish_monitor (conf, stats);
532 static void varnish_config_free (void *ptr) /* {{{ */
534 user_config_t *conf = ptr;
539 sfree (conf->instance);
543 static int varnish_config_apply_default (user_config_t *conf) /* {{{ */
548 conf->collect_backend = 1;
549 conf->collect_cache = 1;
550 conf->collect_connections = 1;
551 #ifdef HAVE_VARNISH_V3
552 conf->collect_dirdns = 0;
554 conf->collect_esi = 0;
555 conf->collect_fetch = 0;
556 conf->collect_hcb = 0;
557 conf->collect_objects = 0;
559 conf->collect_purge = 0;
561 conf->collect_ban = 0;
563 conf->collect_session = 0;
564 conf->collect_shm = 1;
566 conf->collect_sm = 0;
567 conf->collect_sma = 0;
569 conf->collect_sms = 0;
570 conf->collect_struct = 0;
571 conf->collect_totals = 0;
572 conf->collect_uptime = 0;
573 conf->collect_vcl = 0;
574 conf->collect_workers = 0;
577 } /* }}} int varnish_config_apply_default */
579 static int varnish_init (void) /* {{{ */
587 conf = malloc (sizeof (*conf));
590 memset (conf, 0, sizeof (*conf));
592 /* Default settings: */
593 conf->instance = NULL;
595 varnish_config_apply_default (conf);
598 ud.free_func = varnish_config_free;
600 plugin_register_complex_read (/* group = */ "varnish",
601 /* name = */ "varnish/localhost",
602 /* callback = */ varnish_read,
603 /* interval = */ NULL,
604 /* user data = */ &ud);
607 } /* }}} int varnish_init */
609 static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */
613 char callback_name[DATA_MAX_NAME_LEN];
616 conf = malloc (sizeof (*conf));
619 memset (conf, 0, sizeof (*conf));
620 conf->instance = NULL;
622 varnish_config_apply_default (conf);
624 if (ci->values_num == 1)
628 status = cf_util_get_string (ci, &conf->instance);
634 assert (conf->instance != NULL);
636 if (strcmp ("localhost", conf->instance) == 0)
638 sfree (conf->instance);
639 conf->instance = NULL;
642 else if (ci->values_num > 1)
644 WARNING ("Varnish plugin: \"Instance\" blocks accept only "
649 for (i = 0; i < ci->children_num; i++)
651 oconfig_item_t *child = ci->children + i;
653 if (strcasecmp ("CollectCache", child->key) == 0)
654 cf_util_get_boolean (child, &conf->collect_cache);
655 else if (strcasecmp ("CollectConnections", child->key) == 0)
656 cf_util_get_boolean (child, &conf->collect_connections);
657 else if (strcasecmp ("CollectESI", child->key) == 0)
658 cf_util_get_boolean (child, &conf->collect_esi);
659 #ifdef HAVE_VARNISH_V3
660 else if (strcasecmp ("CollectDirectorDNS", child->key) == 0)
661 cf_util_get_boolean (child, &conf->collect_dirdns);
663 else if (strcasecmp ("CollectBackend", child->key) == 0)
664 cf_util_get_boolean (child, &conf->collect_backend);
665 else if (strcasecmp ("CollectFetch", child->key) == 0)
666 cf_util_get_boolean (child, &conf->collect_fetch);
667 else if (strcasecmp ("CollectHCB", child->key) == 0)
668 cf_util_get_boolean (child, &conf->collect_hcb);
669 else if (strcasecmp ("CollectObjects", child->key) == 0)
670 cf_util_get_boolean (child, &conf->collect_objects);
672 else if (strcasecmp ("CollectPurge", child->key) == 0)
673 cf_util_get_boolean (child, &conf->collect_purge);
675 else if (strcasecmp ("CollectBan", child->key) == 0)
676 cf_util_get_boolean (child, &conf->collect_ban);
678 else if (strcasecmp ("CollectSession", child->key) == 0)
679 cf_util_get_boolean (child, &conf->collect_session);
680 else if (strcasecmp ("CollectSHM", child->key) == 0)
681 cf_util_get_boolean (child, &conf->collect_shm);
682 else if (strcasecmp ("CollectSMS", child->key) == 0)
683 cf_util_get_boolean (child, &conf->collect_sms);
685 else if (strcasecmp ("CollectSMA", child->key) == 0)
686 cf_util_get_boolean (child, &conf->collect_sma);
687 else if (strcasecmp ("CollectSM", child->key) == 0)
688 cf_util_get_boolean (child, &conf->collect_sm);
690 else if (strcasecmp ("CollectStruct", child->key) == 0)
691 cf_util_get_boolean (child, &conf->collect_struct);
692 else if (strcasecmp ("CollectTotals", child->key) == 0)
693 cf_util_get_boolean (child, &conf->collect_totals);
694 else if (strcasecmp ("CollectUptime", child->key) == 0)
695 cf_util_get_boolean (child, &conf->collect_uptime);
696 else if (strcasecmp ("CollectVCL", child->key) == 0)
697 cf_util_get_boolean (child, &conf->collect_vcl);
698 else if (strcasecmp ("CollectWorkers", child->key) == 0)
699 cf_util_get_boolean (child, &conf->collect_workers);
702 WARNING ("Varnish plugin: Ignoring unknown "
703 "configuration option: \"%s\"",
708 if (!conf->collect_cache
709 && !conf->collect_connections
710 && !conf->collect_esi
711 && !conf->collect_backend
712 #ifdef HAVE_VARNISH_V3
713 && !conf->collect_dirdns
715 && !conf->collect_fetch
716 && !conf->collect_hcb
717 && !conf->collect_objects
719 && !conf->collect_purge
721 && !conf->collect_ban
723 && !conf->collect_session
724 && !conf->collect_shm
725 && !conf->collect_sms
727 && !conf->collect_sma
730 && !conf->collect_struct
731 && !conf->collect_totals
732 && !conf->collect_uptime
733 && !conf->collect_vcl
734 && !conf->collect_workers)
736 WARNING ("Varnish plugin: No metric has been configured for "
737 "instance \"%s\". Disabling this instance.",
738 (conf->instance == NULL) ? "localhost" : conf->instance);
742 ssnprintf (callback_name, sizeof (callback_name), "varnish/%s",
743 (conf->instance == NULL) ? "localhost" : conf->instance);
746 ud.free_func = varnish_config_free;
748 plugin_register_complex_read (/* group = */ "varnish",
749 /* name = */ callback_name,
750 /* callback = */ varnish_read,
751 /* interval = */ NULL,
752 /* user data = */ &ud);
757 } /* }}} int varnish_config_instance */
759 static int varnish_config (oconfig_item_t *ci) /* {{{ */
763 for (i = 0; i < ci->children_num; i++)
765 oconfig_item_t *child = ci->children + i;
767 if (strcasecmp ("Instance", child->key) == 0)
768 varnish_config_instance (child);
771 WARNING ("Varnish plugin: Ignoring unknown "
772 "configuration option: \"%s\"",
778 } /* }}} int varnish_config */
780 void module_register (void) /* {{{ */
782 plugin_register_complex_config ("varnish", varnish_config);
783 plugin_register_init ("varnish", varnish_init);
786 /* vim: set sw=8 noet fdm=marker : */