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
= (2000, 4000)
94 def inventory_cpu_threads(info
):
95 if len(info
) == 1 and len(info
[0]) >= 5:
96 return [(None, "threads_default_levels")]
99 def check_cpu_threads(item
, params
, info
):
101 nthreads
= int(info
[0][3].split('/')[1])
103 return (3, "invalid output from plugin")
105 perfdata
= [('threads', nthreads
, warn
, crit
, 0)]
107 return (2, "%d threads (critical at %d)" % (nthreads
, crit
), perfdata
)
108 elif nthreads
>= warn
:
109 return (1, "%d threads (warning at %d)" % (nthreads
, warn
), perfdata
)
110 return (0, "%d threads" % (nthreads
,), perfdata
)
113 check_info
["cpu.threads"] = {
114 "check_function": check_cpu_threads
,
115 "inventory_function": inventory_cpu_threads
,
116 "service_description": "Number of threads",
117 "has_perfdata": True,
119 "handle_real_time_checks": True,