Module: check_mk
Branch: master
Commit: 58780974e071e29692185d3015167b4876c28988
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=58780974e071e2…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Mar 10 11:25:55 2016 +0100
3007 FIX Interface groups: fixed exception when port type or interface items were not set in the WATO rule
You should do a new service discovery for hosts with grouped interfaces.
This is not mandatory, however it will clean up some invalid values stored values
in the autochecks directory.
---
.werks/3007 | 11 +++++++++++
ChangeLog | 1 +
checks/if.include | 41 ++++++++++++++++++++++++++++-------------
3 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/.werks/3007 b/.werks/3007
new file mode 100644
index 0000000..bdcf5ef
--- /dev/null
+++ b/.werks/3007
@@ -0,0 +1,11 @@
+Title: Interface groups: fixed exception when port type or interface items were not set in the WATO rule
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.9i1
+Date: 1457605216
+Class: fix
+
+You should do a new service discovery for hosts with grouped interfaces.
+This is not mandatory, however it will clean up some invalid values stored values
+in the autochecks directory.
diff --git a/ChangeLog b/ChangeLog
index 3011201..90dd0b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -74,6 +74,7 @@
* 3094 FIX: cisco_temperature: fixed duplicated sensors on some devices...
* 3006 FIX: agent_vsphere: fixed exception when providing the wrong login credentials
* 3261 FIX: cisco_temperature: fixed wrong datatype handling
+ * 3007 FIX: Interface groups: fixed exception when port type or interface items were not set in the WATO rule...
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/if.include b/checks/if.include
index 89d8a26..fe3b795 100644
--- a/checks/if.include
+++ b/checks/if.include
@@ -293,12 +293,14 @@ def inventory_if_common(info, has_nodeinfo = False):
is_only_in_group = False
for group_name, pattern in group_patterns.items():
# Interfaces can be grouped by item and iftype
- match_item = not pattern.get("include_items") or (tryint(item) in map(tryint, pattern["include_items"]))
- match_type = not pattern.get("iftype") or (pattern["iftype"] == saveint(ifType))
+ match_item = "include_items" not in pattern or (tryint(item) in map(tryint, pattern["include_items"]))
+ match_type = "iftype" not in pattern or (pattern["iftype"] == saveint(ifType))
if match_item and match_type:
- have_groups.setdefault(group_name, {"interfaces": [],
- "iftype": pattern.get("iftype"),
- "include_items": pattern.get("include_items")})
+ have_groups.setdefault(group_name, {"interfaces": []})
+ for what in [ "iftype", "include_items" ]:
+ if pattern.get(what):
+ have_groups[group_name][what] = pattern.get(what)
+
have_groups[group_name]["interfaces"].append((saveint(ifSpeed), ifOperStatus, ifType))
if pattern.get("single"):
is_only_in_group = True
@@ -337,9 +339,10 @@ def inventory_if_common(info, has_nodeinfo = False):
group_operStatus = one_up and "1" or "2"
if group_operStatus in portstates:
- params = { "iftype" : values["iftype"],
- "include_items": values["include_items"],
- "aggregate" : True }
+ params = { "aggregate": True }
+ for what in [ "iftype", "include_items" ]:
+ if what in values:
+ params[what] = values[what]
if uses_description:
params["aggr_member_item"] = "description"
@@ -399,10 +402,17 @@ def check_if_common(item, params, info, has_nodeinfo = False, group_name = "Grou
if ifGroup and ifGroup == item:
matching_interfaces.append((if_member_item, element))
- # tryint -> force "01" and "1" to be identical.
- elif (params.get("include_items") == None or tryint(if_member_item) in map(tryint, params["include_items"])) or\
- saveint(element[2 + node_offset]) == params.get("iftype"):
- matching_interfaces.append((if_member_item, element))
+ else:
+ # The iftype and include_items parameters are further restrictions
+ # If none of them are set, the interface is added to the group
+ add_interface = True # This approach is easier to comprehend..
+ # tryint -> force "01" and "1" to be identical.
+ if params.get("include_items") != None and tryint(if_member_item) not in map(tryint, params["include_items"]):
+ add_interface = False
+ elif params.get("iftype") != None and saveint(element[2 + node_offset]) != params["iftype"]:
+ add_interface = False
+ if add_interface:
+ matching_interfaces.append((if_member_item, element))
# Accumulate info over matching_interfaces
wrapped = False
@@ -477,6 +487,8 @@ def check_if_common(item, params, info, has_nodeinfo = False, group_name = "Grou
group_info["ifOutErrors"] += saveint(ifOutErrors)
group_info["ifOutQLen"] += saveint(ifOutQLen)
+ group_info["ifType"] = ifType # This is the fallback ifType if none is set in the parameters
+
# Append an additional entry to the info table containing the calculated group_info
@@ -503,10 +515,13 @@ def check_if_common(item, params, info, has_nodeinfo = False, group_name = "Grou
else:
group_entry = []
+ if params.get("ifType"):
+ group_info["ifType"] = params["ifType"]
+
group_entry += [
"ifgroup%s" % item, # ifIndex
item, # ifDescr
- params["iftype"], # ifType
+ group_info["ifType"], # ifType
group_info["ifSpeed"], # ifSpeed
group_operStatus, # ifOperStatus
group_info["ifInOctets"], # ifInOctets
Module: check_mk
Branch: master
Commit: b98357582c91f21cfe6deb3278fdb3bc691056e0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b98357582c91f2…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 9 17:20:16 2016 +0100
3283 FIX Bulk import of hosts: It is now possible again to import a simple list of hosts
In previous versions it was possible to just import a simple list of host names. Where
one host name per line is given. This is now possible again.
---
.werks/3283 | 11 +++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 40 +++++++++++++++++++++++++++++-----------
3 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/.werks/3283 b/.werks/3283
new file mode 100644
index 0000000..1e45b36
--- /dev/null
+++ b/.werks/3283
@@ -0,0 +1,11 @@
+Title: Bulk import of hosts: It is now possible again to import a simple list of hosts
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1457540348
+
+In previous versions it was possible to just import a simple list of host names. Where
+one host name per line is given. This is now possible again.
diff --git a/ChangeLog b/ChangeLog
index 45dbb40..c2684d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -116,6 +116,7 @@
* 3281 FIX: Fixed network scan overwriting folder modifications made during the scan
* 3282 FIX: Fixed missing validation of network scan properties...
* 3005 FIX: webapi: now able to add new hosts to main folder (bug was introduced recently)
+ * 3283 FIX: Bulk import of hosts: It is now possible again to import a simple list of hosts...
* 3284 FIX: Bulk import of hosts: Fixed disabling of reading first line as header...
Notifications:
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 6fa1e64..1e025b1 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2949,7 +2949,7 @@ class ModeBulkImport(WatoMode):
def __init__(self):
super(ModeBulkImport, self).__init__()
self._csv_reader = None
- self._params = {}
+ self._params = None
def title(self):
@@ -3009,6 +3009,13 @@ class ModeBulkImport(WatoMode):
os.unlink(path)
+ def _get_custom_csv_dialect(self, delim):
+ class CustomCSVDialect(csv.excel):
+ delimiter = delim
+
+ return CustomCSVDialect()
+
+
def _read_csv_file(self):
try:
csv_file = file(self._file_path())
@@ -3017,22 +3024,23 @@ class ModeBulkImport(WatoMode):
params = self._vs_parse_params().from_html_vars("_preview")
self._vs_parse_params().validate_value(params, "_preview")
- self._params = params or self._vs_parse_params().default_value()
+ self._params = params
# try to detect the CSV format to be parsed
if "field_delimiter" in params:
- class CustomCSVDialect(csv.excel):
- delimiter = params["field_delimiter"]
-
- csv_dialect = CustomCSVDialect()
+ csv_dialect = self._get_custom_csv_dialect(params["field_delimiter"])
else:
try:
csv_dialect = csv.Sniffer().sniff(csv_file.read(2048), delimiters=",;\t:")
csv_file.seek(0)
except csv.Error, e:
if "Could not determine delimiter" in str(e):
- raise MKUserError(None, _("Failed to detect the CSV files field delimiter character. Please "
- "specify it manually."))
+ # Failed to detect the CSV files field delimiter character. Using ";" now. If
+ # you need another one, please specify it manually.
+ csv_dialect = self._get_custom_csv_dialect(";")
+ csv_file.seek(0)
+ else:
+ raise
# Save for preview in self.page()
@@ -3041,7 +3049,10 @@ class ModeBulkImport(WatoMode):
def _import(self):
if self._params.get("has_title_line"):
- self._csv_reader.next() # skip header
+ try:
+ self._csv_reader.next() # skip header
+ except StopIteration:
+ pass
num_succeeded, num_failed = 0, 0
fail_messages = []
@@ -3181,7 +3192,10 @@ class ModeBulkImport(WatoMode):
# Die problematischen Zeilen sollen angezeigt werden, so dass man diese als Block in ein neues CSV-File eintragen kann und dann diese Datei
# erneut importieren kann.
if self._params.get("has_title_line"):
- headers = list(self._csv_reader.next())
+ try:
+ headers = list(self._csv_reader.next())
+ except StopIteration:
+ headers = [] # nope, there is no header
else:
headers = []
@@ -3211,7 +3225,11 @@ class ModeBulkImport(WatoMode):
def _preview_form(self):
- self._vs_parse_params().render_input("_preview", self._params or self._vs_parse_params().default_value())
+ if self._params != None:
+ params = self._params
+ else:
+ params = self._vs_parse_params().default_value()
+ self._vs_parse_params().render_input("_preview", params)
html.hidden_fields()
html.button("_do_preview", _("Update preview"))
html.button("_do_import", _("Import"))
Module: check_mk
Branch: master
Commit: 3d656832929c2b75ab0da26862f5912f3054f67f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3d656832929c2b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 9 17:21:28 2016 +0100
3284 FIX Bulk import of hosts: Fixed disabling of reading first line as header
When no delimiter is specified, it is now possible to disable treating the
first line as header line.
---
.werks/3284 | 11 +++++++++++
ChangeLog | 1 +
2 files changed, 12 insertions(+)
diff --git a/.werks/3284 b/.werks/3284
new file mode 100644
index 0000000..a86bd25
--- /dev/null
+++ b/.werks/3284
@@ -0,0 +1,11 @@
+Title: Bulk import of hosts: Fixed disabling of reading first line as header
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1457540419
+
+When no delimiter is specified, it is now possible to disable treating the
+first line as header line.
diff --git a/ChangeLog b/ChangeLog
index 688a29c..45dbb40 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -116,6 +116,7 @@
* 3281 FIX: Fixed network scan overwriting folder modifications made during the scan
* 3282 FIX: Fixed missing validation of network scan properties...
* 3005 FIX: webapi: now able to add new hosts to main folder (bug was introduced recently)
+ * 3284 FIX: Bulk import of hosts: Fixed disabling of reading first line as header...
Notifications:
* 3263 Notifications: allow users to restrict by their contact groups...