Module: check_mk
Branch: master
Commit: 9b022aa7b9a79f4981f4ed0700bebbcc406d1b32
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9b022aa7b9a79f…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Jan 20 13:23:24 2016 +0100
#2891 FIX mcafee_av_client: fixed wrong params handling after WATO configuration
---
.werks/2891 | 10 ++++++++++
ChangeLog | 1 +
checks/mcafee_av_client | 5 ++++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/.werks/2891 b/.werks/2891
new file mode 100644
index 0000000..d115a03
--- /dev/null
+++ b/.werks/2891
@@ -0,0 +1,10 @@
+Title: mcafee_av_client: fixed wrong params handling after WATO configuration
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i4
+Date: 1453292556
+
+
diff --git a/ChangeLog b/ChangeLog
index 173b09d..dfcfd73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -189,6 +189,7 @@
* 2899 FIX: ps: Finally improved performance impact of perfdata when having a lot of processes...
* 2917 FIX: cisco_asa_failover: Will no longer discover on devices where failover is disabled...
* 2927 FIX: Fix links to logwatch logfiles in case of several special characters in the name...
+ * 2891 FIX: mcafee_av_client: fixed wrong params handling after WATO configuration
Multisite:
* 2684 Added icons for downloading agent data / walks of hosts...
diff --git a/checks/mcafee_av_client b/checks/mcafee_av_client
index 32b3bb9..56bc3bb 100644
--- a/checks/mcafee_av_client
+++ b/checks/mcafee_av_client
@@ -44,7 +44,10 @@ def check_mcafee_av_client(_no_item, params, info):
# the Check_MK server. This might be a problem, if e.g. the agent is located
# in China and the Check_MK server in USA.
age = now - time.mktime(time.strptime(info[0][0], '%Y/%m/%d'))
- warn, crit = params['signature_age']
+ if type(params) == dict:
+ warn, crit = params['signature_age']
+ else:
+ warn, crit = params
if age >= crit:
state = 2
Module: check_mk
Branch: master
Commit: d12417a78e9622ba9044ceeb3cc6bc4b61ba4651
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d12417a78e9622…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jan 20 13:21:16 2016 +0100
Improved error handling for SNMP devices without system object OID
---
modules/discovery.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/modules/discovery.py b/modules/discovery.py
index eef62d5..cee7b52 100644
--- a/modules/discovery.py
+++ b/modules/discovery.py
@@ -636,10 +636,15 @@ def snmp_scan(hostname, ipaddress, on_error = "ignore", for_inv=False):
vverbose(" SNMP scan:\n")
if not in_binary_hostlist(hostname, snmp_without_sys_descr):
- sys_descr_oid = ".1.3.6.1.2.1.1.1.0"
- sys_descr = get_single_oid(hostname, ipaddress, sys_descr_oid)
- if sys_descr == None:
- raise MKSNMPError("Cannot fetch system description OID %s" % sys_descr_oid)
+ for oid, name in [ (".1.3.6.1.2.1.1.1.0", "system description"),
+ (".1.3.6.1.2.1.1.2.0", "system object") ]:
+ value = get_single_oid(hostname, ipaddress, oid)
+ if value == None:
+ raise MKSNMPError(
+ "Cannot fetch %s OID %s. This might be OK for some bogus devices. "
+ "In that case please configure the ruleset \"Hosts without system "
+ "description OID\" to tell Check_MK not to fetch the system "
+ "description and system object OIDs." % (name, oid))
else:
# Fake OID values to prevent issues with a lot of scan functions
vverbose(" Skipping system description OID "
Module: check_mk
Branch: master
Commit: 0529cd3aa582ea6a4bf18c1bad094b4f01d8e6fa
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0529cd3aa582ea…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jan 20 12:09:42 2016 +0100
#2904 FIX Improved error handling when custom url dashlets raise an exception
Fixed whole dashboards crashes when a "Custom URL dashlet" using a "Custom URL
rendering function" raise an exception while calling that function.
---
.werks/2904 | 10 +++++++
ChangeLog | 1 +
web/htdocs/dashboard.py | 53 +++++++++++++++++++++++--------------
web/plugins/dashboard/dashlets.py | 11 +++++++-
4 files changed, 54 insertions(+), 21 deletions(-)
diff --git a/.werks/2904 b/.werks/2904
new file mode 100644
index 0000000..a277077
--- /dev/null
+++ b/.werks/2904
@@ -0,0 +1,10 @@
+Title: Improved error handling when custom url dashlets raise an exception
+Level: 1
+Component: multisite
+Compatible: compat
+Version: 1.2.7i4
+Date: 1453287618
+Class: fix
+
+Fixed whole dashboards crashes when a "Custom URL dashlet" using a "Custom URL
+rendering function" raise an exception while calling that function.
diff --git a/ChangeLog b/ChangeLog
index 0a036c3..173b09d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -224,6 +224,7 @@
* 2896 FIX: Improved handling of wrong encoded input strings...
* 2822 FIX: Availabiltiy: Fixed exception while rendering the timeline...
* 2901 FIX: Fixed issue editing availability annotations...
+ * 2904 FIX: Improved error handling when custom url dashlets raise an exception...
WATO:
* 2442 WATO remove host: improved cleanup of obsolete host files...
diff --git a/web/htdocs/dashboard.py b/web/htdocs/dashboard.py
index 0fb4a8d..7d00b29 100644
--- a/web/htdocs/dashboard.py
+++ b/web/htdocs/dashboard.py
@@ -373,26 +373,7 @@ def render_dashboard(name):
# dashlets using the 'urlfunc' method will dynamically compute
# an url (using HTML context variables at their wish).
if "urlfunc" in dashlet:
- urlfunc = dashlet['urlfunc']
- # We need to support function pointers to be compatible to old dashboard plugin
- # based definitions. The new dashboards use strings to reference functions within
- # the global context or functions of a module. An example would be:
- #
- # urlfunc: "my_custom_url_rendering_function"
- #
- # or within a module:
- #
- # urlfunc: "my_module.render_my_url"
- if type(urlfunc) == type(lambda x: x):
- dashlet["url"] = urlfunc()
- else:
- if '.' in urlfunc:
- module_name, func_name = urlfunc.split('.', 1)
- module = __import__(module_name)
- fp = module.__dict__[func_name]
- else:
- fp = globals()[urlfunc]
- dashlet["url"] = fp()
+ gather_dashlet_url(dashlet)
dashlet_type = dashlet_types[dashlet['type']]
@@ -572,6 +553,38 @@ def render_dashlet_content(nr, the_dashlet, stash_html_vars=True):
if stash_html_vars:
html.unstash_vars()
+# Use the URL returned by urlfunc as dashlet URL
+#
+# We need to support function pointers to be compatible to old dashboard plugin
+# based definitions. The new dashboards use strings to reference functions within
+# the global context or functions of a module. An example would be:
+#
+# urlfunc: "my_custom_url_rendering_function"
+#
+# or within a module:
+#
+# urlfunc: "my_module.render_my_url"
+def gather_dashlet_url(dashlet):
+ try:
+ urlfunc = dashlet['urlfunc']
+ if type(urlfunc) == type(lambda x: x):
+ dashlet["url"] = urlfunc()
+ else:
+ if '.' in urlfunc:
+ module_name, func_name = urlfunc.split('.', 1)
+ module = __import__(module_name)
+ fp = module.__dict__[func_name]
+ else:
+ fp = globals()[urlfunc]
+ dashlet["url"] = fp()
+ except Exception, e:
+ # When an exception occurs the "url" key will be missing in the dashlet
+ # and an error is shown in the dashlet while rendering it. This is enough.
+ # For details the user can enable debugging.
+ if config.debug:
+ raise
+
+
# Create the HTML code for one dashlet. Each dashlet has an id "dashlet_%d",
# where %d is its index (in board["dashlets"]). Javascript uses that id
# for the resizing. Within that div there is an inner div containing the
diff --git a/web/plugins/dashboard/dashlets.py b/web/plugins/dashboard/dashlets.py
index 4b62454..a1e6a07 100644
--- a/web/plugins/dashboard/dashlets.py
+++ b/web/plugins/dashboard/dashlets.py
@@ -649,7 +649,16 @@ dashlet_types["view"] = {
def dashlet_url(dashlet):
if dashlet.get('show_in_iframe', True):
- return dashlet['url']
+ try:
+ return dashlet['url']
+ except KeyError:
+ if "urlfunc" in dashlet:
+ raise MKUserError(None,
+ _("You set the dashlet to use a dynamic URL rendering function. It seems "
+ "that this function call failed. You may want to open the dashboard "
+ "in debug mode to get more details."))
+ else:
+ raise
def dashlet_url_validate(value, varprefix):
if 'url' not in value and 'urlfunc' not in value:
Module: check_mk
Branch: master
Commit: d24890d35015dc5fd2c0a37c0fb111f8e2548009
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d24890d35015dc…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Jan 20 11:28:11 2016 +0100
Remove a few useless casts. Added TODOs about ownership/lifetime issues.
---
livestatus/src/HostServiceState.h | 8 ++++++--
livestatus/src/TableStateHistory.cc | 26 +++++++++++++++++---------
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/livestatus/src/HostServiceState.h b/livestatus/src/HostServiceState.h
index 562080f..3a57d4a 100644
--- a/livestatus/src/HostServiceState.h
+++ b/livestatus/src/HostServiceState.h
@@ -79,9 +79,13 @@ struct HostServiceState {
const char *_debug_info;
- // Pointer to dynamically allocated strings (strdup) that live here.
- // These pointers are 0, if there is no output (e.g. downtime)
+
+ // NOTE: _log_output is the *only* pointer in this class to an object we
+ // own, all other pointers are to foreign objects. This ownership is
+ // unfortunate and complicates things quite a lot, see the corresponding
+ // TODO in TableStateHistory::updateHostServiceState.
char *_log_output;
+
const char *_notification_period; // may be "": -> no period known, we assume "always"
const char *_service_period; // may be "": -> no period known, we assume "always"
host *_host;
diff --git a/livestatus/src/TableStateHistory.cc b/livestatus/src/TableStateHistory.cc
index cf72fe2..093030f 100644
--- a/livestatus/src/TableStateHistory.cc
+++ b/livestatus/src/TableStateHistory.cc
@@ -437,40 +437,40 @@ void TableStateHistory::answerQuery(Query *query)
// If this host/service is no longer availabe in nagios -> set to ""
if (state->_service != 0)
#ifdef CMC
- state->_notification_period = (char *)state->_service->notificationPeriod()->name();
+ state->_notification_period = state->_service->notificationPeriod()->name();
#else
state->_notification_period = state->_service->notification_period;
#endif
else if (state->_host != 0)
#ifdef CMC
- state->_notification_period = (char *)state->_host->notificationPeriod()->name();
+ state->_notification_period = state->_host->notificationPeriod()->name();
#else
state->_notification_period = state->_host->notification_period;
#endif
else
- state->_notification_period = (char *)"";
+ state->_notification_period = "";
// If for some reason the notification period is missing set a default
if (state->_notification_period == NULL) {
- state->_notification_period = (char *)"";
+ state->_notification_period = "";
}
// Same for service period. For Nagios this is a bit different, since this
// is no native field but just a custom variable
if (state->_service != 0)
#ifdef CMC
- state->_service_period = (char *)state->_service->servicePeriod()->name();
+ state->_service_period = state->_service->servicePeriod()->name();
#else
- state->_service_period = (char *)getCustomVariable(state->_service->custom_variables, "SERVICE_PERIOD");
+ state->_service_period = getCustomVariable(state->_service->custom_variables, "SERVICE_PERIOD");
#endif
else if (state->_host != 0)
#ifdef CMC
- state->_service_period = (char *)state->_host->servicePeriod()->name();
+ state->_service_period = state->_host->servicePeriod()->name();
#else
- state->_service_period = (char *)getCustomVariable(state->_host->custom_variables, "SERVICE_PERIOD");
+ state->_service_period = getCustomVariable(state->_host->custom_variables, "SERVICE_PERIOD");
#endif
else
- state->_service_period = (char *)"";
+ state->_service_period = "";
// Determine initial in_notification_period status
@@ -785,6 +785,14 @@ int TableStateHistory::updateHostServiceState(Query *query, const LogEntry *entr
hs_state->_log_output = 0;
else
+ // TODO: Do we really need to strdup? How are the lifetimes of entry
+ // and hs_state related? This is highly unclear. This strdup
+ // complicates things like hell, because HostServiceState owns
+ // _log_output because of it. If this is really needed (hopefully
+ // not), we should better change the type from a naked pointer to a
+ // unique_ptr, but this would mean introducing yet another Column
+ // subclass, because the Column framework is not flexible at all
+ // regarding the types it handles.
hs_state->_log_output = entry->_check_output ? strdup(entry->_check_output) : 0;
}