Module: check_mk
Branch: master
Commit: 2b3b5bfa00f50d57ef517bdd34c87f05a36fce3b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2b3b5bfa00f50d…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Jun 4 17:59:14 2014 +0200
New button for updating DNS cache
In the host details page in WATO there is now a new button <i>Update DNS
Cache</i>. If you
press this button, then all cached IP addresses of hosts on the same site as the host
currently
edited are being updated.
Use this button when you have not specified an explicit address for a host and that
host's
IP address has been changed in your DNS (and you are not willing to wait for the next
regular update).
---
.werks/987 | 14 ++++++++++++++
ChangeLog | 1 +
modules/automation.py | 7 +++++++
modules/check_mk.py | 8 +++++++-
web/htdocs/images/icon_update.png | Bin 0 -> 4229 bytes
web/htdocs/wato.py | 20 ++++++++++++++++++++
6 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/.werks/987 b/.werks/987
new file mode 100644
index 0000000..1151540
--- /dev/null
+++ b/.werks/987
@@ -0,0 +1,14 @@
+Title: New button for updating DNS cache
+Level: 2
+Component: wato
+Version: 1.2.5i4
+Date: 1401897453
+Class: feature
+
+In the host details page in WATO there is now a new button <i>Update DNS
Cache</i>. If you
+press this button, then all cached IP addresses of hosts on the same site as the host
currently
+edited are being updated.
+
+Use this button when you have not specified an explicit address for a host and that
host's
+IP address has been changed in your DNS (and you are not willing to wait for the next
+regular update).
diff --git a/ChangeLog b/ChangeLog
index b836162..70642b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@
* 0934 FIX: Logwatch messages with class unknown ( 'u' ) now displayed as
WARN...
WATO:
+ * 0987 New button for updating DNS cache...
* 0813 FIX: LDAP: Improved slightly missleading logging of LDAP sync actions...
Reporting & Availability:
diff --git a/modules/automation.py b/modules/automation.py
index baa99cc..e0eca6c 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -43,6 +43,9 @@ def do_automation(cmd, args):
result = automation_delete_host(args)
elif cmd == "notification-get-bulks":
result = automation_get_bulks(args)
+ elif cmd == "update-dns-cache":
+ read_config_files(with_autochecks=False)
+ result = automation_update_dns_cache()
else:
read_config_files()
if cmd == "try-inventory":
@@ -1379,3 +1382,7 @@ def execute_check_plugin(commandline):
raise
return 3, "UNKNOWN - Cannot execute command: %s" % e
+
+def automation_update_dns_cache():
+ return do_update_dns_cache()
+
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 796c34b..5380079 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1287,6 +1287,8 @@ def do_update_dns_cache():
# Temporarily disable *use* of cache, we want to force an update
global use_dns_cache
use_dns_cache = False
+ updated = 0
+ failed = []
if opt_verbose:
print "Updating DNS cache..."
@@ -1298,14 +1300,18 @@ def do_update_dns_cache():
# with statically configured addresses, etc.
try:
ip = lookup_ipaddress(hostname)
- sys.stdout.write("%s\n" % ip)
+ if opt_verbose:
+ sys.stdout.write("%s\n" % ip)
+ updated += 1
except Exception, e:
+ failed.append(hostname)
if opt_verbose:
sys.stdout.write("lookup failed: %s\n" % e)
if opt_debug:
raise
continue
+ return updated, failed
def agent_port_of(hostname):
ports = host_extra_conf(hostname, agent_ports)
diff --git a/web/htdocs/images/icon_update.png b/web/htdocs/images/icon_update.png
new file mode 100644
index 0000000..248f614
Binary files /dev/null and b/web/htdocs/images/icon_update.png differ
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 97a8e1c..04ec06d 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2047,8 +2047,22 @@ def mode_edithost(phase, new, cluster):
if not cluster:
html.context_button(_("Diagnostic"),
make_link([("mode", "diag_host"),
("host", hostname)]), "diagnose")
+ html.context_button(_("Update DNS Cache"),
+ html.makeactionuri([("_update_dns_cache",
"1")]), "update")
elif phase == "action":
+ if html.var("_update_dns_cache"):
+ if html.check_transaction():
+ config.need_permission("wato.update_dns_cache")
+ num_updated, failed_hosts =
check_mk_automation(host[".siteid"], "update-dns-cache", [])
+ infotext = _("Successfully updated IP addresses of %d hosts.")
% num_updated
+ if failed_hosts:
+ infotext += "<br><br><b>Hostnames failed to
lookup:</b> " + ", ".join(["<tt>%s</tt>" % h
for h in failed_hosts])
+ return None, infotext
+ else:
+ return None
+
+
if not new and html.var("delete"): # Delete this host
config.need_permission("wato.manage_hosts")
check_folder_permissions(g_folder, "write")
@@ -17434,6 +17448,12 @@ def load_plugins():
"hosts and thus simulate larger environments."),
[ ])
+ config.declare_permission("wato.update_dns_cache",
+ _("Update DNS Cache"),
+ _("Updating the DNS cache is neccessary in order to reflect IP address
"
+ "changes in hosts that are configured without an explicit
address."),
+ [ "admin", "user" ])
+
config.declare_permission("wato.services",
_("Manage services"),
_("Do inventory and service configuration on existing hosts."),