Module: check_mk
Branch: master
Commit: 5c7b839ce25e79c412fb79f96906f0b33f6134ed
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5c7b839ce25e79…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Nov 6 09:11:57 2017 +0100
5432 Network scan: The tag for the "criticality" host tag group can now be
configured
Before this change all new hosts found by the network scan were added as offline hosts
(Criticality: Do not monitor this host). It is now possible to configure this value
in the properties of the network scan.
Change-Id: I639e216b97d833fd79b4a83d8a47c6e1c85109bc
---
.werks/5432 | 12 ++++++++++++
web/htdocs/wato.py | 6 ++++--
web/htdocs/watolib.py | 7 +++++++
web/plugins/wato/builtin_attributes.py | 15 +++++++++++++++
4 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/.werks/5432 b/.werks/5432
new file mode 100644
index 0000000..b7c1503
--- /dev/null
+++ b/.werks/5432
@@ -0,0 +1,12 @@
+Title: Network scan: The tag for the "criticality" host tag group can now be
configured
+Level: 1
+Component: wato
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1509955833
+Class: feature
+
+Before this change all new hosts found by the network scan were added as offline hosts
+(Criticality: Do not monitor this host). It is now possible to configure this value
+in the properties of the network scan.
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index d9331d1..584eb8f 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -16496,7 +16496,9 @@ def find_folder_to_scan():
def add_scanned_hosts_to_folder(folder, found):
- translation =
folder.attribute("network_scan").get("translate_names", {})
+ network_scan_properties = folder.attribute("network_scan")
+
+ translation = network_scan_properties.get("translate_names", {})
entries = []
for host_name, ipaddress in found:
@@ -16504,7 +16506,7 @@ def add_scanned_hosts_to_folder(folder, found):
attrs = {
"ipaddress" : ipaddress,
- "tag_criticality" : "offline",
+ "tag_criticality" :
network_scan_properties.get("tag_criticality", "offline"),
}
if not watolib.Host.host_exists(host_name):
entries.append((host_name, attrs, None))
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index ce67a5b..94d59fe 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -6395,6 +6395,13 @@ class HosttagGroup(object):
return response
+ def get_tag_choices(self):
+ choices = []
+ for tag in self.tags:
+ choices.append((tag.id, tag.title))
+ return choices
+
+
class HosttagsConfiguration(object):
def __init__(self):
super(HosttagsConfiguration, self).__init__()
diff --git a/web/plugins/wato/builtin_attributes.py
b/web/plugins/wato/builtin_attributes.py
index abae99b..e7c1812 100644
--- a/web/plugins/wato/builtin_attributes.py
+++ b/web/plugins/wato/builtin_attributes.py
@@ -254,6 +254,13 @@ class NetworkScanAttribute(ValueSpecAttribute):
return [ (user_id, "%s (%s)" % (user_id,
user.get("alias", user_id)))
for user_id, user in userdb.load_users(lock = False).items() ]
+ def tag_criticality_choices():
+ tags = watolib.HosttagsConfiguration()
+ tags.load()
+
+ criticality = tags.get_tag_group("criticality")
+ return criticality.get_tag_choices()
+
ValueSpecAttribute.__init__(self, "network_scan",
Dictionary(
elements = [
@@ -278,6 +285,14 @@ class NetworkScanAttribute(ValueSpecAttribute):
help = _("Limit the execution of the scan to this time
range."),
allow_empty=False,
)),
+ ("tag_criticality", DropdownChoice(
+ title = _("Set criticality host tag"),
+ help = _("Added hosts will be created as
\"offline\" host by default. You "
+ "can change this option to activate monitoring of
new hosts after "
+ "next activation of the configuration after the
scan."),
+ choices = tag_criticality_choices,
+ default_value = "offline",
+ )),
("max_parallel_pings", Integer(
title = _("Parallel pings to send"),
help = _("Set the maximum number of concurrent pings sent to
target IP "