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;
70 #ifdef HAVE_VARNISH_V3
74 _Bool collect_workers;
76 typedef struct user_config_s user_config_t; /* }}} */
78 static _Bool have_instance = 0;
80 static int varnish_submit (const char *plugin_instance, /* {{{ */
81 const char *category, const char *type, const char *type_instance, value_t value)
83 value_list_t vl = VALUE_LIST_INIT;
88 sstrncpy (vl.host, hostname_g, sizeof (vl.host));
90 sstrncpy (vl.plugin, "varnish", sizeof (vl.plugin));
92 if (plugin_instance == NULL)
93 plugin_instance = "default";
95 ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
96 "%s-%s", plugin_instance, category);
98 sstrncpy (vl.type, type, sizeof (vl.type));
100 if (type_instance != NULL)
101 sstrncpy (vl.type_instance, type_instance,
102 sizeof (vl.type_instance));
104 return (plugin_dispatch_values (&vl));
105 } /* }}} int varnish_submit */
107 static int varnish_submit_gauge (const char *plugin_instance, /* {{{ */
108 const char *category, const char *type, const char *type_instance,
109 uint64_t gauge_value)
113 value.gauge = (gauge_t) gauge_value;
115 return (varnish_submit (plugin_instance, category, type, type_instance, value));
116 } /* }}} int varnish_submit_gauge */
118 static int varnish_submit_derive (const char *plugin_instance, /* {{{ */
119 const char *category, const char *type, const char *type_instance,
120 uint64_t derive_value)
124 value.derive = (derive_t) derive_value;
126 return (varnish_submit (plugin_instance, category, type, type_instance, value));
127 } /* }}} int varnish_submit_derive */
129 static void varnish_monitor (const user_config_t *conf, /* {{{ */
130 const c_varnish_stats_t *stats)
132 if (conf->collect_cache)
135 varnish_submit_derive (conf->instance, "cache", "cache_result", "hit", stats->cache_hit);
137 varnish_submit_derive (conf->instance, "cache", "cache_result", "miss", stats->cache_miss);
138 /* Cache hits for pass */
139 varnish_submit_derive (conf->instance, "cache", "cache_result", "hitpass", stats->cache_hitpass);
142 if (conf->collect_connections)
144 /* Client connections accepted */
145 varnish_submit_derive (conf->instance, "connections", "connections", "accepted", stats->client_conn);
146 /* Connection dropped, no sess */
147 varnish_submit_derive (conf->instance, "connections", "connections", "dropped" , stats->client_drop);
148 /* Client requests received */
149 varnish_submit_derive (conf->instance, "connections", "connections", "received", stats->client_req);
152 #ifdef HAVE_VARNISH_V3
153 if (conf->collect_dirdns)
155 /* DNS director lookups */
156 varnish_submit_derive (conf->instance, "dirdns", "cache_operation", "lookups", stats->dir_dns_lookups);
157 /* DNS director failed lookups */
158 varnish_submit_derive (conf->instance, "dirdns", "cache_result", "failed", stats->dir_dns_failed);
159 /* DNS director cached lookups hit */
160 varnish_submit_derive (conf->instance, "dirdns", "cache_result", "hits", stats->dir_dns_hit);
161 /* DNS director full dnscache */
162 varnish_submit_derive (conf->instance, "dirdns", "cache_result", "cache_full", stats->dir_dns_cache_full);
166 if (conf->collect_esi)
168 /* ESI parse errors (unlock) */
169 varnish_submit_derive (conf->instance, "esi", "total_operations", "error", stats->esi_errors);
171 /* Objects ESI parsed (unlock) */
172 varnish_submit_derive (conf->instance, "esi", "total_operations", "parsed", stats->esi_parse);
174 /* ESI parse warnings (unlock) */
175 varnish_submit_derive (conf->instance, "esi", "total_operations", "warning", stats->esi_warnings);
179 if (conf->collect_backend)
181 /* Backend conn. success */
182 varnish_submit_derive (conf->instance, "backend", "connections", "success" , stats->backend_conn);
183 /* Backend conn. not attempted */
184 varnish_submit_derive (conf->instance, "backend", "connections", "not-attempted", stats->backend_unhealthy);
185 /* Backend conn. too many */
186 varnish_submit_derive (conf->instance, "backend", "connections", "too-many" , stats->backend_busy);
187 /* Backend conn. failures */
188 varnish_submit_derive (conf->instance, "backend", "connections", "failures" , stats->backend_fail);
189 /* Backend conn. reuses */
190 varnish_submit_derive (conf->instance, "backend", "connections", "reuses" , stats->backend_reuse);
191 /* Backend conn. was closed */
192 varnish_submit_derive (conf->instance, "backend", "connections", "was-closed" , stats->backend_toolate);
193 /* Backend conn. recycles */
194 varnish_submit_derive (conf->instance, "backend", "connections", "recycled" , stats->backend_recycle);
196 /* Backend conn. unused */
197 varnish_submit_derive (conf->instance, "backend", "connections", "unused" , stats->backend_unused);
199 /* Backend conn. retry */
200 varnish_submit_derive (conf->instance, "backend", "connections", "retries" , stats->backend_retry);
202 /* Backend requests mades */
203 varnish_submit_derive (conf->instance, "backend", "http_requests", "requests" , stats->backend_req);
205 varnish_submit_gauge (conf->instance, "backend", "backends", "n_backends" , stats->n_backend);
208 if (conf->collect_fetch)
211 varnish_submit_derive (conf->instance, "fetch", "http_requests", "head" , stats->fetch_head);
212 /* Fetch with length */
213 varnish_submit_derive (conf->instance, "fetch", "http_requests", "length" , stats->fetch_length);
215 varnish_submit_derive (conf->instance, "fetch", "http_requests", "chunked" , stats->fetch_chunked);
217 varnish_submit_derive (conf->instance, "fetch", "http_requests", "eof" , stats->fetch_eof);
218 /* Fetch bad headers */
219 varnish_submit_derive (conf->instance, "fetch", "http_requests", "bad_headers", stats->fetch_bad);
220 /* Fetch wanted close */
221 varnish_submit_derive (conf->instance, "fetch", "http_requests", "close" , stats->fetch_close);
222 /* Fetch pre HTTP/1.1 closed */
223 varnish_submit_derive (conf->instance, "fetch", "http_requests", "oldhttp" , stats->fetch_oldhttp);
225 varnish_submit_derive (conf->instance, "fetch", "http_requests", "zero" , stats->fetch_zero);
227 varnish_submit_derive (conf->instance, "fetch", "http_requests", "failed" , stats->fetch_failed);
229 /* Fetch no body (1xx) */
230 varnish_submit_derive (conf->instance, "fetch", "http_requests", "no_body_1xx", stats->fetch_1xx);
231 /* Fetch no body (204) */
232 varnish_submit_derive (conf->instance, "fetch", "http_requests", "no_body_204", stats->fetch_204);
233 /* Fetch no body (304) */
234 varnish_submit_derive (conf->instance, "fetch", "http_requests", "no_body_304", stats->fetch_304);
238 if (conf->collect_hcb)
240 /* HCB Lookups without lock */
241 varnish_submit_derive (conf->instance, "hcb", "cache_operation", "lookup_nolock", stats->hcb_nolock);
242 /* HCB Lookups with lock */
243 varnish_submit_derive (conf->instance, "hcb", "cache_operation", "lookup_lock", stats->hcb_lock);
245 varnish_submit_derive (conf->instance, "hcb", "cache_operation", "insert", stats->hcb_insert);
248 if (conf->collect_objects)
250 /* N expired objects */
251 varnish_submit_derive (conf->instance, "objects", "total_objects", "expired", stats->n_expired);
252 /* N LRU nuked objects */
253 varnish_submit_derive (conf->instance, "objects", "total_objects", "lru_nuked", stats->n_lru_nuked);
255 /* N LRU saved objects */
256 varnish_submit_derive (conf->instance, "objects", "total_objects", "lru_saved", stats->n_lru_saved);
258 /* N LRU moved objects */
259 varnish_submit_derive (conf->instance, "objects", "total_objects", "lru_moved", stats->n_lru_moved);
261 /* N objects on deathrow */
262 varnish_submit_derive (conf->instance, "objects", "total_objects", "deathrow", stats->n_deathrow);
264 /* HTTP header overflows */
265 varnish_submit_derive (conf->instance, "objects", "total_objects", "header_overflow", stats->losthdr);
266 /* Objects sent with sendfile */
267 varnish_submit_derive (conf->instance, "objects", "total_objects", "sent_sendfile", stats->n_objsendfile);
268 /* Objects sent with write */
269 varnish_submit_derive (conf->instance, "objects", "total_objects", "sent_write", stats->n_objwrite);
270 /* Objects overflowing workspace */
271 varnish_submit_derive (conf->instance, "objects", "total_objects", "workspace_overflow", stats->n_objoverflow);
275 if (conf->collect_purge)
277 /* N total active purges */
278 varnish_submit_derive (conf->instance, "purge", "total_operations", "total", stats->n_purge);
279 /* N new purges added */
280 varnish_submit_derive (conf->instance, "purge", "total_operations", "added", stats->n_purge_add);
281 /* N old purges deleted */
282 varnish_submit_derive (conf->instance, "purge", "total_operations", "deleted", stats->n_purge_retire);
283 /* N objects tested */
284 varnish_submit_derive (conf->instance, "purge", "total_operations", "objects_tested", stats->n_purge_obj_test);
285 /* N regexps tested against */
286 varnish_submit_derive (conf->instance, "purge", "total_operations", "regexps_tested", stats->n_purge_re_test);
287 /* N duplicate purges removed */
288 varnish_submit_derive (conf->instance, "purge", "total_operations", "duplicate", stats->n_purge_dups);
291 if (conf->collect_ban)
293 /* N total active bans */
294 varnish_submit_derive (conf->instance, "ban", "total_operations", "total", stats->n_ban);
295 /* N new bans added */
296 varnish_submit_derive (conf->instance, "ban", "total_operations", "added", stats->n_ban_add);
297 /* N old bans deleted */
298 varnish_submit_derive (conf->instance, "ban", "total_operations", "deleted", stats->n_ban_retire);
299 /* N objects tested */
300 varnish_submit_derive (conf->instance, "ban", "total_operations", "objects_tested", stats->n_ban_obj_test);
301 /* N regexps tested against */
302 varnish_submit_derive (conf->instance, "ban", "total_operations", "regexps_tested", stats->n_ban_re_test);
303 /* N duplicate bans removed */
304 varnish_submit_derive (conf->instance, "ban", "total_operations", "duplicate", stats->n_ban_dups);
308 if (conf->collect_session)
311 varnish_submit_derive (conf->instance, "session", "total_operations", "closed", stats->sess_closed);
312 /* Session Pipeline */
313 varnish_submit_derive (conf->instance, "session", "total_operations", "pipeline", stats->sess_pipeline);
314 /* Session Read Ahead */
315 varnish_submit_derive (conf->instance, "session", "total_operations", "readahead", stats->sess_readahead);
317 varnish_submit_derive (conf->instance, "session", "total_operations", "linger", stats->sess_linger);
319 varnish_submit_derive (conf->instance, "session", "total_operations", "herd", stats->sess_herd);
322 if (conf->collect_shm)
325 varnish_submit_derive (conf->instance, "shm", "total_operations", "records" , stats->shm_records);
327 varnish_submit_derive (conf->instance, "shm", "total_operations", "writes" , stats->shm_writes);
328 /* SHM flushes due to overflow */
329 varnish_submit_derive (conf->instance, "shm", "total_operations", "flushes" , stats->shm_flushes);
330 /* SHM MTX contention */
331 varnish_submit_derive (conf->instance, "shm", "total_operations", "contention", stats->shm_cont);
332 /* SHM cycles through buffer */
333 varnish_submit_derive (conf->instance, "shm", "total_operations", "cycles" , stats->shm_cycles);
337 if (conf->collect_sm)
339 /* allocator requests */
340 varnish_submit_derive (conf->instance, "sm", "total_requests", "nreq", stats->sm_nreq);
341 /* outstanding allocations */
342 varnish_submit_gauge (conf->instance, "sm", "requests", "outstanding", stats->sm_nobj);
343 /* bytes allocated */
344 varnish_submit_derive (conf->instance, "sm", "total_bytes", "allocated", stats->sm_balloc);
346 varnish_submit_derive (conf->instance, "sm", "total_bytes", "free", stats->sm_bfree);
349 if (conf->collect_sma)
351 /* SMA allocator requests */
352 varnish_submit_derive (conf->instance, "sma", "total_requests", "nreq", stats->sma_nreq);
353 /* SMA outstanding allocations */
354 varnish_submit_gauge (conf->instance, "sma", "requests", "outstanding", stats->sma_nobj);
355 /* SMA outstanding bytes */
356 varnish_submit_gauge (conf->instance, "sma", "bytes", "outstanding", stats->sma_nbytes);
357 /* SMA bytes allocated */
358 varnish_submit_derive (conf->instance, "sma", "total_bytes", "allocated", stats->sma_balloc);
360 varnish_submit_derive (conf->instance, "sma", "total_bytes", "free" , stats->sma_bfree);
364 if (conf->collect_sms)
366 /* SMS allocator requests */
367 varnish_submit_derive (conf->instance, "sms", "total_requests", "allocator", stats->sms_nreq);
368 /* SMS outstanding allocations */
369 varnish_submit_gauge (conf->instance, "sms", "requests", "outstanding", stats->sms_nobj);
370 /* SMS outstanding bytes */
371 varnish_submit_gauge (conf->instance, "sms", "bytes", "outstanding", stats->sms_nbytes);
372 /* SMS bytes allocated */
373 varnish_submit_derive (conf->instance, "sms", "total_bytes", "allocated", stats->sms_balloc);
374 /* SMS bytes freed */
375 varnish_submit_derive (conf->instance, "sms", "total_bytes", "free", stats->sms_bfree);
378 if (conf->collect_struct)
380 /* N struct sess_mem */
381 varnish_submit_gauge (conf->instance, "struct", "current_sessions", "sess_mem", stats->n_sess_mem);
383 varnish_submit_gauge (conf->instance, "struct", "current_sessions", "sess", stats->n_sess);
384 /* N struct object */
385 varnish_submit_gauge (conf->instance, "struct", "objects", "object", stats->n_object);
386 #ifdef HAVE_VARNISH_V3
387 /* N unresurrected objects */
388 varnish_submit_gauge (conf->instance, "struct", "objects", "vampireobject", stats->n_vampireobject);
389 /* N struct objectcore */
390 varnish_submit_gauge (conf->instance, "struct", "objects", "objectcore", stats->n_objectcore);
392 /* N struct objecthead */
393 varnish_submit_gauge (conf->instance, "struct", "objects", "objecthead", stats->n_objecthead);
394 #ifdef HAVE_VARNISH_V2
396 varnish_submit_gauge (conf->instance, "struct", "objects", "smf", stats->n_smf);
397 /* N small free smf */
398 varnish_submit_gauge (conf->instance, "struct", "objects", "smf_frag", stats->n_smf_frag);
399 /* N large free smf */
400 varnish_submit_gauge (conf->instance, "struct", "objects", "smf_large", stats->n_smf_large);
401 /* N struct vbe_conn */
402 varnish_submit_gauge (conf->instance, "struct", "objects", "vbe_conn", stats->n_vbe_conn);
406 if (conf->collect_totals)
409 varnish_submit_derive (conf->instance, "totals", "total_sessions", "sessions", stats->s_sess);
411 varnish_submit_derive (conf->instance, "totals", "total_requests", "requests", stats->s_req);
413 varnish_submit_derive (conf->instance, "totals", "total_operations", "pipe", stats->s_pipe);
415 varnish_submit_derive (conf->instance, "totals", "total_operations", "pass", stats->s_pass);
417 varnish_submit_derive (conf->instance, "totals", "total_operations", "fetches", stats->s_fetch);
418 /* Total header bytes */
419 varnish_submit_derive (conf->instance, "totals", "total_bytes", "header-bytes", stats->s_hdrbytes);
420 /* Total body byte */
421 varnish_submit_derive (conf->instance, "totals", "total_bytes", "body-bytes", stats->s_bodybytes);
424 #ifdef HAVE_VARNISH_V3
425 if (conf->collect_uptime)
428 varnish_submit_gauge (conf->instance, "uptime", "uptime", "client_uptime", stats->uptime);
432 if (conf->collect_vcl)
435 varnish_submit_gauge (conf->instance, "vcl", "vcl", "total_vcl", stats->n_vcl);
436 /* N vcl available */
437 varnish_submit_gauge (conf->instance, "vcl", "vcl", "avail_vcl", stats->n_vcl_avail);
438 /* N vcl discarded */
439 varnish_submit_gauge (conf->instance, "vcl", "vcl", "discarded_vcl", stats->n_vcl_discard);
442 if (conf->collect_workers)
445 varnish_submit_gauge (conf->instance, "workers", "threads", "worker", stats->n_wrk);
446 /* worker threads created */
447 varnish_submit_derive (conf->instance, "workers", "total_threads", "created", stats->n_wrk_create);
448 /* worker threads not created */
449 varnish_submit_derive (conf->instance, "workers", "total_threads", "failed", stats->n_wrk_failed);
450 /* worker threads limited */
451 varnish_submit_derive (conf->instance, "workers", "total_threads", "limited", stats->n_wrk_max);
452 /* dropped work requests */
453 varnish_submit_derive (conf->instance, "workers", "total_requests", "dropped", stats->n_wrk_drop);
454 #ifdef HAVE_VARNISH_V2
455 /* queued work requests */
456 varnish_submit_derive (conf->instance, "workers", "total_requests", "queued", stats->n_wrk_queue);
457 /* overflowed work requests */
458 varnish_submit_derive (conf->instance, "workers", "total_requests", "overflowed", stats->n_wrk_overflow);
460 /* queued work requests */
461 varnish_submit_derive (conf->instance, "workers", "total_requests", "queued", stats->n_wrk_queued);
462 /* work request queue length */
463 varnish_submit_derive (conf->instance, "workers", "total_requests", "queue_length", stats->n_wrk_lqueue);
466 } /* }}} void varnish_monitor */
469 static int varnish_read (user_data_t *ud) /* {{{ */
472 const c_varnish_stats_t *stats;
476 if ((ud == NULL) || (ud->data == NULL))
484 if (conf->instance != NULL)
488 status = VSM_n_Arg (vd, conf->instance);
491 ERROR ("varnish plugin: VSM_n_Arg (\"%s\") failed "
493 conf->instance, status);
498 if (VSC_Open (vd, /* diag = */ 1))
500 ERROR ("varnish plugin: Unable to load statistics.");
505 stats = VSC_Main(vd);
507 varnish_monitor (conf, stats);
512 #else /* if HAVE_VARNISH_V2 */
513 static int varnish_read (user_data_t *ud) /* {{{ */
515 const c_varnish_stats_t *stats;
519 if ((ud == NULL) || (ud->data == NULL))
524 stats = VSL_OpenStats (conf->instance);
527 ERROR ("Varnish plugin : unable to load statistics");
532 varnish_monitor (conf, stats);
538 static void varnish_config_free (void *ptr) /* {{{ */
540 user_config_t *conf = ptr;
545 sfree (conf->instance);
549 static int varnish_config_apply_default (user_config_t *conf) /* {{{ */
554 conf->collect_backend = 1;
555 conf->collect_cache = 1;
556 conf->collect_connections = 1;
557 #ifdef HAVE_VARNISH_V3
558 conf->collect_dirdns = 0;
560 conf->collect_esi = 0;
561 conf->collect_fetch = 0;
562 conf->collect_hcb = 0;
563 conf->collect_objects = 0;
565 conf->collect_purge = 0;
567 conf->collect_ban = 0;
569 conf->collect_session = 0;
570 conf->collect_shm = 1;
572 conf->collect_sm = 0;
573 conf->collect_sma = 0;
575 conf->collect_sms = 0;
576 conf->collect_struct = 0;
577 conf->collect_totals = 0;
578 #ifdef HAVE_VARNISH_V3
579 conf->collect_uptime = 0;
581 conf->collect_vcl = 0;
582 conf->collect_workers = 0;
585 } /* }}} int varnish_config_apply_default */
587 static int varnish_init (void) /* {{{ */
595 conf = malloc (sizeof (*conf));
598 memset (conf, 0, sizeof (*conf));
600 /* Default settings: */
601 conf->instance = NULL;
603 varnish_config_apply_default (conf);
606 ud.free_func = varnish_config_free;
608 plugin_register_complex_read (/* group = */ "varnish",
609 /* name = */ "varnish/localhost",
610 /* callback = */ varnish_read,
611 /* interval = */ NULL,
612 /* user data = */ &ud);
615 } /* }}} int varnish_init */
617 static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */
621 char callback_name[DATA_MAX_NAME_LEN];
624 conf = malloc (sizeof (*conf));
627 memset (conf, 0, sizeof (*conf));
628 conf->instance = NULL;
630 varnish_config_apply_default (conf);
632 if (ci->values_num == 1)
636 status = cf_util_get_string (ci, &conf->instance);
642 assert (conf->instance != NULL);
644 if (strcmp ("localhost", conf->instance) == 0)
646 sfree (conf->instance);
647 conf->instance = NULL;
650 else if (ci->values_num > 1)
652 WARNING ("Varnish plugin: \"Instance\" blocks accept only "
657 for (i = 0; i < ci->children_num; i++)
659 oconfig_item_t *child = ci->children + i;
661 if (strcasecmp ("CollectCache", child->key) == 0)
662 cf_util_get_boolean (child, &conf->collect_cache);
663 else if (strcasecmp ("CollectConnections", child->key) == 0)
664 cf_util_get_boolean (child, &conf->collect_connections);
665 else if (strcasecmp ("CollectESI", child->key) == 0)
666 cf_util_get_boolean (child, &conf->collect_esi);
667 #ifdef HAVE_VARNISH_V3
668 else if (strcasecmp ("CollectDirectorDNS", child->key) == 0)
669 cf_util_get_boolean (child, &conf->collect_dirdns);
671 else if (strcasecmp ("CollectBackend", child->key) == 0)
672 cf_util_get_boolean (child, &conf->collect_backend);
673 else if (strcasecmp ("CollectFetch", child->key) == 0)
674 cf_util_get_boolean (child, &conf->collect_fetch);
675 else if (strcasecmp ("CollectHCB", child->key) == 0)
676 cf_util_get_boolean (child, &conf->collect_hcb);
677 else if (strcasecmp ("CollectObjects", child->key) == 0)
678 cf_util_get_boolean (child, &conf->collect_objects);
680 else if (strcasecmp ("CollectPurge", child->key) == 0)
681 cf_util_get_boolean (child, &conf->collect_purge);
683 else if (strcasecmp ("CollectBan", child->key) == 0)
684 cf_util_get_boolean (child, &conf->collect_ban);
686 else if (strcasecmp ("CollectSession", child->key) == 0)
687 cf_util_get_boolean (child, &conf->collect_session);
688 else if (strcasecmp ("CollectSHM", child->key) == 0)
689 cf_util_get_boolean (child, &conf->collect_shm);
690 else if (strcasecmp ("CollectSMS", child->key) == 0)
691 cf_util_get_boolean (child, &conf->collect_sms);
693 else if (strcasecmp ("CollectSMA", child->key) == 0)
694 cf_util_get_boolean (child, &conf->collect_sma);
695 else if (strcasecmp ("CollectSM", child->key) == 0)
696 cf_util_get_boolean (child, &conf->collect_sm);
698 else if (strcasecmp ("CollectStruct", child->key) == 0)
699 cf_util_get_boolean (child, &conf->collect_struct);
700 else if (strcasecmp ("CollectTotals", child->key) == 0)
701 cf_util_get_boolean (child, &conf->collect_totals);
702 #ifdef HAVE_VARNISH_V3
703 else if (strcasecmp ("CollectUptime", child->key) == 0)
704 cf_util_get_boolean (child, &conf->collect_uptime);
706 else if (strcasecmp ("CollectVCL", child->key) == 0)
707 cf_util_get_boolean (child, &conf->collect_vcl);
708 else if (strcasecmp ("CollectWorkers", child->key) == 0)
709 cf_util_get_boolean (child, &conf->collect_workers);
712 WARNING ("Varnish plugin: Ignoring unknown "
713 "configuration option: \"%s\". Did "
714 "you forget to add an <Instance /> "
715 "block around the configuration?",
720 if (!conf->collect_cache
721 && !conf->collect_connections
722 && !conf->collect_esi
723 && !conf->collect_backend
724 #ifdef HAVE_VARNISH_V3
725 && !conf->collect_dirdns
727 && !conf->collect_fetch
728 && !conf->collect_hcb
729 && !conf->collect_objects
731 && !conf->collect_purge
733 && !conf->collect_ban
735 && !conf->collect_session
736 && !conf->collect_shm
737 && !conf->collect_sms
739 && !conf->collect_sma
742 && !conf->collect_struct
743 && !conf->collect_totals
744 #ifdef HAVE_VARNISH_V3
745 && !conf->collect_uptime
747 && !conf->collect_vcl
748 && !conf->collect_workers)
750 WARNING ("Varnish plugin: No metric has been configured for "
751 "instance \"%s\". Disabling this instance.",
752 (conf->instance == NULL) ? "localhost" : conf->instance);
756 ssnprintf (callback_name, sizeof (callback_name), "varnish/%s",
757 (conf->instance == NULL) ? "localhost" : conf->instance);
760 ud.free_func = varnish_config_free;
762 plugin_register_complex_read (/* group = */ "varnish",
763 /* name = */ callback_name,
764 /* callback = */ varnish_read,
765 /* interval = */ NULL,
766 /* user data = */ &ud);
771 } /* }}} int varnish_config_instance */
773 static int varnish_config (oconfig_item_t *ci) /* {{{ */
777 for (i = 0; i < ci->children_num; i++)
779 oconfig_item_t *child = ci->children + i;
781 if (strcasecmp ("Instance", child->key) == 0)
782 varnish_config_instance (child);
785 WARNING ("Varnish plugin: Ignoring unknown "
786 "configuration option: \"%s\"",
792 } /* }}} int varnish_config */
794 void module_register (void) /* {{{ */
796 plugin_register_complex_config ("varnish", varnish_config);
797 plugin_register_init ("varnish", varnish_init);
800 /* vim: set sw=8 noet fdm=marker : */