Module: check_mk
Branch: master
Commit: 7d5bce7b882b645985672131bc0a6bc6b35aebfd
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7d5bce7b882b64…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Dec 6 13:45:08 2010 +0100
fc_brocade_port_detailed: configure states for port states
---
ChangeLog | 2 ++
checkman/fc_brocade_port_detailed | 37 ++++++++++++++++++++++++++++++-------
checks/fc_brocade_port_detailed | 27 +++++++++++++++++++++------
3 files changed, 53 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3f4bee3..2360c70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -53,6 +53,8 @@
per-host configuration
Checks & Agents:
+ * fc_brocade_port_detailed: allow to specify port state combinations not
+ to be critical
* megaraid_pdisks: Using the real enclosure number as check item now
* if/if64: Added expected interface speed to warning output
* if/if64: Allow to ignore speed setting (set target speed to None)
diff --git a/checkman/fc_brocade_port_detailed b/checkman/fc_brocade_port_detailed
index bc75a8b..c7a63ad 100644
--- a/checkman/fc_brocade_port_detailed
+++ b/checkman/fc_brocade_port_detailed
@@ -17,14 +17,26 @@ item:
examples:
# set levels for errors, not for in/out
fc_brocade_port_detailed_default_levels = (
- ( 1, 500 ), # warn at 1, crit at 500 CRC errors per check intervall
- ( 0.1, 10.0 ), # warn/crit if encout is more then 0.1 or 10% of packets
+ ( 1, 500 ), # warn at 1, crit at 500 CRC errors per check intervall
+ ( 0.1, 10.0 ), # warn/crit if encout is more then 0.1 or 10% of packets
( 101.0, 101.0 ) ) # do never alert C3 discards
# Same, but warning if traffic more than 160MB/s on in or out,
# no level for critical and assumed link baudrate of 2GBit/s
fc_brocade_port_detailed_default_levels = (
- (1, 500), (0.1, 10.0), (101.0, 101.0), (2, 160, None))
+ ( 1, 500),
+ ( 0.1, 10.0 ),
+ ( 101.0, 101.0 ),
+ ( 2, 160, None ) )
+
+ # Some, but additionally specify certain state-combinations to be
+ # only warning / not critical
+ fc_brocade_port_detailed_default_levels = (
+ ( 1, 500),
+ ( 0.1, 10.0 ),
+ ( 101.0, 101.0 ),
+ ( 2, 160, None, [(1,6,2), (1,4,2)]) )
+
perfdata:
Five variables: the number of bytes received and transmitted, and the number
@@ -43,15 +55,26 @@ crcerrors (number, number): A pair of levels for the CRC errors. If
the level is
to the total number of packets received in the last check cycle.
encout (number, number): A pair of levels for the ENC out counter.
c3discards (number, number): A pair of levels for the C3 discards.
-inoutlevels (number, number, number): An optional triple used for
- checking in- and outgoing traffic. The first argument is the assumed link speed
- in GBit/sec. For inter switch links (ISL) the brocade MIB contains an
+inoutlevels (number, number, number, list): An optional quadruple used for
+ checking in- and outgoing traffic and the possible port states.
+ The first argument is the assumed link speed
+ in GBit/sec. For inter-switch links (ISL) the brocade MIB contains an
entry for the current speed - which is being used. If that is different
from the assumed link speed, then the levels are adapted accordingly.
If you set the assumed link speed to 2, the level to 160 and the detected
- link speed is 4GBit/s, then the level is being raised to 320. The other
+ link speed is 4GBit/s, then the level is being raised to 320. The next
two arguments are the levels for warning and critical in MB/s. Each of those may
be set to {None} in order to disable that level.
+ The forth argument is optional and is a list of triples. This list
+ makes selected port states not result in a critical but in a user
+ defined state. Each triple is consists of ({exitcode}, {physical state},
+ {opstate}). The possible exitcodes are {0} for OK, {1} for WARNING, {2} for
+ CRITICAL and {3} for UNKNOWN. The possible physical states are: {noCard(1)},
+ {noTransceiver(2)}, {laserFault(3)}, {noLight(4)}, {noSync(5)}, {inSync(6)},
+ {portFault(7)}, {diagFault(8)}, {lockRef(9)} The possible opstates are:
+ {online(1)}, {offline(2)}, {testing(3)}, {faulty(4)}. So if you want
+ {noLight/offline} to be OK and {inSync/testing} to be WARN, set the list to
+ {[(0,4,2),(1,6,3)]}.
[configuration]
fc_brocade_port_detailed_default_levels ( pair, pair, pair, triple ):
diff --git a/checks/fc_brocade_port_detailed b/checks/fc_brocade_port_detailed
index 5d38dad..dbbcb24 100644
--- a/checks/fc_brocade_port_detailed
+++ b/checks/fc_brocade_port_detailed
@@ -27,10 +27,12 @@
# 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']
+# 0 1 2 3 4 5
6 7 8 9
+brocade_phystate_names = [ '', 'noCard', 'noTransceiver',
'laserFault', 'noLight', 'noSync', 'inSync',
'portFault', 'diagFault', 'lockRef' ]
+# 0 1 2 3 4
+brocade_opstate_names = [ 'unknown', 'online', 'offline',
'testing', 'faulty' ]
-fc_brocade_port_detailed_default_levels = ( (1, 0.1), (1, 0.1), (1, 0.1), (2, 160, None)
)
+fc_brocade_port_detailed_default_levels = ( (1, 0.1), (1, 0.1), (1, 0.1), (2, 160, None,
[]) )
def inventory_brocade_port(checkname, info):
porttable, isltable = info
@@ -62,6 +64,7 @@ def check_brocade_port(portno, params, info):
portinfo = [ line[1:] for line in porttable 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, txframes, rxframes, crcerrors, encout,
c3discards = map(int, portinfo[0])
baudrate = None
baudinfo = ""
@@ -75,8 +78,11 @@ def check_brocade_port(portno, params, info):
baudrate = 1.0 * (float(brmult) / 16)
baudinfo = ", ISL with baudrate: %gGBit/s" % (baudrate, )
+ special_states = []
if len(params) >= 4:
- assumed_baudrate, io_warn, io_crit = params[3]
+ assumed_baudrate, io_warn, io_crit = params[3][0:3]
+ if len(params[3]) >= 4:
+ special_states = params[3][3]
if not baudinfo:
baudinfo = ", assumed baudrate: %gGBit/s" % assumed_baudrate
@@ -101,9 +107,18 @@ def check_brocade_port(portno, params, info):
]
# First check if port has physical and logical link
- state = phystate,opstate
+ state = phystate, opstate
if state != (6,1):
- return (2, "CRIT - physical state %s, opstate %s" %
(brocade_pystate_names[phystate], brocade_opstate_names[opstate]), perfdata)
+ # If port is in one of the states that are especially configured in the
parameters,
+ # the exit could is set by the admin
+ nagioscode = 2
+ for ncode, phy, op in special_states:
+ if (phy,op) == (phystate, opstate):
+ nagioscode = ncode
+ break
+ return (nagioscode, "%s - physical state %s(%d), opstate %s(%d)" % (
+ nagios_state_names[nagioscode], brocade_phystate_names[phystate],
+ phystate, brocade_opstate_names[opstate], opstate), perfdata)
# Now check rates of various error counters
this_time = time.time()