Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / hpux_tunables
blobba62da159289dabb34bc933143c89d922d952a24
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:
28 # <<<hpux_tunables:sep(58)>>>
29 # Tunable: dbc_max_pct
30 # Usage: 0
31 # Setting: 1
32 # Percentage: 0.0
34 # Tunable: maxdsiz
35 # Usage: 176676864
36 # Setting: 1073741824
37 # Percentage: 16.5
39 # Example of parsed:
41 # {'dbc_max_pct' : (0, 1),
42 # 'maxdsiz' : (176676864, 1073741824),
43 # }
46 # .--general functions---------------------------------------------------.
47 # | _ |
48 # | __ _ ___ _ __ ___ _ __ __ _| | |
49 # | / _` |/ _ \ '_ \ / _ \ '__/ _` | | |
50 # | | (_| | __/ | | | __/ | | (_| | | |
51 # | \__, |\___|_| |_|\___|_| \__,_|_| |
52 # | |___/ |
53 # | __ _ _ |
54 # | / _|_ _ _ __ ___| |_(_) ___ _ __ ___ |
55 # | | |_| | | | '_ \ / __| __| |/ _ \| '_ \/ __| |
56 # | | _| |_| | | | | (__| |_| | (_) | | | \__ \ |
57 # | |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ |
58 # | |
59 # +----------------------------------------------------------------------+
60 # | |
61 # '----------------------------------------------------------------------'
63 # For legacy reasons we need to keep the old format:
64 hpux_tunables_nproc_default_levels = (90.0, 96.0)
65 hpux_tunables_nkthread_default_levels = (80.0, 85.0)
68 def parse_hpux_tunables(info):
69 parsed = {}
70 for line in info:
71 if "Tunable" in line[0] or "Parameter" in line[0]:
72 key = line[1].strip()
73 elif "Usage" in line[0]:
74 usage = int(line[1])
75 elif "Setting" in line[0]:
76 threshold = int(line[1])
78 parsed[key] = (usage, threshold)
80 return parsed
83 def inventory_hpux_tunables(info, tunable):
84 if tunable in parse_hpux_tunables(info):
85 return [(None, {})]
88 def check_hpux_tunables(info, params, tunable, descr):
89 # Since the original author forgot to implement a
90 # main check (without dot) we cannot declare parse
91 # function in check_info...
92 parsed = parse_hpux_tunables(info)
94 if tunable in parsed:
95 usage, threshold = parsed[tunable]
96 perc = float(usage) / float(threshold) * 100
98 if isinstance(params, tuple):
99 params = {
100 'levels': params,
102 warn, crit = params["levels"]
103 warn_perf = float(warn * threshold / 100)
104 crit_perf = float(crit * threshold / 100)
106 yield 0, "%.2f%% used (%d/%d %s)" % (perc, usage, threshold, descr), \
107 [ (descr, usage, warn_perf, crit_perf, 0, threshold) ]
109 if perc > crit:
110 state = 2
111 elif perc > warn:
112 state = 1
113 else:
114 state = 0
116 if state > 0:
117 yield state, "(warn/crit at %s/%s)" % (warn, crit)
119 else:
120 yield 3, "tunable not found in agent output"
124 # .--nkthread------------------------------------------------------------.
125 # | _ _ _ _ |
126 # | _ __ | | _| |_| |__ _ __ ___ __ _ __| | |
127 # | | '_ \| |/ / __| '_ \| '__/ _ \/ _` |/ _` | |
128 # | | | | | <| |_| | | | | | __/ (_| | (_| | |
129 # | |_| |_|_|\_\\__|_| |_|_| \___|\__,_|\__,_| |
130 # | |
131 # +----------------------------------------------------------------------+
132 # | |
133 # '----------------------------------------------------------------------'
135 factory_settings["hpux_tunables_nkthread_default_levels"] = {
136 'levels': (80.0, 85.0),
140 def inventory_hpux_tunables_nkthread(info):
141 tunable = "nkthread"
142 return inventory_hpux_tunables(info, tunable)
145 def check_hpux_tunables_nkthread(_no_item, params, info):
146 tunable = "nkthread"
147 descr = "threads"
148 return check_hpux_tunables(info, params, tunable, descr)
151 check_info["hpux_tunables.nkthread"] = {
152 "inventory_function": inventory_hpux_tunables_nkthread,
153 "check_function": check_hpux_tunables_nkthread,
154 "service_description": "Number of threads",
155 "has_perfdata": True,
156 "default_levels_variable": "hpux_tunables_nkthread_default_levels",
160 # .--nproc---------------------------------------------------------------.
161 # | |
162 # | _ __ _ __ _ __ ___ ___ |
163 # | | '_ \| '_ \| '__/ _ \ / __| |
164 # | | | | | |_) | | | (_) | (__ |
165 # | |_| |_| .__/|_| \___/ \___| |
166 # | |_| |
167 # +----------------------------------------------------------------------+
168 # | |
169 # '----------------------------------------------------------------------'
171 factory_settings["hpux_tunables_nproc_default_levels"] = {'levels': (90.0, 96.0)}
174 def inventory_hpux_tunables_nproc(info):
175 tunable = "nproc"
176 return inventory_hpux_tunables(info, tunable)
179 def check_hpux_tunables_nproc(_no_item, params, info):
180 tunable = "nproc"
181 descr = "processes"
182 return check_hpux_tunables(info, params, tunable, descr)
185 check_info["hpux_tunables.nproc"] = {
186 "inventory_function": inventory_hpux_tunables_nproc,
187 "check_function": check_hpux_tunables_nproc,
188 "service_description": "Number of processes",
189 "has_perfdata": True,
190 "default_levels_variable": "hpux_tunables_nproc_default_levels",
194 # .--maxfiles_lim--------------------------------------------------------.
195 # | __ _ _ _ _ |
196 # | _ __ ___ __ ___ __/ _(_) | ___ ___ | (_)_ __ ___ |
197 # | | '_ ` _ \ / _` \ \/ / |_| | |/ _ \/ __| | | | '_ ` _ \ |
198 # | | | | | | | (_| |> <| _| | | __/\__ \ | | | | | | | | |
199 # | |_| |_| |_|\__,_/_/\_\_| |_|_|\___||___/___|_|_|_| |_| |_| |
200 # | |_____| |
201 # +----------------------------------------------------------------------+
202 # | |
203 # '----------------------------------------------------------------------'
205 factory_settings["hpux_tunables_maxfiles_lim_default_levels"] = {'levels': (85.0, 90.0)}
208 def inventory_hpux_tunables_maxfiles_lim(info):
209 tunable = "maxfiles_lim"
210 return inventory_hpux_tunables(info, tunable)
213 def check_hpux_tunables_maxfiles_lim(_no_item, params, info):
214 tunable = "maxfiles_lim"
215 descr = "files"
216 return check_hpux_tunables(info, params, tunable, descr)
219 check_info["hpux_tunables.maxfiles_lim"] = {
220 "inventory_function": inventory_hpux_tunables_maxfiles_lim,
221 "check_function": check_hpux_tunables_maxfiles_lim,
222 "service_description": "Number of open files",
223 "has_perfdata": True,
224 "default_levels_variable": "hpux_tunables_maxfiles_lim_default_levels",
228 # .--semmni--------------------------------------------------------------.
229 # | _ |
230 # | ___ ___ _ __ ___ _ __ ___ _ __ (_) |
231 # | / __|/ _ \ '_ ` _ \| '_ ` _ \| '_ \| | |
232 # | \__ \ __/ | | | | | | | | | | | | | | |
233 # | |___/\___|_| |_| |_|_| |_| |_|_| |_|_| |
234 # | |
235 # +----------------------------------------------------------------------+
236 # | |
237 # '----------------------------------------------------------------------'
239 factory_settings["hpux_tunables_semmni_default_levels"] = {'levels': (85.0, 90.0)}
242 def inventory_hpux_tunables_semmni(info):
243 tunable = "semmni"
244 return inventory_hpux_tunables(info, tunable)
247 def check_hpux_tunables_semmni(_no_item, params, info):
248 tunable = "semmni"
249 descr = "semaphore_ids"
250 return check_hpux_tunables(info, params, tunable, descr)
253 check_info["hpux_tunables.semmni"] = {
254 "inventory_function": inventory_hpux_tunables_semmni,
255 "check_function": check_hpux_tunables_semmni,
256 "service_description": "Number of IPC Semaphore IDs",
257 "has_perfdata": True,
258 "default_levels_variable": "hpux_tunables_semmni_default_levels",
262 # .--shmseg--------------------------------------------------------------.
263 # | _ |
264 # | ___| |__ _ __ ___ ___ ___ __ _ |
265 # | / __| '_ \| '_ ` _ \/ __|/ _ \/ _` | |
266 # | \__ \ | | | | | | | \__ \ __/ (_| | |
267 # | |___/_| |_|_| |_| |_|___/\___|\__, | |
268 # | |___/ |
269 # +----------------------------------------------------------------------+
270 # | |
271 # '----------------------------------------------------------------------'
273 factory_settings["hpux_tunables_shmseg_default_levels"] = {'levels': (85.0, 90.0)}
276 def inventory_hpux_tunables_shmseg(info):
277 tunable = "shmseg"
278 return inventory_hpux_tunables(info, tunable)
281 def check_hpux_tunables_shmseg(_no_item, params, info):
282 tunable = "shmseg"
283 descr = "segments"
284 return check_hpux_tunables(info, params, tunable, descr)
287 check_info["hpux_tunables.shmseg"] = {
288 "inventory_function": inventory_hpux_tunables_shmseg,
289 "check_function": check_hpux_tunables_shmseg,
290 "service_description": "Number of shared memory segments",
291 "has_perfdata": True,
292 "default_levels_variable": "hpux_tunables_shmseg_default_levels",
296 # .--semmns--------------------------------------------------------------.
297 # | |
298 # | ___ ___ _ __ ___ _ __ ___ _ __ ___ |
299 # | / __|/ _ \ '_ ` _ \| '_ ` _ \| '_ \/ __| |
300 # | \__ \ __/ | | | | | | | | | | | | \__ \ |
301 # | |___/\___|_| |_| |_|_| |_| |_|_| |_|___/ |
302 # | |
303 # +----------------------------------------------------------------------+
304 # | |
305 # '----------------------------------------------------------------------'
307 factory_settings["hpux_tunables_semmns_default_levels"] = {'levels': (85.0, 90.0)}
310 def inventory_hpux_tunables_semmns(info):
311 tunable = "semmns"
312 return inventory_hpux_tunables(info, tunable)
315 def check_hpux_tunables_semmns(_no_item, params, info):
316 tunable = "semmns"
317 descr = "entries"
318 return check_hpux_tunables(info, params, tunable, descr)
321 check_info["hpux_tunables.semmns"] = {
322 "inventory_function": inventory_hpux_tunables_semmns,
323 "check_function": check_hpux_tunables_semmns,
324 "service_description": "Number of IPC Semaphores",
325 "has_perfdata": True,
326 "default_levels_variable": "hpux_tunables_semmns_default_levels",