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 # UCD-SNMP-MIB::ssCpuRawUser.0 = Counter32: 219998591
28 # UCD-SNMP-MIB::ssCpuRawNice.0 = Counter32: 0
29 # UCD-SNMP-MIB::ssCpuRawSystem.0 = Counter32: 98206536
30 # UCD-SNMP-MIB::ssCpuRawIdle.0 = Counter32: 3896034232
31 # UCD-SNMP-MIB::ssCpuRawWait.0 = Counter32: 325152257
32 # UCD-SNMP-MIB::ssCpuRawKernel.0 = Counter32: 96265777
33 # UCD-SNMP-MIB::ssCpuRawInterrupt.0 = Counter32: 1940759
36 def inventory_ucd_cpu_util(info
):
41 def check_ucd_cpu_util(item
, params
, info
):
42 # ancient iowait tuple rule
43 # and legacy None default prior to 1.6
44 params
= transform_cpu_iowait(params
)
46 counters
= map(saveint
, info
[0])
47 this_time
= time
.time()
49 get_rate("cpu.util.%d" % index
, this_time
, counter
)
50 for index
, counter
in enumerate(counters
)
55 raise MKCounterWrapped("Rates have not changed since last interval")
57 parts
= [r
/ total
for r
in rates
]
58 user
= 100 * (parts
[0] + parts
[1])
59 system
= 100 * (parts
[2] + parts
[5] + parts
[6])
60 wait
= 100 * (parts
[4])
61 util
= user
+ system
+ wait
64 user
, "user", None, human_readable_func
=get_percent_human_readable
, infoname
="User")
66 system
, "system", None, human_readable_func
=get_percent_human_readable
, infoname
="System")
71 human_readable_func
=get_percent_human_readable
,
74 for util_result
in check_cpu_util(util
, params
):
78 check_info
["ucd_cpu_util"] = {
79 'inventory_function': inventory_ucd_cpu_util
,
80 'check_function': check_ucd_cpu_util
,
81 'service_description': 'CPU utilization',
83 'snmp_info': ('.1.3.6.1.4.1.2021.11', [50, 51, 52, 53, 54, 55, 56]),
84 'snmp_scan_function': prefer_hr_else_ucd
,
85 'includes': ["ucd_hr.include", "transforms.include", "cpu_util.include"],
86 'group': 'cpu_iowait',