2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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>>>
48 # Example output from a Exchange 2013 server:
49 # <<<winperf_msx_queues>>>
51 # 4 instances: niedrige_priorität normale_priorität hohe_priorität _total
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
):
77 num_instances
= int(info
[1][0])
79 # Its possible to set the wanted queues via wato
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,
86 queues
= inventory_rules
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?"
99 if isinstance(params
, tuple):
101 offset
= winperf_msx_queues
.get(item
)
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
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
116 return (2, infotext
, perfdata
)
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',