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 # +------------------------------------------------------------------+
28 # | This file has been contributed and is copyrighted by: |
30 # | Joerg Linge 2009 <joerg.linge@pnp4nagios.org> Copyright 2010 |
31 # +------------------------------------------------------------------+
33 # %user %sys %wait %idle physc %entc lbusy app vcsw phint
34 # ----- ---- ----- ----- ----- ----- ------ --- ---- -----
35 # 2.5 6.0 0.1 91.5 0.03 11.4 1.8 3.27 1976647217 490545630
37 # %user %sys %wait %idle physc %entc lbusy vcsw phint %nsp %utcyc
38 # ----- ----- ------ ------ ----- ----- ------ ----- ----- ----- ------
39 # 0.2 0.4 0.0 99.3 0.02 1.7 0.0 215 3 101 0.64
41 # %user %sys %wait %idle physc %entc lbusy app vcsw phint %nsp %utcyc
42 # ----- ----- ------ ------ ----- ----- ------ --- ----- ----- ----- ------
43 # 0.1 0.4 0.0 99.5 0.02 1.6 0.0 3.97 297 0 101 0.64
45 # %user %sys %wait %idle physc %entc lbusy vcsw phint %nsp
46 # ----- ----- ------ ------ ----- ----- ------ ----- ----- -----
47 # 0.1 0.2 0.0 99.6 0.04 1.8 2.3 371 0 58
49 lparstat_default_levels
= (5, 10)
51 def inventory_lparstat(info
):
52 if len(info
) >= 1 and len(info
[-1]) >= 5:
53 return [(None, "lparstat_default_levels")]
55 def check_lparstat(item
, params
, info
):
57 # Old agent provided only the values in a single line
60 cols
= [ 'physc', 'entc', 'lbusy', 'app', 'vcsw', 'phint', 'nsp', 'utcyc' ]
61 uom
= [ '', '%', '', '', '', '', '%', '%' ]
64 cols
= [ 'physc', 'entc', 'lbusy', 'app', 'vcsw', 'phint', 'nsp' ]
65 uom
= [ '', '%', '', '', '', '', '%' ]
68 cols
= [ 'physc', 'entc', 'lbusy', 'app', 'vcsw', 'phint' ]
69 uom
= [ '', '%', '', '', '', '' ]
72 cols
= [ 'physc', 'entc', 'lbusy', 'app' ]
73 uom
= [ '', '%', '', '' ]
76 cols
= [ 'nsp', 'utcyc' ]
80 # Invalid output, let exception happen
82 # The new agent provides three lines, the title line, spacer line and the values
83 cols
= [ c
.replace('%', '') for c
in info
[-3] ]
84 uom
= [ '%' * ('%' in c
) for c
in info
[-3] ]
87 perfdata
= zip(cols
, map(float, values
))
88 output
= ', '.join("%s: %s%s" % (c
.title(), v
, u
)
89 for c
, v
, u
in zip(cols
, values
, uom
))
90 return 0, output
, perfdata
92 check_info
["lparstat_aix"] = {
93 'check_function': check_lparstat
,
94 'inventory_function': inventory_lparstat
,
95 'service_description': 'lparstat',
99 # Utilization and IO/Wait
100 kernel_util_default_levels
= None
102 def inventory_lparstat_aix_cpu(info
):
103 if len(info
) >= 1 and len(info
[-1]) >= 4:
104 return [(None, "kernel_util_default_levels")]
106 def check_lparstat_aix_cpu(_no_item
, params
, info
):
108 line
= info
[0] # old (single line) agent output
111 user
, system
, wait
, _idle
= map(float, line
[:4])
118 util
= user
+ system
+ wait
120 infotext
= "user: %2.1f%%, system: %2.1f%%, wait: %2.1f%%" % (user
, system
, wait
)
122 # You may set a warning/critical level on the io wait
123 # percentage. This can be done by setting params to
124 # a pair of (warn, crit)
127 if type(params
) == tuple: # old config only levels io wait
130 result
= max(result
, 2)
133 result
= max(result
, 1)
136 elif type(params
) == dict:
138 warn
, crit
= params
['util']
140 result
= max(result
, 2)
142 result
= max(result
, 1)
143 if 'iowait' in params
:
144 warn
, crit
= params
['iowait']
146 result
= max(result
, 2)
148 result
= max(result
, 1)
150 return (result
, infotext
, perfdata
)
152 check_info
['lparstat_aix.cpu_util'] = {
153 "check_function" : check_lparstat_aix_cpu
,
154 "inventory_function" : inventory_lparstat_aix_cpu
,
155 "service_description" : "CPU utilization",
156 "has_perfdata" : True,
157 "group" : "cpu_iowait",