Cleanup config.nodes_of
[check_mk.git] / checks / hpux_snmp_cs
blob163844ad9807396a459742515b623b8159befa43
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 # Some relevant OIDs are
28 # sysUpTime: 1.3.6.1.4.1.11.2.3.1.1.1
29 # sysUsers: 1.3.6.1.4.1.11.2.3.1.1.2
30 # sysAvgJobs1: 1.3.6.1.4.1.11.2.3.1.1.3
31 # sysAvgJobs5: 1.3.6.1.4.1.11.2.3.1.1.4
32 # sysAvgJobs15: 1.3.6.1.4.1.11.2.3.1.1.5
33 # sysMaxProcess: 1.3.6.1.4.1.11.2.3.1.1.6
34 # sysFreeMemory: 1.3.6.1.4.1.11.2.3.1.1.7
35 # sysPhysMemory: 1.3.6.1.4.1.11.2.3.1.1.8
36 # sysMaxUserMemory: 1.3.6.1.4.1.11.2.3.1.1.9
37 # sysSwapConfig: 1.3.6.1.4.1.11.2.3.1.1.10
38 # sysEnabledSwap: 1.3.6.1.4.1.11.2.3.1.1.11
39 # sysFreeSwap: 1.3.6.1.4.1.11.2.3.1.1.12
40 # sysUserCPU: 1.3.6.1.4.1.11.2.3.1.1.13
41 # sysSysCPU: 1.3.6.1.4.1.11.2.3.1.1.14
42 # sysIdleCPU: 1.3.6.1.4.1.11.2.3.1.1.15
43 # sysNiceCPU: 1.3.6.1.4.1.11.2.3.1.1.16
45 # Example walk:
46 # .1.3.6.1.4.1.11.2.3.1.1.1.0 215207600
47 # .1.3.6.1.4.1.11.2.3.1.1.10.0 33357824
48 # .1.3.6.1.4.1.11.2.3.1.1.11.0 33357824
49 # .1.3.6.1.4.1.11.2.3.1.1.12.0 29350932
50 # .1.3.6.1.4.1.11.2.3.1.1.13.0 52129100
51 # .1.3.6.1.4.1.11.2.3.1.1.14.0 23331438
52 # .1.3.6.1.4.1.11.2.3.1.1.15.0 123137168
53 # .1.3.6.1.4.1.11.2.3.1.1.16.0 10
56 def inventory_hpux_snmp_cpu(info):
57 if len(info) > 0:
58 return [(None, None)]
61 def check_hpux_snmp_cpu(item, _no_params, info):
62 parts = dict(info)
63 this_time = time.time()
64 total_rate = 0
65 rates = []
66 for what, oid in [("user", "13.0"), ("system", "14.0"), ("idle", "15.0"), ("nice", "16.0")]:
67 value = int(parts[oid])
68 rate = get_rate("snmp_cpu_util.%s" % what, this_time, value)
69 total_rate += rate
70 rates.append(rate)
72 if total_rate == 0:
73 raise MKCounterWrapped("No counter counted. Time has ceased to flow.")
75 perfdata = []
76 infos = []
77 for what, rate in zip(["user", "system", "idle", "nice"], rates):
78 part = rate / total_rate
79 perc = part * 100
80 perfdata.append((what, perc, None, None, 0, 100))
81 infos.append("%s: %.0f%%" % (what, perc))
83 return (0, ", ".join(infos), perfdata)
86 check_info['hpux_snmp_cs.cpu'] = (check_hpux_snmp_cpu, "CPU utilization", 1,
87 inventory_hpux_snmp_cpu)
89 snmp_info['hpux_snmp_cs'] = (".1.3.6.1.4.1.11.2.3.1", [OID_END, 1])
91 snmp_scan_functions['hpux_snmp_cs.cpu'] = lambda oid: oid(".1.3.6.1.2.1.1.1.0").startswith("HP-UX")