GUI CSS: Deployed view styles for layouts (CMK-1171)
[check_mk.git] / checks / ucd_cpu_util
blobc9123cca643e202f70caa1d83c8594745aea51e0
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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):
37 if info:
38 yield None, {}
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()
48 rates = [
49 get_rate("cpu.util.%d" % index, this_time, counter)
50 for index, counter in enumerate(counters)
53 total = sum(rates)
54 if total == 0:
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
63 yield check_levels(
64 user, "user", None, human_readable_func=get_percent_human_readable, infoname="User")
65 yield check_levels(
66 system, "system", None, human_readable_func=get_percent_human_readable, infoname="System")
67 yield check_levels(
68 wait,
69 "wait",
70 params.get("iowait"),
71 human_readable_func=get_percent_human_readable,
72 infoname="Wait")
74 for util_result in check_cpu_util(util, params):
75 yield util_result
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',
82 'has_perfdata': True,
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',