Cleanup config.nodes_of
[check_mk.git] / checks / varnish
blobc59ae5fbcbc9373087ee455597ddc6b5c278a891
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2016 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA
27 # Special thanks to Rene Stolle (r.stolle@funkemedien.de)
29 # .--agent output--------------------------------------------------------.
30 # | _ _ _ |
31 # | __ _ __ _ ___ _ __ | |_ ___ _ _| |_ _ __ _ _| |_ |
32 # | / _` |/ _` |/ _ \ '_ \| __| / _ \| | | | __| '_ \| | | | __| |
33 # | | (_| | (_| | __/ | | | |_ | (_) | |_| | |_| |_) | |_| | |_ |
34 # | \__,_|\__, |\___|_| |_|\__| \___/ \__,_|\__| .__/ \__,_|\__| |
35 # | |___/ |_| |
36 # '----------------------------------------------------------------------'
38 # <<<varnish>>>
39 # client_conn 13687134 4.41 Client connections accepted
40 # client_drop 0 0.00 Connection dropped, no sess/wrk
41 # client_req 22397280 7.21 Client requests received
42 # cache_hit 3678 0.00 Cache hits
43 # cache_hitpass 0 0.00 Cache hits for pass
44 # cache_miss 5687 0.00 Cache misses
45 # backend_conn 6870153 2.21 Backend conn. success
46 # backend_unhealthy 0 0.00 Backend conn. not attempted
47 # backend_busy 0 0.00 Backend conn. too many
48 # backend_fail 0 0.00 Backend conn. failures
49 # backend_reuse 15528248 5.00 Backend conn. reuses
50 # backend_toolate 6235 0.00 Backend conn. was closed
51 # backend_recycle 15534489 5.00 Backend conn. recycles
52 # backend_retry 46 0.00 Backend conn. retry
53 # fetch_head 2026 0.00 Fetch head
54 # fetch_length 262203 0.08 Fetch with Length
55 # fetch_chunked 15034709 4.84 Fetch chunked
56 # fetch_eof 0 0.00 Fetch EOF
57 # fetch_bad 0 0.00 Fetch had bad headers
58 # fetch_close 0 0.00 Fetch wanted close
59 # fetch_oldhttp 0 0.00 Fetch pre HTTP/1.1 closed
60 # fetch_zero 0 0.00 Fetch zero len
61 # fetch_failed 0 0.00 Fetch failed
62 # fetch_1xx 0 0.00 Fetch no body (1xx)
63 # fetch_204 0 0.00 Fetch no body (204)
64 # fetch_304 242534 0.08 Fetch no body (304)
65 # n_sess_mem 100000 . N struct sess_mem
66 # n_sess 205470 . N struct sess
67 # n_object 5 . N struct object
68 # n_vampireobject 0 . N unresurrected objects
69 # n_objectcore 101 . N struct objectcore
70 # n_objecthead 104 . N struct objecthead
71 # n_waitinglist 1655 . N struct waitinglist
72 # n_vbc 60 . N struct vbc
73 # n_wrk 1000 . N worker threads
74 # n_wrk_create 1000 0.00 N worker threads created
75 # n_wrk_failed 0 0.00 N worker threads not created
76 # n_wrk_max 893 0.00 N worker threads limited
77 # n_wrk_lqueue 0 0.00 work request queue length
78 # n_wrk_queued 21 0.00 N queued work requests
79 # n_wrk_drop 0 0.00 N dropped work requests
80 # n_backend 2 . N backends
81 # n_expired 5680 . N expired objects
82 # n_lru_nuked 0 . N LRU nuked objects
83 # n_lru_moved 1031 . N LRU moved objects
84 # losthdr 0 0.00 HTTP header overflows
85 # n_objsendfile 0 0.00 Objects sent with sendfile
86 # n_objwrite 15303178 4.93 Objects sent with write
87 # n_objoverflow 0 0.00 Objects overflowing workspace
88 # s_sess 13687207 4.41 Total Sessions
89 # s_req 22397280 7.21 Total Requests
90 # s_pipe 6856634 2.21 Total pipe
91 # s_pass 15536150 5.00 Total pass
92 # s_fetch 15535049 5.00 Total fetch
93 # s_hdrbytes 2623427334 844.71 Total header bytes
94 # s_bodybytes 64229472478 20681.18 Total body bytes
95 # sess_closed 13154452 4.24 Session Closed
96 # sess_pipeline 0 0.00 Session Pipeline
97 # sess_readahead 0 0.00 Session Read Ahead
98 # sess_linger 15526026 5.00 Session Linger
99 # sess_herd 14211876 4.58 Session herd
100 # shm_records 1455193814 468.56 SHM records
101 # shm_writes 117694273 37.90 SHM writes
102 # shm_flushes 0 0.00 SHM flushes due to overflow
103 # shm_cont 1081665 0.35 SHM MTX contention
104 # shm_cycles 646 0.00 SHM cycles through buffer
105 # sms_nreq 1919 0.00 SMS allocator requests
106 # sms_nobj 0 . SMS outstanding allocations
107 # sms_nbytes 0 . SMS outstanding bytes
108 # sms_balloc 708111 . SMS bytes allocated
109 # sms_bfree 708111 . SMS bytes freed
110 # backend_req 15541595 5.00 Backend requests made
111 # n_vcl 1 0.00 N vcl total
112 # n_vcl_avail 1 0.00 N vcl available
113 # n_vcl_discard 0 0.00 N vcl discarded
114 # n_ban 1 . N total active bans
115 # n_ban_add 1 0.00 N new bans added
116 # n_ban_retire 0 0.00 N old bans deleted
117 # n_ban_obj_test 0 0.00 N objects tested
118 # n_ban_re_test 0 0.00 N regexps tested against
119 # n_ban_dups 0 0.00 N duplicate bans removed
120 # hcb_nolock 9355 0.00 HCB Lookups without lock
121 # hcb_lock 5679 0.00 HCB Lookups with lock
122 # hcb_insert 5535 0.00 HCB Inserts
123 # esi_errors 0 0.00 ESI parse errors (unlock)
124 # esi_warnings 0 0.00 ESI parse warnings (unlock)
125 # accept_fail 0 0.00 Accept failures
126 # client_drop_late 0 0.00 Connection dropped late
127 # uptime 3105696 1.00 Client uptime
128 # dir_dns_lookups 0 0.00 DNS director lookups
129 # dir_dns_failed 0 0.00 DNS director failed lookups
130 # dir_dns_hit 0 0.00 DNS director cached lookups hit
131 # dir_dns_cache_full 0 0.00 DNS director full dnscache
132 # vmods 1 . Loaded VMODs
133 # n_gzip 0 0.00 Gzip operations
134 # n_gunzip 82386 0.03 Gunzip operations
135 # LCK.sms.creat 1 0.00 Created locks
136 # LCK.sms.destroy 0 0.00 Destroyed locks
137 # LCK.sms.locks 5757 0.00 Lock Operations
138 # LCK.sms.colls 0 0.00 Collisions
139 # LCK.smp.creat 0 0.00 Created locks
140 # LCK.smp.destroy 0 0.00 Destroyed locks
141 # LCK.smp.locks 0 0.00 Lock Operations
142 # LCK.smp.colls 0 0.00 Collisions
143 # LCK.sma.creat 2 0.00 Created locks
144 # LCK.sma.destroy 0 0.00 Destroyed locks
145 # LCK.sma.locks 76782194 24.72 Lock Operations
146 # LCK.sma.colls 0 0.00 Collisions
147 # LCK.smf.creat 0 0.00 Created locks
148 # LCK.smf.destroy 0 0.00 Destroyed locks
149 # LCK.smf.locks 0 0.00 Lock Operations
150 # LCK.smf.colls 0 0.00 Collisions
151 # LCK.hsl.creat 0 0.00 Created locks
152 # LCK.hsl.destroy 0 0.00 Destroyed locks
153 # LCK.hsl.locks 0 0.00 Lock Operations
154 # LCK.hsl.colls 0 0.00 Collisions
155 # LCK.hcb.creat 1 0.00 Created locks
156 # LCK.hcb.destroy 0 0.00 Destroyed locks
157 # LCK.hcb.locks 28463 0.01 Lock Operations
158 # LCK.hcb.colls 0 0.00 Collisions
159 # LCK.hcl.creat 0 0.00 Created locks
160 # LCK.hcl.destroy 0 0.00 Destroyed locks
161 # LCK.hcl.locks 0 0.00 Lock Operations
162 # LCK.hcl.colls 0 0.00 Collisions
163 # LCK.vcl.creat 1 0.00 Created locks
164 # LCK.vcl.destroy 0 0.00 Destroyed locks
165 # LCK.vcl.locks 2849 0.00 Lock Operations
166 # LCK.vcl.colls 0 0.00 Collisions
167 # LCK.stat.creat 1 0.00 Created locks
168 # LCK.stat.destroy 0 0.00 Destroyed locks
169 # LCK.stat.locks 100000 0.03 Lock Operations
170 # LCK.stat.colls 0 0.00 Collisions
171 # LCK.sessmem.creat 1 0.00 Created locks
172 # LCK.sessmem.destroy 0 0.00 Destroyed locks
173 # LCK.sessmem.locks 13787845 4.44 Lock Operations
174 # LCK.sessmem.colls 0 0.00 Collisions
175 # LCK.wstat.creat 1 0.00 Created locks
176 # LCK.wstat.destroy 0 0.00 Destroyed locks
177 # LCK.wstat.locks 9610148 3.09 Lock Operations
178 # LCK.wstat.colls 0 0.00 Collisions
179 # LCK.herder.creat 1 0.00 Created locks
180 # LCK.herder.destroy 0 0.00 Destroyed locks
181 # LCK.herder.locks 1 0.00 Lock Operations
182 # LCK.herder.colls 0 0.00 Collisions
183 # LCK.wq.creat 2 0.00 Created locks
184 # LCK.wq.destroy 0 0.00 Destroyed locks
185 # LCK.wq.locks 60930521 19.62 Lock Operations
186 # LCK.wq.colls 0 0.00 Collisions
187 # LCK.objhdr.creat 5628 0.00 Created locks
188 # LCK.objhdr.destroy 5528 0.00 Destroyed locks
189 # LCK.objhdr.locks 50484 0.02 Lock Operations
190 # LCK.objhdr.colls 0 0.00 Collisions
191 # LCK.exp.creat 1 0.00 Created locks
192 # LCK.exp.destroy 0 0.00 Destroyed locks
193 # LCK.exp.locks 3116794 1.00 Lock Operations
194 # LCK.exp.colls 0 0.00 Collisions
195 # LCK.lru.creat 2 0.00 Created locks
196 # LCK.lru.destroy 0 0.00 Destroyed locks
197 # LCK.lru.locks 5685 0.00 Lock Operations
198 # LCK.lru.colls 0 0.00 Collisions
199 # LCK.cli.creat 1 0.00 Created locks
200 # LCK.cli.destroy 0 0.00 Destroyed locks
201 # LCK.cli.locks 1034578 0.33 Lock Operations
202 # LCK.cli.colls 0 0.00 Collisions
203 # LCK.ban.creat 1 0.00 Created locks
204 # LCK.ban.destroy 0 0.00 Destroyed locks
205 # LCK.ban.locks 3116799 1.00 Lock Operations
206 # LCK.ban.colls 0 0.00 Collisions
207 # LCK.vbp.creat 1 0.00 Created locks
208 # LCK.vbp.destroy 0 0.00 Destroyed locks
209 # LCK.vbp.locks 0 0.00 Lock Operations
210 # LCK.vbp.colls 0 0.00 Collisions
211 # LCK.vbe.creat 1 0.00 Created locks
212 # LCK.vbe.destroy 0 0.00 Destroyed locks
213 # LCK.vbe.locks 13740586 4.42 Lock Operations
214 # LCK.vbe.colls 0 0.00 Collisions
215 # LCK.backend.creat 2 0.00 Created locks
216 # LCK.backend.destroy 0 0.00 Destroyed locks
217 # LCK.backend.locks 51685293 16.64 Lock Operations
218 # LCK.backend.colls 0 0.00 Collisions
219 # SMA.s0.c_req 13215 0.00 Allocator requests
220 # SMA.s0.c_fail 0 0.00 Allocator failures
221 # SMA.s0.c_bytes 959888353 309.07 Bytes allocated
222 # SMA.s0.c_freed 959475615 308.94 Bytes freed
223 # SMA.s0.g_alloc 12 . Allocations outstanding
224 # SMA.s0.g_bytes 412738 . Bytes outstanding
225 # SMA.s0.g_space 268022718 . Bytes available
226 # SMA.Transient.c_req 30821613 9.92 Allocator requests
227 # SMA.Transient.c_fail 0 0.00 Allocator failures
228 # SMA.Transient.c_bytes 2049827454520 660021.93 Bytes allocated
229 # SMA.Transient.c_freed 2049827454520 660021.93 Bytes freed
230 # SMA.Transient.g_alloc 0 . Allocations outstanding
231 # SMA.Transient.g_bytes 0 . Bytes outstanding
232 # SMA.Transient.g_space 0 . Bytes available
233 # VBE.default(127.0.0.1,,81).vcls 1 . VCL references
234 # VBE.default(127.0.0.1,,81).happy 0 . Happy health probes
235 # VBE.name(xxx.xxx.xxx.xxx,,80).vcls 1 . VCL references
236 # VBE.name(xxx.xxx.xxx.xxx,,80).happy 0 . Happy health probes
238 # Newer agent output has MAIN and MGT prefix keys at the beginning
239 # and provide addtional sections MEMPOOL:
240 # (LCK, SMA, VBE has the same structure)
241 # MGT.uptime Management
242 # MGT.child_start Child
243 # MGT.child_exit Child
244 # MGT.child_stop Child
245 # MGT.child_died Child
246 # MGT.child_dump Child
247 # MGT.child_panic Child
248 # MAIN.summs stat
249 # MAIN.uptime Child
250 # MAIN.sess_conn Sessions
251 # MAIN.sess_drop Sessions
252 # MAIN.sess_fail Session
253 # MAIN.client_req_400 Client
254 # MAIN.client_req_417 Client
255 # MAIN.client_req Good
256 # MAIN.cache_hit Cache
257 # MAIN.cache_hitpass Cache
258 # MAIN.cache_hitmiss Cache
259 # MAIN.cache_miss Cache
260 # ...
261 # MEMPOOL.busyobj.live In
262 # MEMPOOL.busyobj.pool In
263 # MEMPOOL.busyobj.sz_wanted Size
264 # MEMPOOL.busyobj.sz_actual Size
265 # MEMPOOL.busyobj.allocs Allocations
266 # MEMPOOL.busyobj.frees Frees
267 # MEMPOOL.busyobj.recycle Recycled
268 # MEMPOOL.busyobj.timeout Timed
269 # MEMPOOL.busyobj.toosmall Too
270 # MEMPOOL.busyobj.surplus Too
271 # MEMPOOL.busyobj.randry Pool
272 # MEMPOOL.req0.live In
273 # MEMPOOL.req0.pool In
274 # MEMPOOL.req0.sz_wanted Size
275 # MEMPOOL.req0.sz_actual Size
276 # MEMPOOL.req0.allocs Allocations
277 # MEMPOOL.req0.frees Frees
278 # MEMPOOL.req0.recycle Recycled
279 # MEMPOOL.req0.timeout Timed
280 # MEMPOOL.req0.toosmall Too
281 # MEMPOOL.req0.surplus Too
282 # ...
285 # .--common--------------------------------------------------------------.
286 # | |
287 # | ___ ___ _ __ ___ _ __ ___ ___ _ __ |
288 # | / __/ _ \| '_ ` _ \| '_ ` _ \ / _ \| '_ \ |
289 # | | (_| (_) | | | | | | | | | | | (_) | | | | |
290 # | \___\___/|_| |_| |_|_| |_| |_|\___/|_| |_| |
291 # | |
292 # '----------------------------------------------------------------------'
295 def parse_varnish(info):
296 parsed = {}
297 for line in info:
298 parsed_path = _parse_path(line[0])
299 instance = _create_hierarchy(parsed_path, parsed)
300 try:
301 value = int(line[1])
302 except ValueError:
303 value = None
305 if line[3].lower() in line[0]:
306 descr = " ".join(line[4:])
307 else:
308 descr = " ".join(line[3:])
310 perf_var_name = "varnish_%s_rate" % parsed_path[-1]
311 if perf_var_name.startswith("varnish_n_wrk"):
312 perf_var_name = perf_var_name.replace("n_wrk", "worker")
313 elif perf_var_name.startswith("varnish_n_"):
314 perf_var_name = perf_var_name.replace("n_", "objects_")
316 instance.update({
317 "value": value,
318 "descr": descr.replace("/", " "),
319 "perf_var_name": perf_var_name,
320 "params_var_name": parsed_path[-1].split("_", 1)[-1],
323 # Newer output has MAIN or MGT prefix keys,
324 # see above in 'agent output'
325 for key in ["MAIN", "MGT"]:
326 values = parsed.pop(key, {})
327 parsed.update(values)
328 return parsed
331 def _parse_path(raw_path):
332 # Split raw path on ".". We have to deal with different paths:
333 # - 'client_conn'
334 # => ['client_conn']
335 # - 'LCK.sms.creat'
336 # => ['LCK', 'sms', 'creat']
337 # - 'VBE.default(127.0.0.1,,81).happy'
338 # => ['VBE', 'default(127.0.0.1,,81)', 'happy']
339 if '(' not in raw_path:
340 return raw_path.split(".")
341 head, middle = raw_path.split("(", 1)
342 address, tail = middle.split(")", 1)
343 head = head.strip(".").split(".")
344 return head[:-1]\
345 + ["%s(%s)" % (head[-1], address)]\
346 + tail.strip(".").split(".")
349 def _create_hierarchy(path, instance):
350 if not path:
351 return instance
352 head, tail = path[0], path[1:]
353 child = instance.setdefault(head, {})
354 return _create_hierarchy(tail, child)
357 def inventory_varnish(parsed, needed_keys):
358 if all(key in parsed for key in needed_keys):
359 return [(None, {})]
362 def check_varnish_stats(_no_item, params, parsed, expected_keys):
363 this_time = time.time()
364 for key in expected_keys:
365 data = parsed.get(key)
366 if not data:
367 continue
368 descr_per_sec = "%s/s" % data['descr']
369 yield check_levels(
370 get_rate("varnish.%s" % key, this_time, data['value']),
371 data['perf_var_name'],
372 params.get(data['params_var_name'], (None, None)),
373 human_readable_func=lambda r, d=descr_per_sec: ("%.1f " + d) % r)
376 def check_varnish_ratio(_no_item, params, parsed, ratio_keys):
377 reference_key, additional_key, perf_key = ratio_keys
378 reference_value = parsed[reference_key]['value']
379 ratio = 0.0
380 total = reference_value + parsed[additional_key]['value']
381 if total > 0:
382 ratio = 100.0 * reference_value / total
383 warn, crit = params["levels_lower"]
384 return check_levels(
385 ratio, perf_key, (None, None, warn, crit), human_readable_func=get_percent_human_readable)
389 # .--uptime--------------------------------------------------------------.
390 # | _ _ |
391 # | _ _ _ __ | |_(_)_ __ ___ ___ |
392 # | | | | | '_ \| __| | '_ ` _ \ / _ \ |
393 # | | |_| | |_) | |_| | | | | | | __/ |
394 # | \__,_| .__/ \__|_|_| |_| |_|\___| |
395 # | |_| |
396 # +----------------------------------------------------------------------+
397 # | main check |
398 # '----------------------------------------------------------------------'
401 def inventory_varnish_uptime(parsed):
402 if "uptime" in parsed:
403 return [(None, None)]
406 def check_varnish_uptime(_no_item, _no_params, parsed):
407 if "uptime" in parsed:
408 return check_uptime_seconds(_no_params, parsed["uptime"]["value"])
411 check_info["varnish"] = {
412 "parse_function": parse_varnish,
413 "inventory_function": inventory_varnish_uptime,
414 "check_function": check_varnish_uptime,
415 "service_description": "Varnish Uptime",
416 "has_perfdata": True,
417 "includes": ["uptime.include"],
421 # .--cache---------------------------------------------------------------.
422 # | _ |
423 # | ___ __ _ ___| |__ ___ |
424 # | / __/ _` |/ __| '_ \ / _ \ |
425 # | | (_| (_| | (__| | | | __/ |
426 # | \___\__,_|\___|_| |_|\___| |
427 # | |
428 # '----------------------------------------------------------------------'
431 check_info["varnish.cache"] = {
432 "inventory_function" : lambda parsed: \
433 inventory_varnish(parsed, ["cache_miss"]),
434 "check_function" : lambda item, params, parsed: \
435 check_varnish_stats(item, params, parsed, [
436 "cache_miss",
437 "cache_hit",
438 "cache_hitpass",
440 "service_description" : "Varnish Cache",
441 "group" : "varnish_cache",
442 "has_perfdata" : True,
446 # .--client--------------------------------------------------------------.
447 # | _ _ _ |
448 # | ___| (_) ___ _ __ | |_ |
449 # | / __| | |/ _ \ '_ \| __| |
450 # | | (__| | | __/ | | | |_ |
451 # | \___|_|_|\___|_| |_|\__| |
452 # | |
453 # '----------------------------------------------------------------------'
456 check_info["varnish.client"] = {
457 "inventory_function" : lambda parsed: \
458 inventory_varnish(parsed, ["client_req"]),
459 "check_function" : lambda item, params, parsed: \
460 check_varnish_stats(item, params, parsed, [
461 "client_drop",
462 "client_req",
463 "client_conn",
464 "client_drop_late",
466 "service_description" : "Varnish Client",
467 "group" : "varnish_client",
468 "has_perfdata" : True,
472 # .--backend-------------------------------------------------------------.
473 # | _ _ _ |
474 # | | |__ __ _ ___| | _____ _ __ __| | |
475 # | | '_ \ / _` |/ __| |/ / _ \ '_ \ / _` | |
476 # | | |_) | (_| | (__| < __/ | | | (_| | |
477 # | |_.__/ \__,_|\___|_|\_\___|_| |_|\__,_| |
478 # | |
479 # '----------------------------------------------------------------------'
482 check_info["varnish.backend"] = {
483 "inventory_function" : lambda parsed: \
484 inventory_varnish(parsed, ["backend_fail", "backend_unhealthy", "backend_busy"]),
485 "check_function" : lambda item, params, parsed: \
486 check_varnish_stats(item, params, parsed, [
487 "backend_busy",
488 "backend_unhealthy",
489 "backend_req",
490 "backend_recycle",
491 "backend_retry",
492 "backend_fail",
493 "backend_toolate",
494 "backend_conn",
495 "backend_reuse",
497 "service_description" : "Varnish Backend",
498 "group" : "varnish_backend",
499 "has_perfdata" : True,
503 # .--fetch---------------------------------------------------------------.
504 # | __ _ _ |
505 # | / _| ___| |_ ___| |__ |
506 # | | |_ / _ \ __/ __| '_ \ |
507 # | | _| __/ || (__| | | | |
508 # | |_| \___|\__\___|_| |_| |
509 # | |
510 # '----------------------------------------------------------------------'
513 check_info["varnish.fetch"] = {
514 "inventory_function" : lambda parsed: \
515 inventory_varnish(parsed, ["fetch_1xx", "fetch_204", "fetch_304",
516 "fetch_bad", "fetch_eof", "fetch_failed",
517 "fetch_zero"]),
518 "check_function" : lambda item, params, parsed: \
519 check_varnish_stats(item, params, parsed, [
520 "fetch_oldhttp",
521 "fetch_head",
522 "fetch_eof",
523 "fetch_zero",
524 "fetch_304",
525 "fetch_length",
526 "fetch_failed",
527 "fetch_bad",
528 "fetch_close",
529 "fetch_1xx",
530 "fetch_chunked",
531 "fetch_204",
533 "service_description" : "Varnish Fetch",
534 "group" : "varnish_fetch",
535 "has_perfdata" : True,
539 # .--ESI-----------------------------------------------------------------.
540 # | _____ ____ ___ |
541 # | | ____/ ___|_ _| |
542 # | | _| \___ \| | |
543 # | | |___ ___) | | |
544 # | |_____|____/___| |
545 # | |
546 # '----------------------------------------------------------------------'
548 factory_settings["varnish_esi_default_levels"] = {'errors': (1.0, 2.0)}
551 check_info["varnish.esi"] = {
552 "inventory_function" : lambda parsed: \
553 inventory_varnish(parsed, ["esi_errors"]),
554 "check_function" : lambda item, params, parsed: \
555 check_varnish_stats(item, params, parsed, [
556 "esi_errors",
557 "esi_warnings",
559 "service_description" : "Varnish ESI",
560 "default_levels_variable" : "varnish_esi_default_levels",
561 "group" : "varnish_esi",
562 "has_perfdata" : True,
566 # .--objects-------------------------------------------------------------.
567 # | _ _ _ |
568 # | ___ | |__ (_) ___ ___| |_ ___ |
569 # | / _ \| '_ \| |/ _ \/ __| __/ __| |
570 # | | (_) | |_) | | __/ (__| |_\__ \ |
571 # | \___/|_.__// |\___|\___|\__|___/ |
572 # | |__/ |
573 # '----------------------------------------------------------------------'
576 check_info["varnish.objects"] = {
577 "inventory_function" : lambda parsed: \
578 inventory_varnish(parsed, ["n_expired", "n_lru_nuked"]),
579 "check_function" : lambda item, params, parsed: \
580 check_varnish_stats(item, params, parsed, [
581 "n_expired",
582 "n_lru_nuked",
583 "n_lru_moved",
585 "service_description" : "Varnish Objects",
586 "group" : "varnish_objects",
587 "has_perfdata" : True,
591 # .--worker--------------------------------------------------------------.
592 # | _ |
593 # | __ _____ _ __| | _____ _ __ |
594 # | \ \ /\ / / _ \| '__| |/ / _ \ '__| |
595 # | \ V V / (_) | | | < __/ | |
596 # | \_/\_/ \___/|_| |_|\_\___|_| |
597 # | |
598 # '----------------------------------------------------------------------'
601 check_info["varnish.worker"] = {
602 "inventory_function" : lambda parsed: \
603 inventory_varnish(parsed, ["n_wrk_failed", "n_wrk_queued"]),
604 "check_function" : lambda item, params, parsed: \
605 check_varnish_stats(item, params, parsed, [
606 "n_wrk_lqueue",
607 "n_wrk_create",
608 "n_wrk_drop",
609 "n_wrk",
610 "n_wrk_failed",
611 "n_wrk_queued",
612 "n_wrk_max",
614 "service_description" : "Varnish Worker",
615 "group" : "varnish_worker",
616 "has_perfdata" : True,
620 # .--cache hit ratio-----------------------------------------------------.
621 # | _ _ _ _ _ _ |
622 # | ___ __ _ ___| |__ ___ | |__ (_) |_ _ __ __ _| |_(_) ___ |
623 # | / __/ _` |/ __| '_ \ / _ \ | '_ \| | __| | '__/ _` | __| |/ _ \ |
624 # | | (_| (_| | (__| | | | __/ | | | | | |_ | | | (_| | |_| | (_) | |
625 # | \___\__,_|\___|_| |_|\___| |_| |_|_|\__| |_| \__,_|\__|_|\___/ |
626 # | |
627 # '----------------------------------------------------------------------'
629 factory_settings["varnish_cache_hit_ratio_default_levels"] = {'levels_lower': (70.0, 60.0)}
632 check_info["varnish.cache_hit_ratio"] = {
633 "inventory_function" : lambda parsed: \
634 inventory_varnish(parsed, ["cache_miss", "cache_hit"]),
635 "check_function" : lambda item, params, parsed: \
636 check_varnish_ratio(item, params, parsed,
637 ('cache_hit', 'cache_miss', 'cache_hit_ratio')),
638 "default_levels_variable" : "varnish_cache_hit_ratio_default_levels",
639 "service_description" : "Varnish Cache Hit Ratio",
640 "group" : "varnish_cache_hit_ratio",
641 "has_perfdata" : True,
645 # .--backend success ratio-----------------------------------------------.
646 # | _ _ _ |
647 # | | |__ __ _ ___| | _____ _ __ __| | |
648 # | | '_ \ / _` |/ __| |/ / _ \ '_ \ / _` | |
649 # | | |_) | (_| | (__| < __/ | | | (_| | |
650 # | |_.__/ \__,_|\___|_|\_\___|_| |_|\__,_| |
651 # | |
652 # | _ _ |
653 # | ___ _ _ ___ ___ ___ ___ ___ _ __ __ _| |_(_) ___ |
654 # | / __| | | |/ __/ __/ _ \/ __/ __| | '__/ _` | __| |/ _ \ |
655 # | \__ \ |_| | (_| (_| __/\__ \__ \ | | | (_| | |_| | (_) | |
656 # | |___/\__,_|\___\___\___||___/___/ |_| \__,_|\__|_|\___/ |
657 # | |
658 # '----------------------------------------------------------------------'
660 factory_settings["varnish_backend_success_ratio_default_levels"] = {'levels_lower': (70.0, 60.0)}
663 check_info["varnish.backend_success_ratio"] = {
664 "inventory_function" : lambda parsed: \
665 inventory_varnish(parsed, ["backend_fail", "backend_conn"]),
666 "check_function" : lambda item, params, parsed: \
667 check_varnish_ratio(item, params, parsed,
668 ('backend_conn', 'backend_fail', 'varnish_backend_success_ratio')),
669 "default_levels_variable" : "varnish_backend_success_ratio_default_levels",
670 "service_description" : "Varnish Backend Success Ratio",
671 "group" : "varnish_backend_success_ratio",
672 "has_perfdata" : True,
676 # .--worker thread ratio-------------------------------------------------.
677 # | _ _ _ _ |
678 # | __ _____ _ __| | _____ _ __ | |_| |__ _ __ ___ __ _ __| | |
679 # | \ \ /\ / / _ \| '__| |/ / _ \ '__| | __| '_ \| '__/ _ \/ _` |/ _` | |
680 # | \ V V / (_) | | | < __/ | | |_| | | | | | __/ (_| | (_| | |
681 # | \_/\_/ \___/|_| |_|\_\___|_| \__|_| |_|_| \___|\__,_|\__,_| |
682 # | |
683 # | _ _ |
684 # | _ __ __ _| |_(_) ___ |
685 # | | '__/ _` | __| |/ _ \ |
686 # | | | | (_| | |_| | (_) | |
687 # | |_| \__,_|\__|_|\___/ |
688 # | |
689 # '----------------------------------------------------------------------'
691 factory_settings["varnish_worker_thread_ratio_default_levels"] = {'levels_lower': (70.0, 60.0)}
694 def check_varnish_worker_thread_ratio(_no_item, params, parsed):
695 ratio = 0.0
696 worker_create = parsed["n_wrk_create"]['value']
697 if worker_create > 0:
698 ratio = 100.0 * parsed["n_wrk"]['value'] / worker_create
699 warn, crit = params["levels_lower"]
700 return check_levels(
701 ratio,
702 "varnish_worker_thread_ratio", (None, None, warn, crit),
703 human_readable_func=get_percent_human_readable)
706 check_info["varnish.worker_thread_ratio"] = {
707 "inventory_function" : lambda parsed: \
708 inventory_varnish(parsed, ["n_wrk", "n_wrk_create"]),
709 "check_function" : check_varnish_worker_thread_ratio,
710 "service_description" : "Varnish Worker Thread Ratio",
711 "default_levels_variable" : "varnish_worker_thread_ratio_default_levels",
712 "group" : "varnish_worker_thread_ratio",
713 "has_perfdata" : True,