Module: check_mk
Branch: master
Commit: 4c35c9d1e3ea4a17632c23475f8cb8d43614d370
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4c35c9d1e3ea4a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Aug 21 14:51:31 2011 +0200
WATO: Show error message in case of inventory error
---
.bugs/11 | 10 +++++++---
ChangeLog | 3 +++
modules/check_mk.py | 3 +++
modules/check_mk_base.py | 5 +++++
web/htdocs/wato.py | 7 ++++++-
5 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/.bugs/11 b/.bugs/11
index 7a8c61d..d91ed07 100644
--- a/.bugs/11
+++ b/.bugs/11
@@ -1,10 +1,11 @@
Title: Keine Fehlermeldung bei Connection closed
Component: wato
+State: done
+Class: nastiness
+Date: 2010-12-21 12:09:13
Benefit: 2
-State: open
Cost: 3
-Date: 2010-12-21 12:09:13
-Class: nastiness
+Fun: 0
Wenn der Check_MK Agent einen nicht reinlässt (only_from gesetzt),
dann bekommen man nicht Connection refused, sondern eine
@@ -13,3 +14,6 @@ Fehler. WATO zeigt bei der Inventur einfach keine Dienste an.
Der try-inventory sollte das aber als Fehler behandeln und
irgendwie anzeigen. Schließlich ist über die Tags ja festgelegt,
dass vom Agenten Daten kommen sollen.
+
+2011-08-21 14:51:12: changed state open -> done
+Jetzt kommt eine sinnvolle Fehlermeldung.
diff --git a/ChangeLog b/ChangeLog
index 77d883e..e2685fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -37,6 +37,9 @@
* Man-Pages of Check_MK checks shown in Multisite honor OMD's local hierarchy
* nicer output of substates, translate (!) and (!!) into HTML code
+ WATO:
+ * Show error message in case of empty inventory due to agent error
+
1.1.11i2:
Core, Setup, etc.:
* FIX: sort output of cmk --list-hosts alphabetically
diff --git a/modules/check_mk.py b/modules/check_mk.py
index f7d6d3d..2d8d9f9 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1870,6 +1870,8 @@ def make_inventory(checkname, hostnamelist, check_only=False,
include_state=Fals
raise
elif not include_state and str(e):
sys.stderr.write("Host '%s': %s\n" % (hostname, str(e)))
+ elif include_state and str(e): # WATO automation. Abort
+ raise
continue
except MKSNMPError, e:
# This special handling is needed for the inventory check. It needs
special
@@ -1966,6 +1968,7 @@ def make_inventory(checkname, hostnamelist, check_only=False,
include_state=Fals
except KeyboardInterrupt:
sys.stderr.write('<Interrupted>\n')
+
if not check_only:
if newchecks != []:
filename = autochecksdir + "/" + checkname + "-" +
time.strftime("%Y-%m-%d_%H.%M.%S")
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index c9e1059..a6b2009 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -475,7 +475,12 @@ def get_agent_info_tcp(hostname, ipaddress):
else:
break
s.close()
+ if len(output) == 0: # may be caused by xinetd not allowing our address
+ raise MKAgentError("Empty output from agent at TCP port %d" %
+ agent_port_of(hostname))
return output
+ except MKAgentError, e:
+ raise
except Exception, e:
raise MKAgentError("Cannot get data from TCP port %s:%d: %s" %
(ipaddress, agent_port_of(hostname), e))
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 32002f0..fd58fd9 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2050,7 +2050,12 @@ def changelog_button():
def show_service_table(hostname, firsttime):
# Read current check configuration
cache_options = not html.var("_scan") and [ '--cache' ] or []
- table = check_mk_automation("try-inventory", cache_options + [hostname])
+ try:
+ table = check_mk_automation("try-inventory", cache_options +
[hostname])
+ except Exception, e:
+ html.show_error("Inventory failed for this host: %s" % e)
+ return
+
table.sort()
html.begin_form("checks", None, "POST")