Module: check_mk
Branch: master
Commit: 86a8123ae52bff6491e18aee3b2d6b7b23e9e7f2
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=86a8123ae52bff…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Sep 18 12:36:08 2013 +0200
Implement DNS caching. This can be disabled with use_dns_cache = False
---
ChangeLog | 1 +
modules/check_mk.py | 48 +++++++++++++++++++++++-----
web/plugins/wato/check_mk_configuration.py | 18 +++++++++++
3 files changed, 59 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8176726..d8b89fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@
* Preparations for significant SNMP monitoring performance improvement
(It's named Inline SNMP, which is available as special feature via subscriptions)
* Allow to specify custom host check via WATO (arbitrary command line)
+ * Implement DNS caching. This can be disabled with use_dns_cache = False
Livestatus:
* new service column staleness: indicator for outdated service checks
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 1246046..7267c4e 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -211,6 +211,7 @@ agent_port = 6556
agent_ports = []
snmp_ports = [] # UDP ports used for SNMP
tcp_connect_timeout = 5.0
+use_dns_cache = True # prevent DNS by using own cache file
delay_precompile = False # delay Python compilation to Nagios execution
restart_locking = "abort" # also possible: "wait", None
check_submission = "file" # alternative: "pipe"
@@ -1153,25 +1154,38 @@ def lookup_ipaddress(hostname):
if hostname in g_dns_cache:
return g_dns_cache[hostname]
+ # Prepare file based fall-back DNS cache in case resolution fails
init_ip_lookup_cache()
+ cached_ip = g_ip_lookup_cache.get(hostname)
+ if cached_ip and use_dns_cache:
+ g_dns_cache[hostname] = cached_ip
+ return cached_ip
+
# Now do the actual DNS lookup
try:
ipa = socket.gethostbyname(hostname)
- # Cache the result (persistant) when resolving succeeded
- if ipa != g_ip_lookup_cache.get(hostname):
+ # Update our cached address if that has changed or was missing
+ if ipa != cached_ip:
+ if opt_verbose:
+ print "Updating DNS cache for %s: %s" % (hostname, ipa)
g_ip_lookup_cache[hostname] = ipa
write_ip_lookup_cache()
+
+ g_dns_cache[hostname] = ipa # Update in-memory-cache
+ return ipa
+
except:
- # Initialize the lookup cache when called for the first time
- if hostname in g_ip_lookup_cache:
- ipa = g_ip_lookup_cache[hostname]
+ # DNS failed. Use cached IP address if present, even if caching
+ # is disabled.
+ if cached_ip:
+ g_dns_cache[hostname] = cached_ip
+ return cached_ip
else:
g_dns_cache[hostname] = None
raise
- g_dns_cache[hostname] = ipa
- return ipa
+
def init_ip_lookup_cache():
global g_ip_lookup_cache
@@ -1184,6 +1198,20 @@ def init_ip_lookup_cache():
def write_ip_lookup_cache():
file(var_dir + '/ipaddresses.cache', 'w').write(repr(g_ip_lookup_cache))
+def do_update_dns_cache():
+ # Temporarily disable *use* of cache, we want to force an update
+ global use_dns_cache
+ use_dns_cache = False
+
+ if opt_verbose:
+ print "Updating DNS cache..."
+ for hostname in all_active_hosts() + all_active_clusters():
+ # Use intelligent logic. This prevents DNS lookups for hosts
+ # with statically configured addresses, etc.
+ lookup_ipaddress(hostname)
+
+
+
def agent_port_of(hostname):
ports = host_extra_conf(hostname, agent_ports)
if len(ports) == 0:
@@ -4305,6 +4333,7 @@ def usage():
cmk -D, --dump [H1 H2 ..] dump all or some hosts
cmk -d HOSTNAME|IPADDRESS show raw information from agent
cmk --check-inventory HOSTNAME check for items not yet checked
+ cmk --update-dns-cache update IP address lookup cache
cmk --list-hosts [G1 G2 ...] print list of hosts
cmk --list-tag TAG1 TAG2 ... list hosts having certain tags
cmk -L, --list-checks list all available check types
@@ -5270,7 +5299,7 @@ if __name__ == "__main__":
"no-cache", "update", "restart", "reload", "dump", "fake-dns=",
"man", "nowiki", "config-check", "backup=", "restore=",
"check-inventory=", "paths", "cleanup-autochecks", "checks=",
- "cmc-file=", "browse-man", "list-man" ]
+ "cmc-file=", "browse-man", "list-man", "update-dns-cache" ]
non_config_options = ['-L', '--list-checks', '-P', '--package', '-M', '--notify',
'--man', '-V', '--version' ,'-h', '--help', '--automation']
@@ -5390,6 +5419,9 @@ if __name__ == "__main__":
elif o == '--donate':
do_donation()
done = True
+ elif o == '--update-dns-cache':
+ do_update_dns_cache()
+ done = True
elif o == '--snmpwalk':
do_snmpwalk(args)
done = True
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index 68d5706..ec25642 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -950,6 +950,24 @@ register_configvar(group,
need_restart = True)
register_configvar(group,
+ "use_dns_cache",
+ Checkbox(
+ title = _("Use DNS lookup cache"),
+ label = _("Prevent DNS lookups by use of a cache file"),
+ help = _("When this option is enabled (which is the default), then Check_MK tries to "
+ "prevent IP address lookups during the configuration generation. This can speed "
+ "up this process greatly when you have a larger number of hosts. The cache is stored "
+ "in a simple file. Note: when the cache is enabled then changes of the IP address "
+ "of a host in your name server will not be detected immediately. If you need an "
+ "immediate update then simply disable the cache once, activate the changes and "
+ "enabled it again. OMD based installations automatically update the cache once "
+ "a day."),
+ default_value = True,
+ ),
+ need_restart = True
+)
+
+register_configvar(group,
"use_inline_snmp",
Checkbox(
title = _("Use Inline SNMP (EXPERIMENTAL)"),
Module: check_mk
Branch: master
Commit: a0f74fe9c4c647012d4298bb8192330565ab9fcf
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a0f74fe9c4c647…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Sep 18 10:05:46 2013 +0200
OMG! Found a way to make F5 / browser reloads work as expected
This works at least in current firefox, chrome, safari. Cross fingers,
maybe this also works in current IE versions... Have not tested this
yet.
---
ChangeLog | 2 ++
web/htdocs/js/sidebar.js | 43 ++++++++++++++++++++++++++++++++++++++-----
web/htdocs/sidebar.py | 3 ++-
3 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a2b71c0..895d1c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -108,6 +108,8 @@
* HTML notifications: Added time of state change
Multisite:
+ * Finally good handling of F5 / browser reloads -> no page switching to
+ start page anymore (at least in modern browsers)
* User accounts can now be locked after a specified amount of auth
failures (lock_on_logon_failures can be set to a number of tries)
* Column Perf-O-Meter is now sortable: it sorts after the *first*
diff --git a/web/htdocs/js/sidebar.js b/web/htdocs/js/sidebar.js
index 5385dac..5de212b 100644
--- a/web/htdocs/js/sidebar.js
+++ b/web/htdocs/js/sidebar.js
@@ -26,9 +26,8 @@ var browser = navigator.userAgent.toLowerCase();
var weAreIEF__k = ((browser.indexOf("msie") != -1) && (browser.indexOf("opera") == -1));
var weAreOpera = browser.indexOf("opera") != -1;
var weAreFirefox = browser.indexOf("firefox") != -1 || browser.indexOf("namoroka") != -1;
-var contentLocation = null;
-if(contentFrameAccessible())
- var contentLocation = parent.frames[1].document.location;
+var g_orig_title = null;
+var g_content_loc = null;
//
// Sidebar styling and scrolling stuff
@@ -360,6 +359,40 @@ function contentFrameAccessible() {
}
}
+function update_content_location() {
+ // init the original frameset title
+ if (g_orig_title == null)
+ g_orig_title = window.parent.document.title;
+
+ var content_frame = window.parent.frames[1];
+
+ // Change the title to add the right frame title to reflect the
+ // title of the content URL in the framesets title (window title or tab title)
+ if (content_frame.document.title != '') {
+ var page_title = g_orig_title + ' - ' + content_frame.document.title;
+ } else {
+ var page_title = g_orig_title;
+ }
+ window.parent.document.title = page_title;
+
+ // Construct the URL to be called on page reload
+ var parts = content_frame.location.pathname.split('/')
+ parts.pop();
+ var cmk_path = parts.join('/');
+ var rel_url = content_frame.location.pathname + content_frame.location.search + content_frame.location.hash
+ var index_url = cmk_path + '/index.py?start_url=' + rel_url
+
+ if (rel_url && rel_url != 'blank') {
+ // Update the URL to be called on reload, e.g. via F5, to make the
+ // frameset switch to exactly this URL
+ window.parent.history.replaceState({}, page_title, index_url);
+
+ // only update the internal flag var if the url was not blank and has been updated
+ //otherwise try again on next scheduler run
+ g_content_loc = parent.frames[1].document.location.href;
+ }
+}
+
function debug(s) {
window.parent.frames[1].document.write(s+'<br />');
}
@@ -662,9 +695,9 @@ function sidebar_scheduler() {
// Detect page changes and re-register the mousemove event handler
// in the content frame. another bad hack ... narf
- if (contentFrameAccessible() && contentLocation != parent.frames[1].document.location) {
+ if(contentFrameAccessible() && g_content_loc != parent.frames[1].document.location.href) {
registerEdgeListeners(parent.frames[1]);
- contentLocation = parent.frames[1].document.location;
+ update_content_location();
}
setTimeout(function(){sidebar_scheduler();}, 1000);
}
diff --git a/web/htdocs/sidebar.py b/web/htdocs/sidebar.py
index 129ef6c..e653ee1 100644
--- a/web/htdocs/sidebar.py
+++ b/web/htdocs/sidebar.py
@@ -219,7 +219,8 @@ def page_side():
html.write("refresh_snapins = %r;\n" % refresh_snapins)
html.write("restart_snapins = %r;\n" % restart_snapins)
html.write("sidebar_scheduler();\n")
- html.write("window.onresize = function() { setSidebarHeight(); }\n")
+ html.write("window.onresize = function() { setSidebarHeight(); };\n")
+ html.write("if (contentFrameAccessible()) { update_content_location(); };\n")
html.write("</script>\n")
html.write("</body>\n</html>")
Module: check_mk
Branch: master
Commit: 986eda7711a02b88312eb98933b2668af682f83b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=986eda7711a02b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Sep 17 18:18:04 2013 +0200
FIX: fix exception and loss of hosts in a folder when deleting all site connections
---
ChangeLog | 2 ++
web/htdocs/wato.py | 5 ++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index a2b71c0..89e985e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -378,6 +378,8 @@
* FIX: fix logwatch pattern analyzer message "The host xyz is not
managed by WATO." after direct access via snapin
* FIX: Fixed first toggle of flags in global settings when default is set to True
+ * FIX: fix exception and loss of hosts in a folder when deleting all site connections
+ of a distributed WATO setup
Event Console:
* FIX: apply rewriting of application/hostname also when cancelling events
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index cbbd96f..d3f409a 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7417,7 +7417,10 @@ def default_site():
if not "socket" in site \
or site["socket"] == "unix:" + defaults.livestatus_unix_socket:
return id
- return config.sites.keys()[0]
+ try:
+ return config.sites.keys()[0]
+ except:
+ return None
class SiteAttribute(Attribute):
def __init__(self):
Module: check_mk
Branch: master
Commit: 9073d52b23bf050a7875e0c488daf0705e317631
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9073d52b23bf05…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Sep 17 18:06:07 2013 +0200
Updated bug entries #0978
---
.bugs/978 | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/.bugs/978 b/.bugs/978
new file mode 100644
index 0000000..b64fe32
--- /dev/null
+++ b/.bugs/978
@@ -0,0 +1,9 @@
+Title: list index out of range when deleting last site
+Component: wato
+State: open
+Date: 2013-09-17 18:05:17
+Targetversion: 1.4.0
+Class: nastiness
+
+Configure two sites in the Distributed Monitoring setup. Then delete
+both sites. After you delete the last one you can a WATO exception.
Module: check_mk
Branch: master
Commit: 5d7053c5bc83d4b899166e004654bfcad2b453c3
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5d7053c5bc83d4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Sep 17 16:45:19 2013 +0200
Updated bug entries #1021
---
.bugs/1021 | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/.bugs/1021 b/.bugs/1021
new file mode 100644
index 0000000..43ccfc4
--- /dev/null
+++ b/.bugs/1021
@@ -0,0 +1,10 @@
+Title: Multisite title shows only site-name (should show site alias)
+Component: multisite
+State: open
+Date: 2013-09-17 16:39:20
+Targetversion: 1.4.0
+Class: nastiness
+
+It would be more user friendly if the title of the window / tab would show
+the alias of the site instead of the site-id. The normal user does not
+see the site-id in many situations. In most cases the site-alias is used.
Module: check_mk
Branch: master
Commit: f12d77fac6affef722c2685147a31c94639694ca
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f12d77fac6affe…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Sep 17 14:05:45 2013 +0200
Do not try to execute the ldap sync after enabling but without config
---
web/plugins/userdb/ldap.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 2ed66a3..d08d00b 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -838,6 +838,9 @@ def ldap_sync(add_to_changelog, only_username):
# requests to e.g. the page hook would cause duplicate calculations
file(g_ldap_sync_time_file, 'w').write('%s\n' % time.time())
+ if not config.ldap_connection:
+ return # silently skip sync without configuration
+
# Flush ldap related before each sync to have a caching only for the
# current sync process
global g_ldap_user_cache, g_ldap_group_cache