Module: check_mk
Branch: master
Commit: e48d9c472b48f09a52e2652ea3417baa7d69c057
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e48d9c472b48f0…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Oct 29 11:20:24 2010 +0200
cleaned up some code in win_dhcp_pools check
---
ChangeLog | 1 +
LIESMICH.zutun | 19 -------------------
checks/win_dhcp_pools | 36 ++++++++++++------------------------
3 files changed, 13 insertions(+), 43 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bc3c93d..b5551d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,7 @@
* blade_health: More detailed output on problems
* blade_blades: Added new check for checking the health-, present- and
power-state of IBM Bladecenter blades
+ * win_dhcp_pools: Several cleanups in check
Multisite:
* The custom open/close states of custom links are now stored for each
diff --git a/LIESMICH.zutun b/LIESMICH.zutun
index 558032d..429882e 100644
--- a/LIESMICH.zutun
+++ b/LIESMICH.zutun
@@ -9,25 +9,6 @@ BUGS beheben ab 1.1.9i1
Wenn zwei Checks mit dem gleichen Namen existieren bei einem Host
soll mit einem Fehler abgebrochen werden.
-win_dhcp_pools sendet:
-[['MIBCounts:'],
- ['Discovers', '=', '193.'],
- ['Offers', '=', '193.'],
- ['Delayed', 'Offers', '=', '0.'],
- ['Requests', '=', '14540.'],
- ['Acks', '=', '11767.'],
- ['Naks', '=', '2.'],
- ['Declines', '=', '0.'],
- ['Releases', '=', '39.'],
- ['ServerStartTime', '=', '26', 'June', '2010',
'04:47:49'],
- ['Scopes', '=', '1.'],
- ['Scopes', 'with', 'Delay', 'configured=',
'0.'],
- ['Subnet', '=', '10.3.108.0.'],
- ['No.', 'of', 'Addresses', 'in', 'use',
'=', '40.'],
- ['No.', 'of', 'free', 'Addresses', '=',
'150.'],
- ['No.', 'of', 'pending', 'offers', '=',
'0.']]
-Besser: = als Trenner nehmen, dann ist das parsen einfacher.
-
ich bin mir nicht sicher ob das nun ein Thruk Problem oder ein Livestatus Problem ist.
Vermutlich beides :-)
Wenn ich im Thruk im Suchfenster einfach Enter drücke, kommt folgende Query bei raus:
GET services
diff --git a/checks/win_dhcp_pools b/checks/win_dhcp_pools
index bc96e1a..4e5d698 100644
--- a/checks/win_dhcp_pools
+++ b/checks/win_dhcp_pools
@@ -77,34 +77,26 @@ win_dhcp_pools_stats_translate = {
'Anzahl der anstehenden Angebote': 'No. of pending offers',
}
+def parse_win_dhcp_pools(info):
+ return [ ' '.join(line).rstrip('.').split(' = ') for line in
info ]
+
def inventory_win_dhcp_pools(checktype, info):
inventory = []
- for line in info:
- start = line[0]
- if start in win_dhcp_pools_stats_translate:
- start = win_dhcp_pools_stats_translate[line[0]]
- if start == 'Subnet':
- inventory.append((line[2].rstrip('.'),
'win_dhcp_pools_default_levels'))
+ for line in parse_win_dhcp_pools(info):
+ if win_dhcp_pools_stats_translate.get(line[0], line[0]) == 'Subnet':
+ inventory.append((line[1], 'win_dhcp_pools_default_levels'))
return inventory
def check_win_dhcp_pools(item, params, info):
inBlock = False
poolStats = []
status = 0
- for line in info:
- # Translate if needed
- start = line[0]
- if start in win_dhcp_pools_stats_translate:
- start = win_dhcp_pools_stats_translate[line[0]]
-
- if start == 'Subnet' and line[-1] == item+'.':
+ for line in parse_win_dhcp_pools(info):
+ if win_dhcp_pools_stats_translate.get(line[0], line[0]) == 'Subnet' and
line[1] == item:
inBlock = True
continue
if inBlock:
- key = ' '.join(line[:-2])
- if key in win_dhcp_pools_stats_translate:
- key = win_dhcp_pools_stats_translate[key]
- poolStats.append(saveint(line[-1].rstrip('.')))
+ poolStats.append(saveint(line[1]))
if len(poolStats) == 3:
break
@@ -140,16 +132,12 @@ def check_win_dhcp_pools_stats(item, params, info):
this_time = int(time.time())
timedif = 0
- for line in info:
+ for line in parse_win_dhcp_pools(info):
if len(line) > 0:
- if line[0] in win_dhcp_pools_stats_translate:
- key = win_dhcp_pools_stats_translate[line[0]]
- else:
- key = line[0]
-
+ key = win_dhcp_pools_stats_translate.get(line[0], line[0])
if key in [ 'Discovers', 'Offers', 'Requests',
'Acks',
'Nacks', 'Declines', 'Releases',
'Scopes' ]:
- value = saveint(line[2].rstrip('.'))
+ value = saveint(line[1])
try:
timedif, per_sec = get_counter("win_dhcp_stats.%s" % key,
this_time, value)
except MKCounterWrapped: