Refactoring: Changed remaining check parameters starting with an 's' to the new rules...
[check_mk.git] / checks / vms_cpu
blobf32dfa41362f12986a317fb095d3aab22c8a1382
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 # Example output from agent:
28 # <<<vms_cpu>>>
29 # 1 99.17 0.54 0.18 0.00
32 def parse_vms_cpu(info):
33 parsed = {}
34 try:
35 parsed['num_cpus'] = int(info[0][0])
36 for i, key in enumerate(('idle', 'user', 'wait_interrupt', 'wait_npsync'), 1):
37 parsed[key] = float(info[0][i]) / parsed['num_cpus']
38 except (IndexError, ValueError):
39 return {}
41 return parsed
44 def inventory_vms_cpu(info):
45 if info:
46 yield None, {}
49 def check_vms_cpu(_no_item, params, parsed):
50 # ancient tuple rule
51 # and legacy default None prior to 1.6
52 params = transform_cpu_iowait(params)
54 user = parsed["user"]
55 wait = parsed["wait_interrupt"] + parsed["wait_npsync"]
56 util = 100. - parsed["idle"]
57 system = util - user - wait
59 yield check_levels(user, "user", None, '%')
60 yield check_levels(system, "system", None, '%')
61 yield check_levels(wait, "wait", params.get("iowait"), '%')
63 for util_result in check_cpu_util(util, params):
64 yield util_result
66 num_cpus = parsed['num_cpus']
67 unit = "CPU" if num_cpus == 1 else "CPUs"
68 yield check_levels(
69 num_cpus, 'cpu_entitlement', None, unit=unit, infoname="100% corresponding to")
72 check_info['vms_cpu'] = {
73 "parse_function": parse_vms_cpu,
74 "check_function": check_vms_cpu,
75 "inventory_function": inventory_vms_cpu,
76 "service_description": "CPU utilization",
77 "has_perfdata": True,
78 "group": "cpu_iowait",
79 "includes": ["transforms.include", "cpu_util.include"],