Module: check_mk
Branch: master
Commit: 472e57edbda5ab1edcf05d38adab0302041138bc
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=472e57edbda5ab…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Jul 22 14:30:58 2014 +0200
Virtual Host Tree: Allow to use topic as tree level
The <i>Virtual Host Tree</i> snapin now allows not only to use tag groups but also <b>topics</b>
as tree levels. A topic can only be used if:
<ul>
<li>It contains just <i>Checkbox</i>-tags (tags with only once choicee)</li>
<li>It contains at least two entries.</li>
</ul>
The idea is to make the typical <i>Applications</i> topic usable as a tree level. The
tree then shows all the different applications. Note: this usually leads to hosts being
contained in several branches of the tree (if they have several applications) and other
hosts not being contained at all (if the do not have at least one application).
---
.werks/1047 | 19 ++++++
ChangeLog | 1 +
web/plugins/sidebar/shipped.py | 100 +++++++++++++++++++++-------
web/plugins/wato/check_mk_configuration.py | 18 +++++
4 files changed, 113 insertions(+), 25 deletions(-)
diff --git a/.werks/1047 b/.werks/1047
new file mode 100644
index 0000000..9c382e4
--- /dev/null
+++ b/.werks/1047
@@ -0,0 +1,19 @@
+Title: Virtual Host Tree: Allow to use topic as tree level
+Level: 2
+Component: multisite
+Version: 1.2.5i5
+Date: 1406032104
+Class: feature
+
+The <i>Virtual Host Tree</i> snapin now allows not only to use tag groups but also <b>topics</b>
+as tree levels. A topic can only be used if:
+
+<ul>
+<li>It contains just <i>Checkbox</i>-tags (tags with only once choicee)</li>
+<li>It contains at least two entries.</li>
+</ul>
+
+The idea is to make the typical <i>Applications</i> topic usable as a tree level. The
+tree then shows all the different applications. Note: this usually leads to hosts being
+contained in several branches of the tree (if they have several applications) and other
+hosts not being contained at all (if the do not have at least one application).
diff --git a/ChangeLog b/ChangeLog
index 5b6b80c..a8a4bbf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -70,6 +70,7 @@
* 0949 quicksearch: now able to search for multiple hosts at once...
* 1052 SEC: index start URL can not be used to redirect to absolute URLs anymore...
* 1085 quicksearch: multiple hostname matches now lead to the searchhost view instead of the hosts view...
+ * 1047 Virtual Host Tree: Allow to use topic as tree level...
* 0945 FIX: Sidebar snapin "Problem hosts": Now excludes hosts and services in downtime
* 1036 FIX: doc/treasures/downtime: fix --url option, better error output
* 1074 FIX: Fix Virtual Host Tree snapin...
diff --git a/web/plugins/sidebar/shipped.py b/web/plugins/sidebar/shipped.py
index d98a9fc..05f3eeb 100644
--- a/web/plugins/sidebar/shipped.py
+++ b/web/plugins/sidebar/shipped.py
@@ -1214,6 +1214,11 @@ if defaults.omd_root:
# | |
# '----------------------------------------------------------------------'
+def parse_hosttag_title(title):
+ if '/' in title:
+ return title.split('/', 1)
+ else:
+ return None, title
def compute_tag_tree(taglist):
html.live.set_prepend_site(True)
@@ -1235,11 +1240,17 @@ def compute_tag_tree(taglist):
# No empty entry found -> get default (i.e. first entry)
return groupentries[0][:2]
+ # Prepare list of host tag groups and topics
taggroups = {}
+ topics = {}
for entry in config.wato_host_tags:
- groupname = entry[0]
- grouptitle = entry[1]
- group = entry[2]
+ grouptitle = entry[1]
+ if '/' in grouptitle:
+ topic, grouptitle = grouptitle.split("/", 1)
+ topics.setdefault(topic, []).append(entry)
+
+ groupname = entry[0]
+ group = entry[2]
taggroups[groupname] = group
tree = {}
@@ -1261,24 +1272,53 @@ def compute_tag_tree(taglist):
have_svc_problems = True
tags = custom_variables.get("TAGS", []).split()
- tree_entry = tree
+
+ tree_entry = tree # Start at top node
+
+ # Now go through the levels of the tree. Each level may either be
+ # - a tag group id, or
+ # - "topic:" plus the name of a tag topic. That topic should only contain
+ # checkbox tags.
+ # The problem with the "topic" entries is, that a host may appear several
+ # times!
+
+ current_branches = [ tree ]
+
for tag in taglist:
- if tag not in taggroups:
- continue # Configuration error. User deleted tag group after configuring his tree
- tag_value, tag_title = get_tag_group_value(taggroups[tag], tags)
- tree_entry = tree_entry.setdefault((tag_title, tag_value), {})
-
- if not tree_entry:
- tree_entry.update({
- "_num_hosts" : 0,
- "_state" : 0,
- })
- tree_entry["_num_hosts"] += 1
- tree_entry["_svc_problems"] = tree_entry.get("_svc_problems", False) or have_svc_problems
- if state == 2 or tree_entry["_state"] == 2:
- tree_entry["_state"] = 2
- else:
- tree_entry["_state"] = max(state, tree_entry["_state"])
+ new_current_branches = []
+ for tree_entry in current_branches:
+ if tag.startswith("topic:"):
+ topic = tag[6:]
+ if topic in topics: # Could have vanished
+ # Iterate over all host tag groups with that topic
+ for entry in topics[topic]:
+ grouptitle = entry[1].split("/", 1)[1]
+ group = entry[2]
+ for tagentry in group:
+ tag_value, tag_title = tagentry[:2]
+ if tag_value in tags:
+ new_current_branches.append(tree_entry.setdefault((tag_title, tag_value), {}))
+
+ else:
+ if tag not in taggroups:
+ continue # Configuration error. User deleted tag group after configuring his tree
+ tag_value, tag_title = get_tag_group_value(taggroups[tag], tags)
+ new_current_branches.append(tree_entry.setdefault((tag_title, tag_value), {}))
+
+ current_branches = new_current_branches
+
+ for tree_entry in new_current_branches:
+ if not tree_entry:
+ tree_entry.update({
+ "_num_hosts" : 0,
+ "_state" : 0,
+ })
+ tree_entry["_num_hosts"] += 1
+ tree_entry["_svc_problems"] = tree_entry.get("_svc_problems", False) or have_svc_problems
+ if state == 2 or tree_entry["_state"] == 2:
+ tree_entry["_state"] = 2
+ else:
+ tree_entry["_state"] = max(state, tree_entry["_state"])
return tree
@@ -1305,10 +1345,22 @@ def tag_tree_url(taggroups, taglist, viewname):
urlvars = [("view_name", viewname), ("filled_in", "filter")]
if viewname == "svcproblems":
urlvars += [ ("st1", "on"), ("st2", "on"), ("st3", "on") ]
+
for nr, (group, tag) in enumerate(zip(taggroups, taglist)):
- urlvars.append(("host_tag_%d_grp" % nr, group))
- urlvars.append(("host_tag_%d_op" % nr, "is"))
- urlvars.append(("host_tag_%d_val" % nr, tag or ""))
+ if group.startswith("topic:"):
+ # Find correct tag group for this tag
+ for entry in config.wato_host_tags:
+ for tagentry in entry[2]:
+ if tagentry[0] == tag: # Found our tag
+ taggroup = entry[0]
+ urlvars.append(("host_tag_%d_grp" % nr, taggroup))
+ urlvars.append(("host_tag_%d_op" % nr, "is"))
+ urlvars.append(("host_tag_%d_val" % nr, tag))
+ break
+ else:
+ urlvars.append(("host_tag_%d_grp" % nr, group))
+ urlvars.append(("host_tag_%d_op" % nr, "is"))
+ urlvars.append(("host_tag_%d_val" % nr, tag or ""))
return html.makeuri_contextless(urlvars, "view.py")
def tag_tree_bullet(state, path, leaf):
@@ -1419,8 +1471,6 @@ def render_tag_tree():
title, taggroups = config.virtual_host_trees[tree_conf["tree"]]
tree = compute_tag_tree(taggroups)
-
-
render_tag_tree_level(taggroups, [], cwd, _("Virtual Host Tree"), tree)
sidebar_snapins["tag_tree"] = {
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index a550b26..654504b 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -245,11 +245,29 @@ register_configvar(group,
def wato_host_tag_group_choices():
+ # We add to the choices:
+ # 1. All host tag groups with their id
+ # 2. All *topics* that:
+ # - consist only of checkbox tags
+ # - contain at least two entries
choices = []
+ by_topic = {}
for entry in config.wato_host_tags:
tgid = entry[0]
topic, tit = parse_hosttag_title(entry[1])
choices.append((tgid, tit))
+ by_topic.setdefault(topic, []).append(entry)
+
+ # Now search for checkbox-only-topics
+ for topic, entries in by_topic.items():
+ for entry in entries:
+ tgid, title, tags = entry
+ if len(tags) != 1:
+ break
+ else:
+ if len(entries) > 1:
+ choices.append(("topic:" + topic, _("Topic") + ": " + topic))
+
return choices
Module: check_mk
Branch: master
Commit: 376a889ede54b7877d06db5ec22f1ee5c6ae8478
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=376a889ede54b7…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jul 22 12:06:44 2014 +0200
FIX Fixed exception during first login of a user when saving of access times is enabled
When a user logged in for the first time an exception could occur when the
tracking of user access times is enabled.
---
.werks/1060 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/userdb.py | 1 +
3 files changed, 12 insertions(+)
diff --git a/.werks/1060 b/.werks/1060
new file mode 100644
index 0000000..c9ef747
--- /dev/null
+++ b/.werks/1060
@@ -0,0 +1,10 @@
+Title: Fixed exception during first login of a user when saving of access times is enabled
+Level: 1
+Component: multisite
+Class: fix
+State: unknown
+Version: 1.2.5i5
+Date: 1406023447
+
+When a user logged in for the first time an exception could occur when the
+tracking of user access times is enabled.
diff --git a/ChangeLog b/ChangeLog
index 5b6b80c..2591715 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -74,6 +74,7 @@
* 1036 FIX: doc/treasures/downtime: fix --url option, better error output
* 1074 FIX: Fix Virtual Host Tree snapin...
* 1059 FIX: LDAP: Using configured user filter during login to prevent temporary created users...
+ * 1060 FIX: Fixed exception during first login of a user when saving of access times is enabled...
WATO:
* 0825 WATO: Hover menu of user online state shows the last seen date/time now
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 7fbecee..d0dc871 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -345,6 +345,7 @@ def load_custom_attr(userid, key, conv_func, default = None):
def save_custom_attr(userid, key, val):
basedir = defaults.var_dir + "/web/" + userid
+ make_nagios_directory(basedir)
create_user_file('%s/%s.mk' % (basedir, key), 'w').write('%s\n' % val)
def get_online_user_ids():
Module: check_mk
Branch: master
Commit: edc088388cb84d8a56819f1f8a4dc68307bfc6c4
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=edc088388cb84d…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Jul 22 08:53:39 2014 +0200
New additional API for checks using yield
---
checks/tcp_conn_stats | 38 +++++++++++---------------
modules/automation.py | 2 +-
modules/check_mk_base.py | 67 ++++++++++++++++++++++++++--------------------
3 files changed, 55 insertions(+), 52 deletions(-)
diff --git a/checks/tcp_conn_stats b/checks/tcp_conn_stats
index d85b48a..64ab3cc 100644
--- a/checks/tcp_conn_stats
+++ b/checks/tcp_conn_stats
@@ -47,31 +47,25 @@ def inventory_tcp_conn_stats(info):
def check_tcp_conn_stats(item, params, info):
stats = dict(info)
- worst_state = 0
- info = []
- perfdata = []
for state, hex in tcp_conn_stats_states:
num = int(stats.get(state, stats.get(hex, 0)))
- if num > 0:
+ if num > 0: # Only check positive counts
infotext = "%s: %d" % (state, num)
- else:
- infotext = None
- levels = params.get(state)
- perf = [state, num]
- if levels:
- warn, crit = levels
- perf.append(warn)
- perf.append(crit)
- if num >= crit:
- worst_state = 2
- infotext += "(!!) (critical at %d)" % crit
- elif num >= warn:
- worst_state = max(1, worst_state)
- infotext += "(!) (warning at %d)" % warn
- perfdata.append(perf)
- if infotext:
- info.append(infotext)
- return (worst_state, ", ".join(info), perfdata)
+ perf = [state, num]
+ levels = params.get(state)
+ if levels:
+ warn, crit = levels
+ perf.append(warn)
+ perf.append(crit)
+ if num >= crit:
+ state = 2
+ infotext += " (critical at %d)" % crit
+ elif num >= warn:
+ state = 1
+ infotext += " (warning at %d)" % warn
+ else:
+ state = 0
+ yield state, infotext, [perf]
check_info["tcp_conn_stats"] = {
diff --git a/modules/automation.py b/modules/automation.py
index 2882a54..93e69c7 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -388,7 +388,7 @@ def automation_try_inventory_node(hostname, leave_no_tcp=False, with_snmp_scan=F
params = compute_check_parameters(hostname, ct, item, params)
try:
- result = check_function(item, params, info)
+ result = convert_check_result(check_function(item, params, info))
except MKCounterWrapped, e:
result = (None, "WAITING - Counter based check, cannot be done offline")
except Exception, e:
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 3ca0383..5699b67 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -1127,6 +1127,40 @@ def convert_check_info():
if info["snmp_scan_function"] and basename not in snmp_scan_functions:
snmp_scan_functions[basename] = info["snmp_scan_function"]
+
+def convert_check_result(result):
+ if type(result) == tuple:
+ return result
+
+ # The check function may either return a tuple (pair or triple) or an iterator
+ # (using yield). The latter one is new since version 1.2.5i5.
+ else: # We assume an iterator, convert to tuple
+ subresults = list(result)
+
+ # Simple check with no separate subchecks (yield wouldn't have been neccessary here!)
+ if len(subresults) == 1:
+ return subresults[0]
+
+ # Several sub results issued with multiple yields. Make that worst sub check
+ # decide the total state, join the texts and performance data
+ else:
+ perfdata = []
+ infotexts = []
+ status = 0
+
+ for subresult in subresults:
+ st, text = subresult[:2]
+ infotexts.append(text + ["", "(!)", "(!!)", "(?)"][st])
+ if st == 2 or status == 2:
+ status = 2
+ else:
+ status = max(status, st)
+ if len(subresult) == 3:
+ perfdata += subresult[2]
+
+ return status, ", ".join(infotexts), perfdata
+
+
# Loops over all checks for a host, gets the data, calls the check
# function that examines that data and sends the result to Nagios
def do_all_checks_on_host(hostname, ipaddress, only_check_types = None):
@@ -1193,35 +1227,10 @@ def do_all_checks_on_host(hostname, ipaddress, only_check_types = None):
try:
dont_submit = False
- result = check_function(item, params, info)
- # the new api doesen't return a tuple,
- # it's yield based instead.
- if type(result) != tuple:
- messages = []
- perf = []
- for line in result:
- messages.append(( line[0], line[1] ))
- if len(line) == 3:
- # there can be a single perf value (tuple)
- # or a list of multiple perf values
- if type(line[2]) == tuple:
- perf.append(line[2])
- elif type(line[2]) == list:
- perf += list
- # Check funktion returns only a single line
- if len(messages) == 1:
- result = messages[0][0], messages[0][1], perf
- else:
- # Get the overall status
- return_states = [ x[0] for x in messages ]
- if 3 in return_states:
- if not 2 in return_states and not 1 in return_states:
- status = 3
- else:
- status = max(return_states) - 1
- else:
- status = max(return_states)
- result = status, ", ".join( x[1]+state_markers[x[0]] for x in messages ), perf
+
+ # Call the actual check function
+ result = convert_check_result(check_function(item, params, info))
+
# handle check implementations that do not yet support the
# handling of wrapped counters via exception. Do not submit
Module: check_mk
Branch: master
Commit: f40bc9000ee56ced637645f63a5661fa16873219
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f40bc9000ee56c…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Mon Jul 21 16:59:22 2014 +0200
qlogic_sanbox_fabric_element: New Check for Fabric Elements in QLogic SANbox Fibre Channel Switches
---
.werks/1133 | 8 +++++
ChangeLog | 1 +
checkman/qlogic_sanbox_fabric_element | 16 +++++++++
checks/qlogic_sanbox_fabric_element | 57 +++++++++++++++++++++++++++++++++
4 files changed, 82 insertions(+)
diff --git a/.werks/1133 b/.werks/1133
new file mode 100644
index 0000000..047fcc1
--- /dev/null
+++ b/.werks/1133
@@ -0,0 +1,8 @@
+Title: qlogic_sanbox_fabric_element: New Check for Fabric Elements in QLogic SANbox Fibre Channel Switches
+Level: 1
+Component: checks
+Version: 1.2.5i5
+Date: 1405954726
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 8e28ef0..5b6b80c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,7 @@
* 1001 qlogic_sanbox.psu: New Check for power supplies in QLogic SANbox Fibre Channel Switches
* 0182 MegaCli: Agent now also supports the 64bit version (Thanks to Philipp Lemke)
* 1132 qlogic_fcport: New Check for Fibre Channel Ports in QLogic SANbox FC Switches
+ * 1133 qlogic_sanbox_fabric_element: New Check for Fabric Elements in QLogic SANbox Fibre Channel Switches
* 0994 FIX: agent plugin smart: fixed syntax error
* 0989 FIX: logwatch.ec: Fix forwarding multiple messages via syslog/TCP...
* 0943 FIX: if.include: fixed incorrect traffic percentage values in the check output of if checks...
diff --git a/checkman/qlogic_sanbox_fabric_element b/checkman/qlogic_sanbox_fabric_element
new file mode 100644
index 0000000..df7f099
--- /dev/null
+++ b/checkman/qlogic_sanbox_fabric_element
@@ -0,0 +1,16 @@
+title: QLogic SANbox Fibre Channel Switches: Status of Fabric Elements
+agents: snmp
+catalog: hw/storagehw/qlogic
+license: GPL
+distribution: check_mk
+description:
+ Checks the Status of Fabric Elements in QLogic SANbox Fibre Channel Switches.
+
+ Returns {OK} on status online, {WARN} on status testing and {CRIT} on
+ status offline or faulty.
+
+item:
+ The ID of Fabric Element, just an integer.
+
+inventory:
+ Creates one check for every Fabric Element found by SNMP.
diff --git a/checks/qlogic_sanbox_fabric_element b/checks/qlogic_sanbox_fabric_element
new file mode 100644
index 0000000..db99e0c
--- /dev/null
+++ b/checks/qlogic_sanbox_fabric_element
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+def inventory_qlogic_sanbox_fabric_element(info):
+ inventory = []
+ for fe_status, fe_id in info:
+ inventory.append( (fe_id, None) )
+ return inventory
+
+def check_qlogic_sanbox_fabric_element(item, _no_params, info):
+ for fe_status, fe_id in info:
+ if fe_id == item:
+ if fe_status == "1":
+ return 0, "Fabric Element %s is online" % fe_id
+ elif fe_status == "2":
+ return 2, "Fabric Element %s is offline" % fe_id
+ elif fe_status == "3":
+ return 1, "Fabric Element %s is testing" % fe_id
+ elif fe_status == "4":
+ return 2, "Fabric Element %s is faulty" % fe_id
+ else:
+ return 3, "Fabric Element %s is in unidentified status %s" % (fe_id, fe_status)
+
+ return 3, "No Fabric Element %s found" % item
+
+check_info["qlogic_sanbox_fabric_element"] = {
+ "check_function" : check_qlogic_sanbox_fabric_element,
+ "inventory_function" : inventory_qlogic_sanbox_fabric_element,
+ "service_description" : "Fabric Element %s",
+ "has_perfdata" : False,
+ "snmp_info" : (".1.3.6.1.2.1.75.1.1.4.1", [4, # fcFeModuleOperStatus
+ OID_END]),
+ "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.3873.1.14"),
+}