GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / sni_octopuse_trunks
blob96a4499d3e4946e7c1f8d83fdcb57a75e1b659eb
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 #.1.3.6.1.4.1.231.7.2.9.3.8.1.3.1 "OpenStage 30"
28 #.1.3.6.1.4.1.231.7.2.9.3.8.1.3.2 "OpenStage 30"
29 #.1.3.6.1.4.1.231.7.2.9.3.8.1.3.7 "P. O. T."
30 #.1.3.6.1.4.1.231.7.2.9.3.8.1.3.9 "S0 extension"
31 #.1.3.6.1.4.1.231.7.2.9.3.8.1.3.11 "S0 trunk: extern"
32 #.1.3.6.1.4.1.231.7.2.9.3.8.1.3.13 "<not configured>: extern"
33 #[...]
34 #.1.3.6.1.4.1.231.7.2.9.3.8.1.4.11 2
35 #.1.3.6.1.4.1.231.7.2.9.3.8.1.4.13 1
38 def inventory_octopus_trunks(info):
39 trunkports = ["S0 trunk: extern"]
40 inventory = []
41 for line in info[0]:
42 if len(line) == 4:
43 portindex, cardindex, porttype, portstate = line
44 portdesc = "%s/%s" % (cardindex, portindex)
45 if porttype in trunkports and portstate == "2":
46 inventory.append((portdesc, None))
47 return inventory
50 def check_octopus_trunks(item, _no_params, info):
51 for line in info[0]:
52 portindex, cardindex, porttype, portstate = line
53 portdesc = "%s/%s" % (cardindex, portindex)
54 if item == portdesc:
55 # There are two relevant card states, we use the one from
56 # octoPortTable
57 if portstate == "1":
58 return (2, "Port [%s] is inactive" % porttype)
59 return (0, "Port [%s] is active" % porttype)
61 return (3, "UNKW - unknown data received from agent")
63 check_info['sni_octopuse_trunks'] = {
64 'check_function' : check_octopus_trunks,
65 'inventory_function' : inventory_octopus_trunks,
66 'service_description': "Trunk Port %s",
67 'snmp_scan_function' : lambda oid: "agent for hipath" in \
68 oid(".1.3.6.1.2.1.1.1.0").lower(),
69 'snmp_info' : [ (".1.3.6.1.4.1.231.7.2.9.3.8.1", [
70 "1", # portIndex
71 "2", # port card index (slot)
72 "3", # PortType
73 "4", # Port State
74 ]),