Module: check_mk
Branch: master
Commit: a6edf6239a3a5554b6ed81cb33b86451b865fac9
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a6edf6239a3a55…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Aug 25 13:54:45 2016 +0200
3767 FIX Fixed possible UnicodeDecodeError when having users with umlauts in the user ID
---
.werks/3767 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/config.py | 2 +-
web/htdocs/userdb.py | 3 ++-
4 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/.werks/3767 b/.werks/3767
new file mode 100644
index 0000000..919ecfd
--- /dev/null
+++ b/.werks/3767
@@ -0,0 +1,10 @@
+Title: Fixed possible UnicodeDecodeError when having users with umlauts in the user ID
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i1
+Date: 1472126075
+
+
diff --git a/ChangeLog b/ChangeLog
index 369e1ae..07ddcfe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -455,6 +455,7 @@
* 3561 FIX: Removing a comment now also removes any linked acknowledgements...
* 3763 FIX: Fixed playing sounds in views when using current Firefox...
* 3779 FIX: availability: added validation of availability options
+ * 3767 FIX: Fixed possible UnicodeDecodeError when having users with umlauts in the user ID
WATO:
* 3244 WATO BI Module: swap order of aggregation function and child node selection...
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index 90fb6f6..a9175de 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -337,7 +337,7 @@ def roles_of_user(user):
return [ "guest" ]
elif users != None and user in users:
return [ "user" ]
- elif os.path.exists(config_dir + "/" + user + "/automation.secret"):
+ elif os.path.exists(config_dir + "/" + user.encode("utf-8") + "/automation.secret"):
return [ "guest" ] # unknown user with automation account
elif 'roles' in default_user_profile:
return existing_role_ids(default_user_profile['roles'])
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 043df3c..6890de4 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -229,7 +229,8 @@ def _user_exists_according_to_profile(username):
def _user_exists_htpasswd(username):
for line in open(defaults.htpasswd_file):
- if line.startswith("%s:" % username):
+ l = line.decode("utf-8")
+ if l.startswith("%s:" % username):
return True
return False
Module: check_mk
Branch: master
Commit: 3d0b294ecf22e458d9be5c7c6856f7d8409c9e58
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3d0b294ecf22e4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Aug 25 13:33:39 2016 +0200
3765 FIX oracle_asm_diskgroup: Made check more robust against invalid data received from agent
It may happen, at least with older version of the agent plugin, that the help text of SQLPlus
is sent in the agent sections. This could lead to ~50 services being created by accident. The
changed check now ignores these unexpected lines from the agent and only processes lines which
match the known format.
---
.werks/3765 | 13 +++++++++++++
ChangeLog | 1 +
checks/oracle_asm_diskgroup | 9 ++++++---
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/.werks/3765 b/.werks/3765
new file mode 100644
index 0000000..3dd9e99
--- /dev/null
+++ b/.werks/3765
@@ -0,0 +1,13 @@
+Title: oracle_asm_diskgroup: Made check more robust against invalid data received from agent
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i1
+Date: 1472124723
+
+It may happen, at least with older version of the agent plugin, that the help text of SQLPlus
+is sent in the agent sections. This could lead to ~50 services being created by accident. The
+changed check now ignores these unexpected lines from the agent and only processes lines which
+match the known format.
diff --git a/ChangeLog b/ChangeLog
index bf35bd5..4f4d3cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -351,6 +351,7 @@
* 3774 FIX: apc_symmetra: fixed wrong status and values handling
* 3761 FIX: windows_tasks: Fixed possible exception in discovery in case of unexpected agent data
* 3762 FIX: local: Fixed long output handling with Microcore...
+ * 3765 FIX: oracle_asm_diskgroup: Made check more robust against invalid data received from agent...
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/oracle_asm_diskgroup b/checks/oracle_asm_diskgroup
index c2516ab..3a74d31 100644
--- a/checks/oracle_asm_diskgroup
+++ b/checks/oracle_asm_diskgroup
@@ -41,10 +41,10 @@ factory_settings["asm_diskgroup_default_levels"] = {
}
def inventory_oracle_asm_diskgroup(info):
- return [ (line[-1].rstrip("/"), {}) for line in info ]
+ return [ (line[-1].rstrip("/"), {}) for line in info
+ if len(line) in [ 12, 13 ] and line[0] in [ "MOUNTED", "DISMOUNTED" ] ]
def check_oracle_asm_diskgroup(item, params, info):
-
for line in info:
voting_files = 'N'
@@ -57,7 +57,10 @@ def check_oracle_asm_diskgroup(item, params, info):
free_mb, req_mir_free_mb, usable_file_mb, offline_disks, \
name = line
else:
- name = ""
+ continue # Invalid data, skip this line
+
+ if state not in [ "MOUNTED", "DISMOUNTED" ]:
+ continue # Invalid data, skip this line
dg_name = name.rstrip('/')
Module: check_mk
Branch: master
Commit: e9fde3be951de115c858f125f355f39dddbc2ae1
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e9fde3be951de1…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Aug 25 09:59:04 2016 +0200
3780 availability: now limit of fetched logfile rows is configurable.
---
.werks/3780 | 9 ++++++++
ChangeLog | 1 +
web/htdocs/availability.py | 44 ++++++++++++++++++++++++++++++++-----
web/plugins/views/availability.py | 17 +++++++++++---
4 files changed, 62 insertions(+), 9 deletions(-)
diff --git a/.werks/3780 b/.werks/3780
new file mode 100644
index 0000000..ef79d9e
--- /dev/null
+++ b/.werks/3780
@@ -0,0 +1,9 @@
+Title: availability: now limit of fetched logfile rows is configurable.
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.4.0i1
+Date: 1472111747
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index bc606c0..6df1a19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -371,6 +371,7 @@
* 3141 added user interfaces and permissions to view and acknowledge failed notifications
* 3640 new filter option for status details: can now be negated
* 3713 new filter: hosts with certain service problems
+ * 3780 availability: now limit of fetched logfile rows is configurable.
* 3059 FIX: Fixed highlighting of availability timeline time slices
* 3175 FIX: Fix timeranges of graphs that are embedded in a dashboard...
* 3076 FIX: fixed broken views in check_mk raw edition
diff --git a/web/htdocs/availability.py b/web/htdocs/availability.py
index be04b12..cdfc2ee 100644
--- a/web/htdocs/availability.py
+++ b/web/htdocs/availability.py
@@ -475,7 +475,6 @@ def get_avoption_entries(what):
label = _("Show timeline of each object directly in table")),
),
- # Timelimit
( "timelimit",
"single",
False,
@@ -486,7 +485,18 @@ def get_avoption_entries(what):
unit = _("sec"),
default_value = 30,
),
- )
+ ),
+
+ ( "logrow_limit",
+ "single",
+ True,
+ Integer(
+ title = _("Log row limit"),
+ help = _("Limit the fetched rows of logfile in order to avoid "
+ "a hanging system. A value of zero means no limit."),
+ default_value = 5000,
+ ),
+ ),
]
def get_default_avoptions():
@@ -508,6 +518,7 @@ def get_default_avoptions():
"summary" : "sum",
"show_timeline" : False,
"timelimit" : 30,
+ "logrow_limit" : 5000,
"downtimes" : {
"include" : "honor",
@@ -581,8 +592,11 @@ def get_availability_rawdata(what, filterheaders, only_sites, av_object, include
else:
av_filter += "Filter: service_description =\n"
- query = "GET statehist\n" + av_filter
+ query = "GET statehist\n" + av_filter
query += "Timelimit: %d\n" % avoptions["timelimit"]
+ logrow_limit = avoptions["logrow_limit"]
+ if logrow_limit:
+ query += "Limit: %d\n" % (logrow_limit + 1)
# Add Columns needed for object identification
columns = [ "host_name", "service_description" ]
@@ -612,11 +626,20 @@ def get_availability_rawdata(what, filterheaders, only_sites, av_object, include
sites.live().set_prepend_site(False)
columns = ["site"] + columns
spans = [ dict(zip(columns, span)) for span in data ]
- return spans_by_object(spans)
+
+ # Now we find out if the log row limit was exceeded or
+ # if the log's length is the limit by accident.
+ # If this limit was exceeded then we cut off the last element
+ # in spans_by_object because it might be incomplete.
+ logrow_limit_reached_entry = None
+ if logrow_limit and len(data) >= logrow_limit + 1:
+ logrow_limit_reached_entry = dict(zip(columns, data[-1]))
+
+ return spans_by_object(spans, logrow_limit_reached_entry)
# Sort the raw spans into a tree of dicts, so that we
# have easy access to the timeline of each object
-def spans_by_object(spans):
+def spans_by_object(spans, logrow_limit_reached_entry):
# Sort by site/host and service, while keeping native order
av_rawdata = {}
for span in spans:
@@ -624,7 +647,16 @@ def spans_by_object(spans):
service = span["service_description"]
av_rawdata.setdefault(site_host, {})
av_rawdata[site_host].setdefault(service, []).append(span)
- return av_rawdata
+
+ if logrow_limit_reached_entry:
+ site_host = (logrow_limit_reached_entry["site"], logrow_limit_reached_entry["host_name"])
+ if logrow_limit_reached_entry["service_description"]:
+ del av_rawdata[site_host][logrow_limit_reached_entry["service_description"]]
+ else:
+ del av_rawdata[site_host]
+
+ # We have to remember if rawdata was modified
+ return av_rawdata, logrow_limit_reached_entry != None
# Compute an availability table. what is one of "bi", "host", "service".
diff --git a/web/plugins/views/availability.py b/web/plugins/views/availability.py
index b990f86..317d50a 100644
--- a/web/plugins/views/availability.py
+++ b/web/plugins/views/availability.py
@@ -136,6 +136,7 @@ def render_availability_options(what):
# is (currently) called by views.py, when showing a view but
# availability mode is activated.
def render_availability_page(view, datasource, filterheaders, only_sites, limit):
+
if handle_edit_annotations():
return
@@ -187,8 +188,9 @@ def render_availability_page(view, datasource, filterheaders, only_sites, limit)
# Now compute all data, we need this also for CSV export
if not html.has_user_errors():
- av_rawdata = availability.get_availability_rawdata(what, filterheaders, only_sites,
- av_object, av_mode == "timeline", avoptions)
+ av_rawdata, has_reached_logrow_limit = \
+ availability.get_availability_rawdata(what, filterheaders, only_sites,
+ av_object, av_mode == "timeline", avoptions)
av_data = availability.compute_availability(what, av_rawdata, avoptions)
# Do CSV ouput
@@ -206,7 +208,6 @@ def render_availability_page(view, datasource, filterheaders, only_sites, limit)
html.write(confirmation_html_code)
-
# Remove variables for editing annotations, otherwise they will make it into the uris
html.del_all_vars("editanno_")
html.del_all_vars("anno_")
@@ -237,6 +238,16 @@ def render_availability_page(view, datasource, filterheaders, only_sites, limit)
avoptions = render_availability_options(what)
if not html.has_user_errors():
+ # If we abolish the limit we have to fetch the data again
+ # with changed logrow_limit = 0, which means no limit
+ if has_reached_logrow_limit:
+ text = _("Your query matched more than %d log entries. "
+ "<b>Note:</b> The number of shown rows does not necessarily reflect the "
+ "matched entries and the result might be incomplete. ") % avoptions["logrow_limit"]
+ text += '<a href="%s">%s</a>' % \
+ (html.makeuri([("avo_logrow_limit", 0)]), _('Repeat query without limit.'))
+ html.show_warning(text)
+
do_render_availability(what, av_rawdata, av_data, av_mode, av_object, avoptions)
if DisplayOptions.enabled(DisplayOptions.Z):