Module: check_mk
Branch: master
Commit: 4f9a0e78176356880fce646cc64a0ccf5a128f2f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4f9a0e78176356…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 18 18:35:00 2010 +0100
drbd checks handle unconfigured devices correctly now
---
ChangeLog | 2 ++
checkman/drbd | 3 ++-
checkman/drbd.disk | 3 ++-
checkman/drbd.net | 3 ++-
checkman/drbd.stats | 3 ++-
checks/drbd | 22 +++++++++++++++++-----
6 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 39d657f..3ca81d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -76,6 +76,8 @@
* j4p_performance.mem: added new experimental check for memory usage via JMX.
* if/if64: added Perf-O-Meter for Multisite
* Cleaned up several checks to meet the variable naming conventions
+ * drbd: Handling unconfigured drbd devices correctly. These devices are
+ ignored during nventory
Multisite:
* The custom open/close states of custom links are now stored for each
diff --git a/checkman/drbd b/checkman/drbd
index d907d00..b6fbf10 100644
--- a/checkman/drbd
+++ b/checkman/drbd
@@ -24,7 +24,8 @@ examples:
]
inventory:
- Each DRBD device will result in one service during inventory.
+ Each configured DRBD device will result in one service during inventory. All
+ devices with the connection state "Unconfigured" are skipped.
[parameters]
roles (list): The expected role of each node
diff --git a/checkman/drbd.disk b/checkman/drbd.disk
index 840849a..b80eecc 100644
--- a/checkman/drbd.disk
+++ b/checkman/drbd.disk
@@ -13,7 +13,8 @@ item:
The name of the DRBD device e.g. drbd0
inventory:
- Each DRBD device will result in one service during inventory.
+ Each configured DRBD device will result in one service during inventory. All
+ devices with the connection state "Unconfigured" are skipped.
perfdata:
It contains the current read and write disk I/O given as kb/s
diff --git a/checkman/drbd.netb/checkman/drbd.net
index 29ae710..04482f0 100644
--- a/checkman/drbd.net
+++ b/checkman/drbd.net
@@ -14,7 +14,8 @@ item:
The name of the DRBD device e.g. drbd0
inventory:
- Each DRBD device will result in one service during inventory.
+ Each configured DRBD device will result in one service during inventory. All
+ devices with the connection state "Unconfigured" are skipped.
perfdata:
It contains the current inbound and outbound network load given as kb/s
diff --git a/checkman/drbd.stats b/checkman/drbd.stats
index 0049a03..5c0b5c4 100644
--- a/checkman/drbd.stats
+++ b/checkman/drbd.stats
@@ -19,7 +19,8 @@ item:
The name of the DRBD device e.g. drbd0
inventory:
- Each DRBD device will result in one service during inventory.
+ Each configured DRBD device will result in one service during inventory. All
+ devices with the connection state "Unconfigured" are skipped.
perfdata:
One dataset is appended for each of the counters above.
diff --git a/checks/drbd b/checks/drbd
index f415dbf..c9af72e 100644
--- a/checks/drbd
+++ b/checks/drbd
@@ -146,9 +146,9 @@ drbd_stats_default_levels = ( None, None, None, None, None, None, None, None,
drbd_block_start_match = re.compile('^[0-9]+:')
drbd_general_map = [ 'cs', 'ro', 'ds' ]
-drbd_net_map = [ 'ns', 'nr' ]
-drbd_disk_map = [ 'dw', 'dr' ]
-drbd_stats_map = [ 'al', 'bm', 'lo', 'pe', 'ua', 'ap', 'ep', 'wo', 'oos' ]
+drbd_net_map = [ 'cs', 'ns', 'nr' ]
+drbd_disk_map = [ 'cs', 'dw', 'dr' ]
+drbd_stats_map = [ 'cs', 'al', 'bm', 'lo', 'pe', 'ua', 'ap', 'ep', 'wo', 'oos' ]
drbd_cs_map = {
'StandAlone': 1, 'Disconnecting': 1,
@@ -169,7 +169,11 @@ def inventory_drbd(checktype, info):
for line in info[2:]:
if drbd_block_start_match.search(line[0]) > 0:
parsed = drbd_parse_block(drbd_extract_block('drbd%s' % line[0][:-1], info), checktype)
- if checktype == 'drbd':
+ # Skip unconfigured drbd devices
+ if parsed['cs'] == 'Unconfigured':
+ continue
+
+ if checktye == 'drbd':
levels = '( [ "%s", "%s" ], [ "%s", "%s" ] )' % \
(parsed['ro'][0], parsed['ro'][1],
parsed['ds'][0], parsed['ds'][1])
@@ -235,7 +239,9 @@ def drbd_get_block(item, info, checktype):
def check_drbd_general(item, params, info):
parsed = drbd_get_block(item, info, 'drbd')
if not parsed is None:
- if not parsed['cs'] in drbd_cs_map:
+ if parsed['cs'] == 'Unconfigured':
+ return (2, 'CRITICAL - The device is "Unconfigured"')
+ elif not parsed['cs'] in drbd_cs_map:
return (3, 'UNKNOWN - Undefined "connection state" in drbd output')
# Weight of connection state is calculated by the drbd_cs_map.
@@ -274,6 +280,8 @@ def drbd_get_counters(list):
def check_drbd_net(item, params, info):
parsed = drbd_get_block(item, info, 'drbd.net')
if not parsed is None:
+ if parsed['cs'] == 'Unconfigured':
+ return (2, 'CRITICAL - The device is "Unconfigured"')
output, perfdata = drbd_get_counters([ ('drbd.net', 'in', item, int(parsed['nr']), 'kb'),
('drbd.net', 'out', item, int(parsed['ns']), 'kb') ])
# FIXME: Maybe handle thresholds in the future
@@ -284,6 +292,8 @@ def check_drbd_net(item, params, info):
def check_drbd_disk(item, params, info):
parsed = drbd_get_block(item, info, 'drbd.disk')
if not parsed is None:
+ if parsed['cs'] == 'Unconfigured':
+ return (2, 'CRITICAL - The device is "Unconfigured"')
output, perfdata = drbd_get_counters([ ('drbd.disk', 'write', item, int(parsed['dw']), 'kb'),
('drbd.disk', 'read', item, int(parsed['dr']), 'kb') ])
# FIXME: Maybe handle thresholds in the future
@@ -294,6 +304,8 @@ def check_drbd_disk(item, params, info):
def check_drbd_stats(item, params, info):
parsed = drbd_get_block(item, info, 'drbd.stats')
if not parsed is None:
+ if parsed['cs'] == 'Unconfigured':
+ return (2, 'CRITICAL - The device is "Unconfigured"')
output = ''
perfdata = []
for key, label in [ ('al', 'activity log updates'), ('bm', 'bit map updates'),
Module: check_mk
Branch: master
Commit: 4c1f2890eb220b937af897f7501c3e7602a28789
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4c1f2890eb220b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 16 08:10:47 2010 +0100
Fixed some global vars after reports of validate_checks
---
checks/blade_bays | 4 ++--
checks/heartbeat_crm | 5 ++---
doc/helpers/validate_checks | 2 +-
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/checks/blade_bays b/checks/blade_bays
index 80413da..672f423 100644
--- a/checks/blade_bays
+++ b/checks/blade_bays
@@ -24,7 +24,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-blade_bay_module_state = {
+blade_bays_module_state = {
0: 'standby',
1: 'on',
2: 'notPresent',
@@ -42,7 +42,7 @@ def check_blade_bays(item, params, info):
type = line[2]
if state == 1:
return (0, "OK - State %s (Type: %s, ID: %s)" %
- (blade_bay_module_state.get(state, 'Unhandled'), type, line[3]))
+ (blade_bays_module_state.get(state, 'Unhandled'), type, line[3]))
elif state == 2:
return (1, "WARNING - Not present")
elif state == 0:
diff --git a/checks/heartbeat_crm b/checks/heartbeat_crm
index 7e74547..566b731 100644
--- a/checks/heartbeat_crm
+++ b/checks/heartbeat_crm
@@ -44,8 +44,7 @@
# resource_slapmaster (ocf::heartbeat:OpenLDAP): Started mwp
# resource_slapslave (ocf::heartbeat:OpenLDAP): Started smwp
-from datetime import datetime, timedelta
-import time
+import time, datetime
# Nails down the DC to the node which is the DC during inventory. The check
# will report CRITICAL when another node becomes the DC during later checks.
@@ -98,7 +97,7 @@ def check_heartbeat_crm(item, params, info):
# Check the freshness of the crm_mon output and terminate with CRITICAL
# when too old information are found
- dt = int(datetime(*time.strptime(lastUpdated, '%a %b %d %H:%M:%S %Y')[0:5]).strftime("%s"))
+ dt = int(datetime.datetime(*time.strptime(lastUpdated, '%a %b %d %H:%M:%S %Y')[0:5]).strftime("%s"))
now = time.time()
delta = now - dt
if delta > param_max_age:
diff --git a/doc/helpers/validate_checks b/doc/helpers/validate_checks
index 5850bd0..0d2ab6c 100755
--- a/doc/helpers/validate_checks
+++ b/doc/helpers/validate_checks
@@ -110,7 +110,7 @@ def usage():
print "No real help available... The only option is -v|--verbose."
sys.exit(0)
-ignored_variables = []
+ignored_variables = [ 'datetime', ]
# Load all checks and record global var definitions
# Also read the man pages