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 # Output is taken from /proc/loadavg plus the number of cores:
28 # 0.26 0.47 0.52 2/459 19531 4
30 # .--Load----------------------------------------------------------------.
32 # | | | ___ __ _ __| | |
33 # | | | / _ \ / _` |/ _` | |
34 # | | |__| (_) | (_| | (_| | |
35 # | |_____\___/ \__,_|\__,_| |
37 # '----------------------------------------------------------------------'
39 cpuload_default_levels
= (5.0, 10.0)
42 def inventory_cpu_load(info
):
43 if len(info
) >= 1 and len(info
[0]) >= 5:
44 return [(None, "cpuload_default_levels")]
47 def check_cpu_load(item
, params
, info
):
52 # There have been broken AIX agents for a long time which produced data like follows.
53 # Newer agents deal with this, but to be nice to old agents: deal with it.
55 # 0.00 0.00 0.00 1/97 8913088 aixxyz configuration: @lcpu=8 @mem=24576MB @ent=0.20
56 line
= " ".join(info
[0])
60 num_cpus
= int(part
.split("=", 1)[1])
63 num_cpus
= int(info
[0][5])
67 load
= map(float, info
[0][0:3])
68 return check_cpu_load_generic(params
, load
, num_cpus
)
71 check_info
["cpu.loads"] = {
72 "check_function": check_cpu_load
,
73 "inventory_function": inventory_cpu_load
,
74 "service_description": "CPU load",
77 "includes": ["cpu_load.include"],
78 "handle_real_time_checks": True,
82 # .--Threads-------------------------------------------------------------.
84 # | |_ _| |__ _ __ ___ __ _ __| |___ |
85 # | | | | '_ \| '__/ _ \/ _` |/ _` / __| |
86 # | | | | | | | | | __/ (_| | (_| \__ \ |
87 # | |_| |_| |_|_| \___|\__,_|\__,_|___/ |
89 # '----------------------------------------------------------------------'
91 threads_default_levels
= {} # legacy default levels variable
93 factory_settings
["cpu_threads_default_levels"] = {
94 "levels": (2000, 4000),
98 def inventory_cpu_threads(info
):
99 if len(info
) >= 1 and len(info
[0]) >= 5:
103 def check_cpu_threads(item
, params
, info
):
104 if isinstance(params
, tuple):
105 params
= {'levels': params
}
108 num_threads
= int(info
[0][3].split('/')[1])
110 yield (3, "invalid output from plugin")
113 absolute_levels
= params
.get("levels", (None, None))
119 human_readable_func
=lambda x
: "%.f" % x
,
123 max_threads
= int(info
[1][0])
124 thread_usage
= 100.0 * num_threads
/ max_threads
125 relative_levels
= params
.get("levels_percent", (None, None))
130 human_readable_func
=get_percent_human_readable
,
134 check_info
["cpu.threads"] = {
135 "check_function": check_cpu_threads
,
136 "inventory_function": inventory_cpu_threads
,
137 "service_description": "Number of threads",
138 "has_perfdata": True,
140 "default_levels_variable": "cpu_threads_default_levels",
141 "handle_real_time_checks": True,