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.
28 factory_settings
['jolokia_jvm_threading.pool'] = {
29 'currentThreadsBusy': (80, 90),
33 def parse_jolokia_json_output(info
):
36 instance
, mbean
, raw_json_data
= line
37 yield instance
, mbean
, json
.loads(raw_json_data
)
42 def parse_jolokia_jvm_threading(info
):
44 for instance
, mbean
, data
in parse_jolokia_json_output(info
):
46 type_
= mbean
.split("type=", 1)[-1].split(",", 1)[0].split("/", 1)[0]
47 parsed_data
= parsed
.setdefault(instance
, {}).setdefault(type_
, {})
49 if type_
== "ThreadPool":
51 name
= key
.split('name="', 1)[-1].split('"', 1)[0]
52 parsed_data
[name
] = data
[key
]
54 parsed_data
.update(data
)
60 def discover_jolokia_jvm_threading(_instance
, data
):
61 return bool(data
.get("Threading"))
65 def check_jolokia_jvm_threading(item
, params
, instance_data
):
66 data
= instance_data
.get("Threading", {})
67 count
= data
.get('ThreadCount')
69 levels
= params
.get('threadcount_levels')
71 count
, 'ThreadCount', levels
, infoname
="Count", human_readable_func
=lambda i
: "%.f" % i
)
73 counter
= "jolokia_jvm_threading.count.%s" % item
74 thread_rate
= get_rate(counter
, time
.time(), count
, allow_negative
=True)
75 levels
= params
.get('threadrate_levels')
76 yield check_levels(thread_rate
, 'ThreadRate', levels
, infoname
="Rate")
79 ('DaemonThreadCount', 'Daemon threads'),
80 ('PeakThreadCount', 'Peak count'),
81 ('TotalStartedThreadCount', 'Total started'),
86 levels
= params
.get('%s_levels' % key
.lower())
88 value
, key
, levels
, infoname
=name
, human_readable_func
=lambda i
: "%.f" % i
)
91 check_info
["jolokia_jvm_threading"] = {
92 "parse_function": parse_jolokia_jvm_threading
,
93 "inventory_function": discover_jolokia_jvm_threading
,
94 "check_function": check_jolokia_jvm_threading
,
95 "service_description": "JVM %s Threading",
96 "group": "jvm_threading",
101 def discover_jolokia_jvm_threading_pool(parsed
):
102 for instance
in parsed
:
103 threadpool_data
= parsed
[instance
].get("ThreadPool", {})
104 for name
in threadpool_data
:
105 yield "%s ThreadPool %s" % (instance
, name
), {}
108 def check_jolokia_jvm_threading_pool(item
, params
, parsed
):
109 instance
, pool_name
= item
.split(" ThreadPool ", 1)
110 thread_pools
= parsed
.get(instance
, {}).get("ThreadPool", {})
111 threadpool_info
= thread_pools
.get(pool_name
, {})
112 max_threads
= threadpool_info
.get("maxThreads")
113 if max_threads
is None:
116 yield 0, "Maximum threads: %d" % max_threads
119 ('currentThreadsBusy', 'Busy'),
120 ('currentThreadCount', 'Total'),
122 value
= threadpool_info
.get(key
)
125 result
= check_levels(
130 factor
=max_threads
/ 100.,
131 human_readable_func
=lambda f
: "%.f" % f
)
132 result
[2][0] = result
[2][0][:4] + (None, max_threads
)
136 check_info
["jolokia_jvm_threading.pool"] = {
137 "inventory_function": discover_jolokia_jvm_threading_pool
,
138 "check_function": check_jolokia_jvm_threading_pool
,
139 "default_levels_variable": "jolokia_jvm_threading.pool",
140 "service_description": "JVM %s",
142 "has_perfdata": True,