Cleanup config.nodes_of
[check_mk.git] / checks / winperf_msx_queues
blobd477137d2ccf8c42f5054347e53fef09add8e266
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 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 # Example output from agent:
28 # <<<winperf_msx_queues>>>
29 # 12947176002.19
30 # 1 instances: _total
31 # 10334 0 rawcount
32 # 10336 810 rawcount
33 # 10338 0 rawcount
34 # 10340 0 rawcount
35 # 10342 0 rawcount
36 # 10344 0 rawcount
37 # 10346 810 rawcount
38 # 10348 810 rawcount
39 # 10350 821 rawcount
40 # 10352 821 counter
41 # 10354 10 rawcount
42 # 10356 10 counter
43 # 10358 0 rawcount
44 # 10360 0 rawcount
45 # 10362 0 rawcount
46 # 10364 811 rawcount
48 # Example output from a Exchange 2013 server:
49 # <<<winperf_msx_queues>>>
50 # 1385554029.05 12048
51 # 4 instances: niedrige_priorität normale_priorität hohe_priorität _total
52 # 2 0 0 0 0 rawcount
53 # 4 0 0 0 0 rawcount
54 # 6 0 0 0 0 rawcount
56 # For Legacy reasons we need still this var.
57 msx_queues_default_levels = (500, 2000)
59 # Default warn/crit levels for length of queues
60 factory_settings['winperf_msx_queues_factory'] = {
61 'levels': (500, 2000),
64 # Queues to be inventorized (number are relative to counter base)
65 winperf_msx_queues = {
66 "Active Remote Delivery": "2",
67 "Retry Remote Delivery": "4",
68 "Active Mailbox Delivery": "6",
69 "Poison Queue Length": "44",
72 winperf_msx_queues_inventory = []
75 def inventory_winperf_msx_queues(info):
76 if len(info) > 1:
77 num_instances = int(info[1][0])
78 if num_instances > 0:
79 # Its possible to set the wanted queues via wato
80 inventory_rules = {}
81 for rulset in host_extra_conf(host_name(), winperf_msx_queues_inventory):
82 inventory_rules.update(dict(rulset))
83 # In case that rules for this host are set,
84 # only use this rules
85 if inventory_rules:
86 queues = inventory_rules
87 else:
88 queues = winperf_msx_queues
89 return [(name, {"offset": int(offset)}) for name, offset in queues.items()]
92 def check_winperf_msx_queues(item, params, info):
93 # current windows agents should not produce winperf sections with no data after the header but
94 # this ensures compatibility with older agents
95 if len(info) < 2 or int(info[1][0]) < 1:
96 return 3, "no counters available, transport service running?"
98 # Old default case:
99 if isinstance(params, tuple):
100 warn, crit = params
101 offset = winperf_msx_queues.get(item)
102 else:
103 warn, crit = params['levels']
104 if params.get('offset'):
105 offset = str(params['offset'])
106 # If no offset is set, we assume that still the default counters are used
107 else:
108 offset = winperf_msx_queues.get(item)
110 for line in info[2:]:
111 if line[0] == offset:
112 length = int(line[-2])
113 perfdata = [("length", length, warn, crit)]
114 infotext = "%d entries" % length
115 if length >= crit:
116 return (2, infotext, perfdata)
117 elif length >= warn:
118 return (1, infotext, perfdata)
119 return (0, infotext, perfdata)
121 return (3, "counter not found")
124 check_config_variables.append("winperf_msx_queues")
126 check_info["winperf_msx_queues"] = {
127 'check_function': check_winperf_msx_queues,
128 'inventory_function': inventory_winperf_msx_queues,
129 'service_description': 'Queue %s',
130 'has_perfdata': True,
131 "default_levels_variable": "winperf_msx_queues_factory",
132 'group': 'msx_queues',