Module: check_mk
Branch: master
Commit: 18f7beeb5d748b1ab92fd3bda1aac0fa30f9549b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=18f7beeb5d748b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Sep 12 10:33:45 2016 +0200
Updated comment
---
modules/automation.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/modules/automation.py b/modules/automation.py
index 167dac1..4d82ce3 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -385,8 +385,10 @@ def automation_delete_hosts(args):
def delete_host_files(hostname):
- # the inventory_archive as well as the performance data is kept
- # we do not want to loose any historic data for accidently deleted hosts
+ # The inventory_archive as well as the performance data is kept
+ # we do not want to loose any historic data for accidently deleted hosts.
+ #
+ # These files are cleaned up by the disk space mechanism.
# single files
for path in [
Module: check_mk
Branch: master
Commit: 5fb72d185f8a68c8a87e8bc4130b17f7b9c54abc
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5fb72d185f8a68…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Sep 12 10:31:39 2016 +0200
3852 FIX Host related files are now deleted during host deletion
Some host related files (caches, precompiled checks, counters, ...)
were not deleted when removing a host via WATO. This has now been
fixed. These files are removed once a host is deleted:
<ul>
<li>precompiled host checks (nagios)</li>
<li>discovered services</li>
<li>counters</li>
<li>agent / SNMP caches</li>
<li>persisted sections</li>
<li>piggyback data</li>
<li>HW/SW inventory caches</li>
<li>baked agents</li>
<li>logwatch files</li>
</ul>
The HW/SW inventory archive and performance data (RRDs) are not
cleaned up by this mechanism. To clean these files up, use the
disk space cleanup mechanism (see global settings).
---
.werks/3852 | 27 +++++++++++++++++++++++++++
ChangeLog | 1 +
modules/automation.py | 11 +++++++----
web/htdocs/wato.py | 12 ------------
web/htdocs/watolib.py | 17 ++++++++++++++++-
5 files changed, 51 insertions(+), 17 deletions(-)
diff --git a/.werks/3852 b/.werks/3852
new file mode 100644
index 0000000..1eac2dd
--- /dev/null
+++ b/.werks/3852
@@ -0,0 +1,27 @@
+Title: Host related files are now deleted during host deletion
+Level: 1
+Component: core
+Compatible: compat
+Version: 1.4.0i1
+Date: 1473668830
+Class: fix
+
+Some host related files (caches, precompiled checks, counters, ...)
+were not deleted when removing a host via WATO. This has now been
+fixed. These files are removed once a host is deleted:
+
+<ul>
+<li>precompiled host checks (nagios)</li>
+<li>discovered services</li>
+<li>counters</li>
+<li>agent / SNMP caches</li>
+<li>persisted sections</li>
+<li>piggyback data</li>
+<li>HW/SW inventory caches</li>
+<li>baked agents</li>
+<li>logwatch files</li>
+</ul>
+
+The HW/SW inventory archive and performance data (RRDs) are not
+cleaned up by this mechanism. To clean these files up, use the
+disk space cleanup mechanism (see global settings).
diff --git a/ChangeLog b/ChangeLog
index aa81cbc..d7fc3c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,7 @@
* 3149 FIX: fixed rare crash if alert handling tried to long non-latin characters
* 3843 FIX: Fixed reporting of crashes when using Nagios core
* 3846 FIX: Nagios: define_contactgroups = False is handled correctly again
+ * 3852 FIX: Host related files are now deleted during host deletion...
Checks & Agents:
* 3183 aruba_wlc_aps: new check which monitors the provisioned accesspoints of an Aruba Network WLAN Controller
diff --git a/modules/automation.py b/modules/automation.py
index 92d932f..167dac1 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -102,8 +102,8 @@ def do_automation(cmd, args):
result = automation_scan_parents(args)
elif cmd == "diag-host":
result = automation_diag_host(args)
- elif cmd == "delete-host":
- result = automation_delete_host(args)
+ elif cmd == "delete-hosts":
+ result = automation_delete_hosts(args)
elif cmd == "rename-hosts":
result = automation_rename_hosts()
elif cmd == "notification-replay":
@@ -379,9 +379,12 @@ def automation_analyse_service(args):
# TODO: Klappt das mit automatischen verschatten von SNMP-Checks (bei dual Monitoring)
-def automation_delete_host(args):
- hostname = args[0]
+def automation_delete_hosts(args):
+ for hostname in args:
+ delete_host_files(hostname)
+
+def delete_host_files(hostname):
# the inventory_archive as well as the performance data is kept
# we do not want to loose any historic data for accidently deleted hosts
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index a9fc9f5..eb150a7 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -868,18 +868,6 @@ def show_host_actions(host):
html.icon_button(delete_url, _("Delete this host"), "delete")
-def delete_host_files(site_id, hostname):
- # TODO: See bug #2414
- check_mk_automation(site_id, "delete-host", [hostname])
- if not config.site_is_local(site_id):
- # Delete inventory data received from remote sites (not the archive)
- for filename in [ "%s/inventory/%s" % (defaults.var_dir, hostname),
- "%s/inventory/%s.gz" % (defaults.var_dir, hostname) ]:
- if os.path.exists(filename):
- os.unlink(filename)
- log_pending(AFFECTED, hostname, "delete-host", _("Deleted host %s") % hostname)
-
-
def delete_host_after_confirm(delname):
c = wato_confirm(_("Confirm host deletion"),
_("Do you really want to delete the host <tt>%s</tt>?") % delname)
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 8ee75ad..e3ed65c 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -1604,17 +1604,32 @@ class Folder(BaseFolder):
self.need_unlocked_hosts()
self.need_permission("write")
- # 2. Actual modification
+ # 2. Delete host specific files (caches, tempfiles, ...)
+ self._delete_host_files(host_names)
+
+ # 3. Actual modification
for host_name in host_names:
host = self.hosts()[host_name]
host.mark_dirty()
del self._hosts[host_name]
self._num_hosts = len(self._hosts)
log_pending(AFFECTED, host, "delete-host", _("Deleted host %s") % host_name)
+
self._save_wato_info() # num_hosts has changed
self.save_hosts()
+ # Group the given host names by their site and delete their files
+ def _delete_host_files(self, host_names):
+ hosts_by_site = {}
+ for host_name in host_names:
+ host = self.hosts()[host_name]
+ hosts_by_site.setdefault(host.site_id(), []).append(host_name)
+
+ for site_id, site_host_names in hosts_by_site.items():
+ check_mk_automation(site_id, "delete-hosts", site_host_names)
+
+
def move_hosts(self, host_names, target_folder):
# 1. Check preconditions
config.need_permission("wato.manage_hosts")
Module: check_mk
Branch: master
Commit: c2e25048cf8b82430254b9d29576dbbf79b890cb
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c2e25048cf8b82…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Sep 12 12:28:33 2016 +0200
3853 cmk --list-tag can now also list offline hosts
---
.werks/3853 | 9 +++++++++
ChangeLog | 1 +
modules/check_mk.py | 33 ++++++++++++++++++++++++++++-----
3 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/.werks/3853 b/.werks/3853
new file mode 100644
index 0000000..8229052
--- /dev/null
+++ b/.werks/3853
@@ -0,0 +1,9 @@
+Title: cmk --list-tag can now also list offline hosts
+Level: 1
+Component: core
+Compatible: compat
+Version: 1.4.0i1
+Date: 1473676104
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index d7fc3c7..4acacf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
* 3580 The macro $HOSTNAME$ is now available for host checks which are based on service states
* 3155 implemented dual monitoring for systems with management boards (like HP iLO)
* 3721 Host macros are now replaced in datasource program command lines...
+ * 3853 cmk --list-tag can now also list offline hosts
* 3193 FIX: Fixed fake check results for hosts...
* 3214 FIX: Removing SNMP checks for non SNMP hosts and agent based checks for non agent hosts...
* 3220 FIX: Check_MK HW/SW Inventory is now always disabled for "No Agent" hosts
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 48ee864..00c5f18 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -642,6 +642,20 @@ def all_configured_hosts():
def all_active_hosts():
return all_active_realhosts() + all_active_clusters()
+# Returns a list of all hosts which are associated with this site,
+# but have been removed by the "only_hosts" rule. Normally these
+# are the hosts which have the tag "offline".
+#
+# This is not optimized for performance, so use in specific situations.
+def all_offline_hosts():
+ hostlist = filter_active_hosts(all_configured_realhosts()
+ + all_configured_clusters(),
+ keep_offline_hosts=True)
+
+ return [ hostname for hostname in hostlist
+ if not in_binary_hostlist(hostname, only_hosts) ]
+
+
def duplicate_hosts():
# Sanity check for duplicate hostnames
seen_hostnames = set([])
@@ -672,19 +686,22 @@ def all_active_clusters():
all_clusters_untagged = filter_active_hosts(all_configured_clusters())
return all_clusters_untagged
-def filter_active_hosts(hostlist):
+def filter_active_hosts(hostlist, keep_offline_hosts=False):
if only_hosts == None and distributed_wato_site == None:
return hostlist
elif only_hosts == None:
return [ hostname for hostname in hostlist
if host_is_member_of_site(hostname, distributed_wato_site) ]
elif distributed_wato_site == None:
- return [ hostname for hostname in hostlist
- if in_binary_hostlist(hostname, only_hosts) ]
+ if keep_offline_hosts:
+ return hostlist
+ else:
+ return [ hostname for hostname in hostlist
+ if in_binary_hostlist(hostname, only_hosts) ]
else:
site_tag = "site:" + distributed_wato_site
return [ hostname for hostname in hostlist
- if in_binary_hostlist(hostname, only_hosts)
+ if (keep_offline_hosts or in_binary_hostlist(hostname, only_hosts))
and host_is_member_of_site(hostname, distributed_wato_site) ]
def host_is_member_of_site(hostname, site):
@@ -3664,7 +3681,13 @@ def list_all_hosts(hostgroups):
# Same for host tags, needed for --list-tag
def list_all_hosts_with_tags(tags):
hosts = []
- for h in all_active_hosts():
+
+ if "offline" in tags:
+ hostlist = all_offline_hosts()
+ else:
+ hostlist = all_active_hosts()
+
+ for h in hostlist:
if hosttags_match_taglist(tags_of_host(h), tags):
hosts.append(h)
return hosts
Module: check_mk
Branch: master
Commit: f7bd3cdaaa7c973fcf28607288cc7fbd4bd687cf
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f7bd3cdaaa7c97…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Sep 9 16:31:21 2016 +0200
Fixed non working bulk discovery and other bulk actions
---
web/htdocs/htmllib.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index c911e1a..5a7e597 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -1816,9 +1816,9 @@ class html(object):
return self.current_transid
- # All generated transids are saved per user. They are stored
- # in the transids and per user only up to 20 transids are kept.
- # Transaction ids older than one day are deleted.
+ # All generated transids are saved per user. They are stored in the transids.mk.
+ # Per user only up to 20 transids of the already existing ones are kept. The transids
+ # generated on the current page are all kept. IDs older than one day are deleted.
def store_new_transids(self):
if self.new_transids:
valid_ids = self.load_transids(lock = True)
@@ -1828,7 +1828,7 @@ class html(object):
timestamp, rand = valid_id.split("/")
if now - int(timestamp) < 86400: # one day
cleared_ids.append(valid_id)
- self.save_transids((cleared_ids + self.new_transids)[-20:], unlock = True)
+ self.save_transids((cleared_ids[-20:] + self.new_transids), unlock = True)
# Remove the used transid from the list of valid ones
Module: check_mk
Branch: master
Commit: d1b019cbc8c67fccf50b24289a28ef3a8ab90975
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d1b019cbc8c67f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Sep 9 15:57:10 2016 +0200
3851 Host edit dialog: Checkbox hosttags are now checked by default
In most cases you want to have the checkbox ticked by default when
setting a host tag group explicit for a host.
---
.werks/3851 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/watolib.py | 4 ++--
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/.werks/3851 b/.werks/3851
new file mode 100644
index 0000000..d7bdea5
--- /dev/null
+++ b/.werks/3851
@@ -0,0 +1,10 @@
+Title: Host edit dialog: Checkbox hosttags are now checked by default
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.4.0i1
+Date: 1473429363
+Class: feature
+
+In most cases you want to have the checkbox ticked by default when
+setting a host tag group explicit for a host.
diff --git a/ChangeLog b/ChangeLog
index 4f63b5a..016a544 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -511,6 +511,7 @@
* 3785 WATO rulesets: now able to set a negate option for services and items...
* 3786 WATO webapi: now able to bake agents with the new action bake_agents
* 3792 check_http: now able to configure HTTP method PROPFIND
+ * 3851 Host edit dialog: Checkbox hosttags are now checked by default...
* 3060 FIX: Folder properties: Fixed exception when a user has no alias set...
* 3062 FIX: Git integration: Fixed not adding files in WATO folders to git control
* 3203 FIX: Distributed WATO: Fixed exception in remote host service discovery...
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index d79c9c0..8ee75ad 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -2551,7 +2551,7 @@ class HostTagAttribute(Attribute):
tag_id, title, self._taglist = tag_definition
name = "tag_" + tag_id
if len(self._taglist) == 1:
- def_value = None
+ def_value = True
else:
def_value = self._taglist[0][0]
Attribute.__init__(self, name, title, "", def_value)
@@ -2578,7 +2578,7 @@ class HostTagAttribute(Attribute):
def render_input(self, varprefix, value):
varname = varprefix + "attr_" + self.name()
if value == None:
- value = html.var(varname,"") # "" is important for tag groups with an empty tag entry
+ value = html.var(varname, "") # "" is important for tag groups with an empty tag entry
# Tag groups with just one entry are being displayed
# as checkboxes