This file is indexed.

/usr/share/check_mk/checks/fc_brocade_port is in check-mk-server 1.1.12-1ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# |             ____ _               _        __  __ _  __           |
# |            / ___| |__   ___  ___| | __   |  \/  | |/ /           |
# |           | |   | '_ \ / _ \/ __| |/ /   | |\/| | ' /            |
# |           | |___| | | |  __/ (__|   <    | |  | | . \            |
# |            \____|_| |_|\___|\___|_|\_\___|_|  |_|_|\_\           |
# |                                                                  |
# | Copyright Mathias Kettner 2010             mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software;  you can redistribute it and/or modify it
# under the  terms of the  GNU General Public License  as published by
# the Free Software Foundation in version 2.  check_mk is  distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY;  with-
# out even the implied warranty of  MERCHANTABILITY  or  FITNESS FOR A
# PARTICULAR PURPOSE. See the  GNU General Public License for more de-
# ails.  You should have  received  a copy of the  GNU  General Public
# License along with GNU Make; see the file  COPYING.  If  not,  write
# to the Free Software Foundation, Inc., 51 Franklin St,  Fifth Floor,
# Boston, MA 02110-1301 USA.


# targetstate is 1 (used) or 0 (unused)
# info columns: INDEX PHYSTATE OPSTATE TXWORDS RXWORDS
brocade_pystate_names = ['', 'noCard', 'noTransceiver', 'laserFault', 'noLight',
                         'noSync', 'inSync', 'portFault', 'diagFault', 'lockRef']
brocade_opstate_names = [ 'unknown', 'online', 'offline', 'testing', 'faulty']
brocade_perfdata_errors = False
brocade_default_params = (0.1, 0.01)

def inventory_brocade_port(info):
    inventory = []
    for index, phystate, opstate, txwords, rxwords, crcerrors, c3discards in info:
        state = (int(phystate), int(opstate))
        if state == (4,2):
            used = 0
            used_txt = "unused"
        elif phystate == "1" or phystate == "2":
            used = 0
            used_txt = "no card or no transceiver"
        else:
            used = 1
            used_txt = "used"
        # index  is e.g. '3'. But port number printed on switch
        # and in management software of switch counts from 0, so subtract
        # one. Also make it 2-digits => '03'
        if used:
            index = "%02d" % (int(index) - 1)
            inventory.append( (index, used_txt, "brocade_default_params") )
    return inventory


def check_brocade_port(portno, params, info):
    try:
        warning, critical = params
    except:
        warning, critical = (0.1, 0.01) # percent error rate

    # SNMP counts ports from 1, but management console and hardware from 0
    portinfo = [ line[1:] for line in info if int(line[0]) == int(portno) + 1 ]
    if len(portinfo) < 1:
        return (3, "UNKNOWN - No port number %d present" % int(portno))
    phystate, opstate, txwords, rxwords, crcerrors, c3discards = map(int, portinfo[0])
    perfdata = [
        ( "txwords", "%dc" % txwords ),
        ( "rxwords", "%dc" % rxwords ) ]
    if brocade_perfdata_errors:
        perfdata += [
            ( "crcerrors", "%dc" % crcerrors ),
            ( "c3discards", "%dc" % c3discards ) ]


    state = phystate,opstate
    if state == (6,1):
        return (0, "OK - physical and logical link UP", perfdata)
    else:
        return (2, "CRIT - physical state %s, opstate %s" %
                (brocade_pystate_names[phystate],
                 brocade_opstate_names[opstate]), perfdata)


check_info['fc_brocade_port'] = (check_brocade_port, "PORT %s", 1,  inventory_brocade_port)
snmp_info['fc_brocade_port'] = ( ".1.3.6.1.4.1.1588.2.1.1.1.6.2.1", [ 1, 3, 4, 11, 12, 22, 28 ] )
snmp_scan_functions['fc_brocade_port'] = \
       lambda oid: False # prefer fc_brodade_port_detailed
# 1: swFCPortIndex, 3: swFCPortOpStatus, 4:swFCPortAdmStatus,
# 11: swFCPortTxWords, 12: swFCPortRxWords
# 22: swFCPortRxCrcs, 28: swFCPortC3Discards
check_config_variables.append("brocade_perfdata_errors")