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 # <<<tsm_stagingpools>>>
28 # tsmfarm2 SL8500_STGPOOL_05 99.9
29 # tsmfarm2 SL8500_STGPOOL_05 97.9
30 # tsmfarm2 SL8500_LTO4_STGPOOL_01 48.6
31 # tsmfarm2 SL8500_LTO4_STGPOOL_01 35.9
32 # tsmfarm2 SL8500_LTO4_STGPOOL_01 58.9
33 # tsmfarm2 SL8500_LTO4_STGPOOL_01 61.6
37 # "free_below" : 30.0, # consider as free if utilized <= this
38 # "levels" : (5, 2), # warn/crit if less then that many free tapes
41 factory_settings
["tsm_stagingpools_default_levels"] = {
46 def parse_tsm_stagingpools(info
):
49 def add_item(node
, lineinfo
):
50 inst
, pool
, util
= lineinfo
54 item
= inst
+ " / " + pool
55 parsed
.setdefault(item
, {})
56 parsed
[item
].setdefault(node
, [])
57 parsed
[item
][node
].append(util
.replace(",", "."))
61 add_item(node
, line
[1:4])
62 # The agent plugin sometimes seems to mix two lines together some
63 # times. Detect and fix that.
65 add_item(node
, line
[4:])
70 def inventory_tsm_stagingpools(parsed
):
75 def check_tsm_stagingpools(item
, params
, parsed
):
76 if item
not in parsed
:
77 return 3, "Item not found in agent output"
79 datasets
, nodeinfos
= [], []
80 for node
, data
in parsed
[item
].items():
82 nodeinfos
.append(node
)
83 datasets
.append(tuple(data
))
87 utilization
= 0.0 # in relation to one tape size
88 for util
in datasets
[0]:
89 util
= float(util
) / 100.0
92 if util
<= params
["free_below"] / 100.0:
96 infotext
= "%s: " % "/".join(nodeinfos
)
99 infotext
+= "Total tapes: %d, Tapes less then %d%% full: %d, Utilization: %.1f tapes" % \
100 (num_tapes
, params
["free_below"], num_free_tapes
, utilization
)
102 if "levels" in params
:
103 warn
, crit
= params
["levels"]
104 if num_free_tapes
< crit
:
107 elif num_free_tapes
< warn
:
111 warn
, crit
= None, None
113 if state
== 0 and num_tapes
== 0:
115 infotext
= "no tapes in this pool or pool not existant"
117 # In cluster mode we check if data sets are equal from all nodes
118 # else we have only one data set
119 if len(set(datasets
)) > 1:
121 infotext
+= ", Cluster: data from nodes are not equal"
123 return state
, infotext
, [("tapes", num_tapes
), ("free", num_free_tapes
, warn
, crit
),
124 ("util", utilization
)]
127 check_info
['tsm_stagingpools'] = {
128 "parse_function": parse_tsm_stagingpools
,
129 "check_function": check_tsm_stagingpools
,
130 "inventory_function": inventory_tsm_stagingpools
,
131 "service_description": "TSM Stagingpool %s",
132 "has_perfdata": True,
133 "group": "tsm_stagingpools",
134 "default_levels_variable": "tsm_stagingpools_default_levels",