Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / ibm_svc_node
blob2be83cac25b41bece1755a55bd69dc40edb980d3
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 from agent:
28 # Put here the example output from your TCP-Based agent. If the
29 # check is SNMP-Based, then remove this section
31 # newer agent output with more columns
32 # 1:N1_164191:10001AA202:500507680100D7CA:online:0:io_grp0:no:2040000051442002:CG8:iqn.1986-03.com.ibm:2145.svc-cl.n1164191::164191:::::
33 # 2:N2_164373:10001AA259:500507680100D874:online:0:io_grp0:no:2040000051442149:CG8:iqn.1986-03.com.ibm:2145.svc-cl.n2164373::164373:::::
34 # 5:N3_162711:100025E317:500507680100D0A7:online:1:io_grp1:no:2040000085543047:CG8:iqn.1986-03.com.ibm:2145.svc-cl.n3162711::162711:::::
35 # 6:N4_164312:100025E315:500507680100D880:online:1:io_grp1:yes:2040000085543045:CG8:iqn.1986-03.com.ibm:2145.svc-cl.n4164312::164312:::::
38 def inventory_ibm_svc_node(info):
39 io_groups = set()
40 for line in info:
41 _node_id, _node_name, _ups_serial, _wwnn, _node_status, _io_group_id,\
42 io_group_name, _config_node, _ups_unique_id, _hardware, _iscsi_name,\
43 _iscsi_alias, _panel_name, _enclosure_id, _canister_id,\
44 _enclosure_serial_number, _additional = line[:17]
45 io_groups.add(io_group_name)
46 return [(io_group_name, None) for io_group_name in io_groups]
49 def check_ibm_svc_node(item, _no_params, info):
50 message = ""
51 status = 0
52 online_nodes = 0
53 nodes_of_iogroup = 0
55 for line in info:
56 _node_id, node_name, _ups_serial, _wwnn, node_status, _io_group_id,\
57 io_group_name, _config_node, _ups_unique_id, _hardware, _iscsi_name,\
58 _iscsi_alias, _panel_name, _enclosure_id, _canister_id,\
59 _enclosure_serial_number, _additional = line[:17]
60 if io_group_name == item:
61 if message != "":
62 message += ", "
63 message += "Node %s is %s" % (node_name, node_status)
64 nodes_of_iogroup += 1
65 if node_status == "online":
66 online_nodes += 1
68 if nodes_of_iogroup == 0:
69 return 3, "IO Group %s not found in agent output" % item
71 if nodes_of_iogroup == online_nodes:
72 status = 0
73 elif online_nodes == 0:
74 status = 2
75 else:
76 status = 1
78 return status, message
81 check_info["ibm_svc_node"] = {
82 "check_function": check_ibm_svc_node,
83 "inventory_function": inventory_ibm_svc_node,
84 "service_description": "IO Group %s",