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 # Example output from agent:
28 # <<<hpux_multipath>>>
29 # LUN PATH INFORMATION FOR LUN : /dev/rtape/tape1_BEST
30 # World Wide Identifier(WWID) = 0x600508b4000139e500049000075e0000
32 # LUN PATH INFORMATION FOR LUN : /dev/rdisk/disk10
33 # World Wide Identifier(WWID) = 0x600508b4000139e500009000075e00b0
35 # LUN PATH INFORMATION FOR LUN : /dev/rdisk/disk13
36 # World Wide Identifier(WWID) = 0x600508b4000139e500009000075e00c0
38 # LUN PATH INFORMATION FOR LUN : /dev/pt/pt2
39 # World Wide Identifier(WWID) = 0x600508b4000139e500009000075e00d0
48 # LUN PATH INFORMATION FOR LUN : /dev/rdisk/disk781
49 # World Wide Identifier(WWID) = 0x600508b4000139e500009000075e00e0
56 # LUN PATH INFORMATION FOR LUN : /dev/rdisk/disk912
57 # World Wide Identifier(WWID) = 0x600508b4000139e500009000075e00f0
63 hpux_multipath_pathstates
= {
73 def parse_hpux_multipath(info
):
78 elif line
[0] == "World":
80 paths
= [0, 0, 0, 0] # ACTIVE, STANBY, FAILED, UNOPEN
81 disks
[wwid
] = (disk
, paths
)
84 paths
[hpux_multipath_pathstates
[state
]] += 1
88 def inventory_hpux_multipath(info
):
90 disks
= parse_hpux_multipath(info
)
91 for wwid
, (_disk
, (active
, standby
, failed
, unopen
)) in disks
.items():
92 if active
+ standby
+ failed
>= 2:
93 inventory
.append((wwid
, (active
, standby
, failed
, unopen
)))
97 def hpux_multipath_format_pathstatus(pathcounts
):
99 for name
, i
in hpux_multipath_pathstates
.items():
102 infos
.append("%d %s" % (c
, name
))
103 return ", ".join(infos
)
106 def check_hpux_multipath(item
, params
, info
):
107 disks
= parse_hpux_multipath(info
)
108 if item
not in disks
:
109 return (3, "no LUN with this WWID found")
110 disk
, pathcounts
= disks
[item
]
112 if pathcounts
[2] > 0:
113 return (2, "%s: %d failed paths! (%s)" % (disk
, pathcounts
[2],
114 hpux_multipath_format_pathstatus(pathcounts
)))
116 elif list(pathcounts
) != list(params
):
117 return (1, "%s: Invalid path status %s (should be %s)" %
118 (disk
, hpux_multipath_format_pathstatus(pathcounts
),
119 hpux_multipath_format_pathstatus(params
)))
120 return (0, "%s: %s" % (disk
, hpux_multipath_format_pathstatus(pathcounts
)))
123 check_info
["hpux_multipath"] = {
124 'check_function': check_hpux_multipath
,
125 'inventory_function': inventory_hpux_multipath
,
126 'service_description': 'Multipath %s',
127 'group': 'hpux_multipath',