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 def inventory_h3c_lanswitch_sensors(info
):
29 return [(h3c_lanswitch_genitem(line
[0]), None) for line
in info
if line
[1] in ['1', '2']]
32 def check_h3c_lanswitch_sensors(item
, params
, info
):
33 # the values are: active (1), deactive (2), not-install (3), unsupport (4)
34 for (endoid
, status
) in info
:
35 if h3c_lanswitch_genitem(endoid
) == item
:
37 return (2, "Sensor %s status is %s" % (item
, status
))
39 return (0, "Sensor %s status is %s" % (item
, status
))
40 return (1, "Sensor % status is %s" % (item
, status
))
41 return (3, "Sensor %s not found" % item
)
44 check_info
["h3c_lanswitch_sensors"] = (check_h3c_lanswitch_sensors
, "%s", 0,
45 inventory_h3c_lanswitch_sensors
)
48 def h3c_lanswitch_genitem(endoid
):
49 deviceclass
, _one
, id_
= endoid
.split(".")
50 if deviceclass
== "1":
53 hwLswdev
= "Powersupply"
54 unitid
= int(id_
) / 65536
55 num
= int(id_
) % 65536
56 return "Unit %d %s %d" % (unitid
, hwLswdev
, num
)
59 # mib: A3COM-HUAWEI-LswDEVM-MIB
60 # fan table: A3COM-HUAWEI-OID-MIB::lswCommon.9.1.1.1.1.65536 = INTEGER: 65536
61 # fan status: A3COM-HUAWEI-OID-MIB::lswCommon.9.1.1.1.2.65536 = INTEGER: 1
62 # hwdevMPowerStatusTable ( hwDevMPowerNum, hwDevMPowerStatus )
63 # hwdevMFanStatusTable
66 # finally,just check fan status
67 snmp_info
["h3c_lanswitch_sensors"] = (".1.3.6.1.4.1.43.45.1.2.23.1.9.1", ["1.1", "2.1"],
70 snmp_scan_functions
["h3c_lanswitch_sensors"] = lambda oid
: '3com s' in oid(".1.3.6.1.2.1.1.1.0"