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 ## Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll
30 # *** lan0 64 bit MIB statistics:
31 # Interface Name = lan0
33 # Description = lan0 HP PCI-X 1000Base-T Release PHNE_36238 B.11.31.0709.02
34 # Interface Type = 1000Base-T
37 # Station Address = 0x001A4B067700
38 # Administration Status = UP
39 # Operation Status = UP
40 # Last Change = Tue Jul 13 10:36:24 2010
41 # Inbound Octets = 30886837904
42 # Inbound Unicast Packets = 25436296
43 # Inbound Multicast Packets = 0
44 # Inbound Broadcast Packets = 357491069
45 # Inbound Discards = 0
47 # Inbound Unknown Protocols = 357491069
48 # Outbound Octets = 3510268106
49 # Outbound Unicast Packets = 25436308
50 # Outbound Multicast Packets = 0
51 # Outbound Broadcast Packets = 0
52 # Outbound Discards = 0
54 # Counter Discontinuity Time = Tue Jul 13 10:36:24 2010
55 # Physical Promiscuous Mode = FALSE
56 # Physical Connector Present = TRUE
58 # Link Up/Down Trap Enable = Enabled
61 def hpux_convert_to_if64(info
):
67 nic
[2] = '6' # fake port type Ethernet
69 line_txt
= " ".join(line
)
70 left
, right
= line_txt
.split("=")
73 if left
== "PPA Number":
76 nic
[3] = hpux_parse_speed(right
)
77 elif left
== "Inbound Octets":
79 elif left
== "Inbound Unicast Packets":
81 elif left
== "Inbound Multicast Packets":
83 elif left
== "Inbound Broadcast Packets":
85 elif left
== "Inbound Discards":
87 elif left
== "Inbound Errors":
89 elif left
== "Outbound Octets":
91 elif left
== "Outbound Unicast Packets":
93 elif left
== "Outbound Multicast Packets":
95 elif left
== "Outbound Broadcast Packets":
97 elif left
== "Outbound Discards":
99 elif left
== "Outbound Errors":
101 elif left
== "Operation Status":
102 nic
[4] = hpux_parse_operstatus(right
)
103 elif left
== "Interface Name":
106 elif left
== "Station Address":
108 nic
[19] = "".join([chr(int(x
+ y
, 16)) for (x
, y
) in zip(h
[::2], h
[1::2])])
112 def hpux_parse_speed(speed
):
113 parts
= speed
.split()
114 if parts
[1] == "Gbps":
115 mult
= 1000 * 1000 * 1000
118 return float(parts
[0]) * mult
121 def hpux_parse_operstatus(txt
):
122 if txt
.lower() == "up":
127 def inventory_hpux_if(info
):
128 return inventory_if_common(hpux_convert_to_if64(info
))
131 def check_hpux_if(item
, params
, info
):
132 return check_if_common(item
, params
, hpux_convert_to_if64(info
))
135 check_includes
['hpux_if'] = ["if.include"]
137 check_info
["hpux_if"] = {
138 'check_function': check_hpux_if
,
139 'inventory_function': inventory_hpux_if
,
140 'service_description': 'NIC %s',
141 'has_perfdata': True,
143 'default_levels_variable': 'if_default_levels',