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.
28 # <<<hpux_tunables:sep(58)>>>
29 # Tunable: dbc_max_pct
41 # {'dbc_max_pct' : (0, 1),
42 # 'maxdsiz' : (176676864, 1073741824),
46 # .--general functions---------------------------------------------------.
48 # | __ _ ___ _ __ ___ _ __ __ _| | |
49 # | / _` |/ _ \ '_ \ / _ \ '__/ _` | | |
50 # | | (_| | __/ | | | __/ | | (_| | | |
51 # | \__, |\___|_| |_|\___|_| \__,_|_| |
54 # | / _|_ _ _ __ ___| |_(_) ___ _ __ ___ |
55 # | | |_| | | | '_ \ / __| __| |/ _ \| '_ \/ __| |
56 # | | _| |_| | | | | (__| |_| | (_) | | | \__ \ |
57 # | |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/ |
59 # +----------------------------------------------------------------------+
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
):
71 if "Tunable" in line
[0] or "Parameter" in line
[0]:
73 elif "Usage" in line
[0]:
75 elif "Setting" in line
[0]:
76 threshold
= int(line
[1])
78 parsed
[key
] = (usage
, threshold
)
83 def inventory_hpux_tunables(info
, tunable
):
84 if tunable
in parse_hpux_tunables(info
):
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
)
95 usage
, threshold
= parsed
[tunable
]
96 perc
= float(usage
) / float(threshold
) * 100
98 if isinstance(params
, tuple):
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
) ]
117 yield state
, "(warn/crit at %s/%s)" % (warn
, crit
)
120 yield 3, "tunable not found in agent output"
124 # .--nkthread------------------------------------------------------------.
126 # | _ __ | | _| |_| |__ _ __ ___ __ _ __| | |
127 # | | '_ \| |/ / __| '_ \| '__/ _ \/ _` |/ _` | |
128 # | | | | | <| |_| | | | | | __/ (_| | (_| | |
129 # | |_| |_|_|\_\\__|_| |_|_| \___|\__,_|\__,_| |
131 # +----------------------------------------------------------------------+
133 # '----------------------------------------------------------------------'
135 factory_settings
["hpux_tunables_nkthread_default_levels"] = {
136 'levels': (80.0, 85.0),
140 def inventory_hpux_tunables_nkthread(info
):
142 return inventory_hpux_tunables(info
, tunable
)
145 def check_hpux_tunables_nkthread(_no_item
, params
, info
):
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---------------------------------------------------------------.
162 # | _ __ _ __ _ __ ___ ___ |
163 # | | '_ \| '_ \| '__/ _ \ / __| |
164 # | | | | | |_) | | | (_) | (__ |
165 # | |_| |_| .__/|_| \___/ \___| |
167 # +----------------------------------------------------------------------+
169 # '----------------------------------------------------------------------'
171 factory_settings
["hpux_tunables_nproc_default_levels"] = {'levels': (90.0, 96.0)}
174 def inventory_hpux_tunables_nproc(info
):
176 return inventory_hpux_tunables(info
, tunable
)
179 def check_hpux_tunables_nproc(_no_item
, params
, info
):
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--------------------------------------------------------.
196 # | _ __ ___ __ ___ __/ _(_) | ___ ___ | (_)_ __ ___ |
197 # | | '_ ` _ \ / _` \ \/ / |_| | |/ _ \/ __| | | | '_ ` _ \ |
198 # | | | | | | | (_| |> <| _| | | __/\__ \ | | | | | | | | |
199 # | |_| |_| |_|\__,_/_/\_\_| |_|_|\___||___/___|_|_|_| |_| |_| |
201 # +----------------------------------------------------------------------+
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"
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--------------------------------------------------------------.
230 # | ___ ___ _ __ ___ _ __ ___ _ __ (_) |
231 # | / __|/ _ \ '_ ` _ \| '_ ` _ \| '_ \| | |
232 # | \__ \ __/ | | | | | | | | | | | | | | |
233 # | |___/\___|_| |_| |_|_| |_| |_|_| |_|_| |
235 # +----------------------------------------------------------------------+
237 # '----------------------------------------------------------------------'
239 factory_settings
["hpux_tunables_semmni_default_levels"] = {'levels': (85.0, 90.0)}
242 def inventory_hpux_tunables_semmni(info
):
244 return inventory_hpux_tunables(info
, tunable
)
247 def check_hpux_tunables_semmni(_no_item
, params
, info
):
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--------------------------------------------------------------.
264 # | ___| |__ _ __ ___ ___ ___ __ _ |
265 # | / __| '_ \| '_ ` _ \/ __|/ _ \/ _` | |
266 # | \__ \ | | | | | | | \__ \ __/ (_| | |
267 # | |___/_| |_|_| |_| |_|___/\___|\__, | |
269 # +----------------------------------------------------------------------+
271 # '----------------------------------------------------------------------'
273 factory_settings
["hpux_tunables_shmseg_default_levels"] = {'levels': (85.0, 90.0)}
276 def inventory_hpux_tunables_shmseg(info
):
278 return inventory_hpux_tunables(info
, tunable
)
281 def check_hpux_tunables_shmseg(_no_item
, params
, info
):
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--------------------------------------------------------------.
298 # | ___ ___ _ __ ___ _ __ ___ _ __ ___ |
299 # | / __|/ _ \ '_ ` _ \| '_ ` _ \| '_ \/ __| |
300 # | \__ \ __/ | | | | | | | | | | | | \__ \ |
301 # | |___/\___|_| |_| |_|_| |_| |_|_| |_|___/ |
303 # +----------------------------------------------------------------------+
305 # '----------------------------------------------------------------------'
307 factory_settings
["hpux_tunables_semmns_default_levels"] = {'levels': (85.0, 90.0)}
310 def inventory_hpux_tunables_semmns(info
):
312 return inventory_hpux_tunables(info
, tunable
)
315 def check_hpux_tunables_semmns(_no_item
, params
, info
):
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",