Module: check_mk
Branch: master
Commit: 56517f978cb4012ef0072cf9f63d887a216130c2
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=56517f978cb401…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Aug 14 09:14:43 2013 +0200
Improved foldertree folder filtering
---
ChangeLog | 3 +++
web/plugins/sidebar/wato.py | 22 +++++++++++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 5561dee..c6c361c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -109,6 +109,9 @@
* Added new painters for displaying host tags (list of tags, single tag
groups). All those painters are sortable. Also added new filters for tags.
* Added painters, icon and filters for visualizing staleness information
+ * Improved filtering of the foldertree snapin by user permissions (when a user is
+ only permitted on one child folder, the upper folder is removed from the
+ hierarchy)
* FIX: better error message in case of exception in SNMP handling
* FIX: Inventory screen: Now shows custom checks
* FIX: Fixed locking problem of multisite pages related to user loading/saving
diff --git a/web/plugins/sidebar/wato.py b/web/plugins/sidebar/wato.py
index 8a9d23f..3cd3f66 100644
--- a/web/plugins/sidebar/wato.py
+++ b/web/plugins/sidebar/wato.py
@@ -156,6 +156,7 @@ def render_wato_foldertree():
'.folders': {},
}
+
# After the query we have a list of lists where each
# row is a folder with the number of hosts on this level.
#
@@ -190,6 +191,25 @@ def render_wato_foldertree():
del user_folders[folder_path]
#
+ # Now reduce the tree by e.g. removing top-level parts which the user is not
+ # permitted to see directly. Example:
+ # Locations
+ # -> Hamburg: Permitted to see all hosts
+ # -> Munich: Permitted to see no host
+ # In this case, where only a single child with hosts is available, remove the
+ # top level
+ def reduce_tree(folders):
+ for folder_path, folder in folders.items():
+ if len(folder['.folders']) == 1:
+ child_path, child_folder = folder['.folders'].items()[0]
+ folders[child_path] = child_folder
+ del folders[folder_path]
+
+ reduce_tree(folders)
+
+ reduce_tree(user_folders)
+
+ #
# Render link target selection
#
selected_topic, selected_target = config.load_user_file("foldertree", (_('Hosts'), 'allhosts'))
@@ -224,7 +244,7 @@ def render_wato_foldertree():
# Now render the whole tree
if user_folders:
- render_tree_folder(user_folders[''])
+ render_tree_folder(user_folders.values()[0])
def render_tree_folder(f):
subfolders = f.get(".folders", {})
Module: check_mk
Branch: master
Commit: 59636587f34e62875ce183b909e1e87d11180620
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=59636587f34e62…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Tue Aug 13 18:09:53 2013 +0200
new check ups_test
---
checks/ups_test | 136 ++++++++++++++++++++++++++++++++++
web/plugins/wato/check_parameters.py | 17 ++++-
2 files changed, 152 insertions(+), 1 deletion(-)
diff --git a/checks/ups_test b/checks/ups_test
new file mode 100644
index 0000000..d5d0497
--- /dev/null
+++ b/checks/ups_test
@@ -0,0 +1,136 @@
+#!/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.
+
+# Description of OIDs used from RFC 1628
+# OID: 1.3.6.1.2.1.33.1.7.3
+# upsTestResultsSummary OBJECT-TYPE
+# SYNTAX INTEGER {
+# donePass(1),
+# doneWarning(2),
+# doneError(3),
+# aborted(4),
+# inProgress(5),
+# noTestsInitiated(6)
+# }
+# MAX-ACCESS read-only
+# STATUS current
+# DESCRIPTION
+# "The results of the current or last UPS diagnostics
+# test performed. The values for donePass(1),
+# doneWarning(2), and doneError(3) indicate that the
+# test completed either successfully, with a warning, or
+# with an error, respectively. The value aborted(4) is
+# returned for tests which are aborted by setting the
+# value of upsTestId to upsTestAbortTestInProgress.
+# Tests which have not yet concluded are indicated by
+# inProgress(5). The value noTestsInitiated(6)
+# indicates that no previous test results are available,
+# such as is the case when no tests have been run since
+# the last reinitialization of the network management
+# subsystem and the system has no provision for non-
+# volatile storage of test results."
+
+# OID: 1.3.6.1.2.1.33.1.7.4
+# upsTestResultsDetail OBJECT-TYPE
+# SYNTAX DisplayString (SIZE (0..255))
+# MAX-ACCESS read-only
+# STATUS current
+# DESCRIPTION
+# "Additional information about upsTestResultsSummary.
+# If no additional information available, a zero length
+# string is returned."
+
+# OID: 1.3.6.1.2.1.33.1.7.5
+# Description:
+# upsTestStartTime OBJECT-TYPE
+# SYNTAX TimeStamp
+# MAX-ACCESS read-only
+# STATUS current
+# DESCRIPTION
+# "The value of sysUpTime at the time the test in
+# progress was initiated, or, if no test is in progress,
+# the time the previous test was initiated. If the
+# value of upsTestResultsSummary is noTestsInitiated(6),
+# upsTestStartTime has the value 0."
+
+# OID: 1.3.6.1.2.1.33.1.7.6
+# Description:
+# upsTestElapsedTime OBJECT-TYPE
+# SYNTAX TimeInterval
+# MAX-ACCESS read-only
+# STATUS current
+# DESCRIPTION
+# "The amount of time, in TimeTicks, since the test in
+# progress was initiated, or, if no test is in progress,
+# the previous test took to complete. If the value of
+# TestResultsSummary is noTestsInitiated(6),
+# upsTestElapsedTime has the value 0."
+
+ups_test_default = (None, None )
+
+def inventory_ups_test(info):
+ if len(info) > 0:
+ return [ (None, "ups_test_default") ]
+
+def check_ups_test(item, params, info):
+ warn, crit = params
+ line = info[0]
+ ResultsSummary, StartTime, ElapsedTime = map(saveint, line[:-1])
+ ElapsedTime = ElapsedTime/100
+ etime = get_age_human_readable(ElapsedTime)
+
+ state = 0
+ state_label = ""
+ if ResultsSummary in [ 3, 4 ]:
+ state = 2
+ state_label = "(!!)"
+ elif ResultsSummary in [ 2, 6 ]:
+ state = 1
+ state_label = "(!)"
+
+ time_label = ""
+ if crit and ElapsedTime >= crit:
+ state = 2
+ time_label = "(!!)"
+ elif warn and ElapsedTime >= warn:
+ state = max(state, 1)
+ time_label = "(!)"
+
+ ResultsDetail = "%s%s Time elapsed since test: %s%s" % (line[-1], state_label, etime, time_label)
+
+ perf = [ ( "ElapsedTime", ElapsedTime, warn, crit) ]
+ return (state, ResultsDetail, perf )
+
+check_info['ups_test'] = {
+ "inventory_function" : inventory_ups_test,
+ "check_function" : check_ups_test,
+ "service_description" : "UPS Test",
+ "has_perfdata" : True,
+ "group" : "ups_test",
+ "snmp_info" : ( ".1.3.6.1.2.1.33.1.7", [3,5,6,4 ] ),
+ "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0") in [".1.3.6.1.4.1.534.1"]
+
+}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 9e90ee0..212c77b 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -699,6 +699,21 @@ register_check_parameters(
)
register_check_parameters(
+ subgroup_environment,
+ "ups_test",
+ _("Time since last UPS selftest"),
+ Tuple(
+ title = _("Time since last UPS selftest"),
+ elements = [
+ Age(title = _("Warning if above")),
+ Age(title = _("Critical if above")),
+ ]
+ ),
+ None,
+ "first"
+)
+
+register_check_parameters(
subgroup_storage,
"fileinfo",
_("Size and age of single files"),
@@ -2865,7 +2880,7 @@ register_check_parameters(
register_check_parameters(
subgroup_os,
"apc_symentra",
- _("Levels for APC Symentra Check"),
+ _("APC Symentra Checks"),
Tuple(
elements = [
Integer(
Module: check_mk
Branch: master
Commit: 294078e758b04bcd5f363968a659cb0659f6d1a5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=294078e758b04b…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Mon Aug 12 18:13:48 2013 +0200
small fixes for texts
---
web/plugins/wato/check_parameters.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index f439a8c..9e90ee0 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -768,7 +768,7 @@ register_rule(group + '/' + subgroup_storage,
title = _("Name of group"),
),
TextAscii(
- title = _("File pattern (using * and ?)"),
+ title = _("Pattern for mount point (using * and ?)"),
help = _("You can specify one or several patterns containing "
"<tt>*</tt> and <tt>?</tt>, for example <tt>/spool/tmpspace*</tt>. "
"The filesystems matching the patterns will be monitored "
@@ -805,7 +805,7 @@ register_rule(group + '/' + subgroup_storage,
title = _("Name of group"),
),
TextAscii(
- title = _("Pattern for mount point (using * and ?)"),
+ title = _("File pattern (using * and ?)"),
),
]
),
@@ -824,8 +824,8 @@ register_check_parameters(
Tuple(
title = _("Minimal age of oldest file"),
elements = [
- Age(title = _("Warning younger than")),
- Age(title = _("Critical younger than")),
+ Age(title = _("Warning if younger than")),
+ Age(title = _("Critical if younger than")),
]
)
),
Module: check_mk
Branch: master
Commit: 63ee29d3d47029d214229ffeff5c6a8386e9b36b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=63ee29d3d47029…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Aug 12 14:15:54 2013 +0200
WATO hosts/folders: implemented snmp community config on host/folder base
---
ChangeLog | 2 ++
web/htdocs/wato.py | 38 +++++++++++++++++++++-----------
web/plugins/wato/builtin_attributes.py | 11 +++++++++
3 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 82a0963..4091581 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -122,6 +122,8 @@
requests, queue
* Custom user attributes can now be managed using WATO
* Allow GIT to be used for change tracking (enable via global option)
+ * Hosts/Folders: SNMP communities can now be configured via the host
+ and folders hierarchy. Those settings override the rule base config.
* FIX: do validation of check items in rule editor
* FIX: More consistent handling of folderpath select in rule editor
* Require unique alias names in between the following elements:
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 57860c5..8433cf7 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -572,16 +572,17 @@ def load_hosts_file(folder):
filename = root_dir + folder[".path"] + "/hosts.mk"
if os.path.exists(filename):
variables = {
- "FOLDER_PATH" : "",
- "ALL_HOSTS" : ALL_HOSTS,
- "all_hosts" : [],
- "clusters" : {},
- "ipaddresses" : {},
- "extra_host_conf" : { "alias" : [] },
- "extra_service_conf" : { "_WATO" : [] },
- "host_attributes" : {},
- "host_contactgroups" : [],
- "_lock" : False,
+ "FOLDER_PATH" : "",
+ "ALL_HOSTS" : ALL_HOSTS,
+ "all_hosts" : [],
+ "clusters" : {},
+ "ipaddresses" : {},
+ "explicit_snmp_communities" : {},
+ "extra_host_conf" : { "alias" : [] },
+ "extra_service_conf" : { "_WATO" : [] },
+ "host_attributes" : {},
+ "host_contactgroups" : [],
+ "_lock" : False,
}
execfile(filename, variables, variables)
nodes_of = {}
@@ -610,8 +611,9 @@ def load_hosts_file(folder):
alias = aliases[0]
else:
alias = None
- host["alias"] = alias
- host["ipaddress"] = ipaddress
+ host["alias"] = alias
+ host["ipaddress"] = ipaddress
+ host["snmp_community"] = variables["explicit_snmp_communities"].get(hostname)
# Retrieve setting for each individual host tag
tags = set([ tag for tag in parts[1:] if tag != 'wato' and not tag.endswith('.mk') ])
@@ -675,6 +677,7 @@ def save_hosts(folder = None):
all_hosts = [] # list of [Python string for all_hosts]
clusters = [] # tuple list of (Python string, nodes)
ipaddresses = {}
+ explicit_snmp_communities = {}
hostnames = hosts.keys()
hostnames.sort()
custom_macros = {} # collect value for attributes that are to be present in Nagios
@@ -686,7 +689,8 @@ def save_hosts(folder = None):
host = cleaned_hosts[hostname]
effective = effective_attributes(host, folder)
- ipaddress = effective.get("ipaddress")
+ ipaddress = effective.get("ipaddress")
+ snmp_community = effective.get("snmp_community")
# Compute tags from settings of each individual tag. We've got
# the current value for each individual tag. Also other attributes
@@ -712,6 +716,8 @@ def save_hosts(folder = None):
if ipaddress:
ipaddresses[hostname] = ipaddress
+ if snmp_community:
+ explicit_snmp_communities[hostname] = snmp_community
# Create contact group rule entries for hosts with explicitely set values
# Note: since the type if this entry is a list, not a single contact group, all other list
@@ -754,6 +760,12 @@ def save_hosts(folder = None):
out.write("\n# Explicit IP addresses\n")
out.write("ipaddresses.update(")
out.write(pprint.pformat(ipaddresses))
+ out.write(")\n")
+
+ if len(ipaddresses) > 0:
+ out.write("\n# Explicit SNMP communities\n")
+ out.write("explicit_snmp_communities.update(")
+ out.write(pprint.pformat(explicit_snmp_communities))
out.write(")")
out.write("\n")
diff --git a/web/plugins/wato/builtin_attributes.py b/web/plugins/wato/builtin_attributes.py
index cebcd2a..1d907e7 100644
--- a/web/plugins/wato/builtin_attributes.py
+++ b/web/plugins/wato/builtin_attributes.py
@@ -46,6 +46,17 @@ declare_host_attribute(TextAttribute("ipaddress", _("IP address"),
show_in_table = True,
show_in_folder = False)
+declare_host_attribute(TextAttribute("snmp_community", _("SNMP Community"),
+ _("Using this option you can configure the community which should be used when "
+ "contacting this host via SNMP v1 or v2. It is possible to configure the SNMP community by "
+ "using the <a href=\"%s\">SNMP Communities</a> ruleset, but when you configure "
+ "some community here, this will override the community defined by the rules.") % \
+ html.makeuri([('mode', 'edit_ruleset'), ('varname', 'snmp_communities')]),
+ allow_empty = False),
+ show_in_table = False,
+ show_in_folder = True,
+ depends_on_tags = ['snmp'])
+
# Attribute for configuring parents
class ParentsAttribute(ValueSpecAttribute):
def __init__(self):
Module: check_mk
Branch: master
Commit: 22ae8a767eb67d5230e6272e7547ab627a12ec84
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=22ae8a767eb67d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Aug 12 11:07:52 2013 +0200
WATO: Show inventory hint after creating a host without inventory
---
web/htdocs/wato.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index f71fe1a..57860c5 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2048,7 +2048,15 @@ def mode_edithost(phase, new, cluster):
if errors: # keep on this page if host does not validate
return
elif new:
- return go_to_services and "firstinventory" or "folder"
+ if host.get('tag_agent') != 'ping':
+ create_result = 'folder', _('Successfully created the host. Now you should do an '
+ '<a href="%s">inventory</a> in order to auto-configure '
+ 'all services to be checked on this host.') % \
+ make_link([("mode", "inventory"), ("host", hostname)])
+ else:
+ create_result = 'folder'
+
+ return go_to_services and "firstinventory" or create_result
else:
return go_to_services and "inventory" or "folder"
Module: check_mk
Branch: master
Commit: a622d89f21a2014ca284a36df4245f929ea607b0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a622d89f21a201…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Aug 12 10:45:23 2013 +0200
Updated bug entries #0926
---
.bugs/926 | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/.bugs/926 b/.bugs/926
new file mode 100644
index 0000000..d5bd961
--- /dev/null
+++ b/.bugs/926
@@ -0,0 +1,45 @@
+Title: host_state (and others) are not treated as integers in log table
+Component: livestatus
+State: open
+Date: 2013-08-12 10:45:03
+Targetversion: 1.2.2
+Class: bug
+
+Multisite assumes that columns like the host_state are integers.
+
+
+GET log
+Columns: host_state host_has_been_checked host_name service_max_check_attempts service_description service_current_attempt
+Filter: class = 1
+Stats: state = 0
+Stats: state = 1
+Stats: state = 2
+Stats: state = 3
+Stats: state != 0
+OutputFormat: python
+
+this results in [u"1",u"1",u"win7",u"1",u"Check_MK",u"1",0,0,1,0,1],
+[u"1",u"1",u"win7",u"1",u"Check_MK inventory",u"1",0,0,0,1,1]]
+
+we see host_state and host_has_been_checked and service_max_check_attempts as
+strings which should really be integers.
+
+This host_state results in an exception in views which use the alert statistics
+datasource and have sounds enabled.
+
+Internal error:: u'0'
+
+Traceback (most recent call last):
+ File "/omd/sites/event/share/check_mk/web/htdocs/index.py", line 330, in handler
+ handler()
+ File "/omd/sites/event/share/check_mk/web/htdocs/views.py", line 1118, in page_view
+ show_view(view, True, True, True)
+ File "/omd/sites/event/share/check_mk/web/htdocs/views.py", line 1400, in show_view
+ browser_reload)
+ File "/omd/sites/event/share/check_mk/web/htdocs/views.py", line 1496, in render_view
+ show_checkboxes and not html.do_actions())
+ File "/omd/sites/event/share/check_mk/web/plugins/views/layouts.py", line 121, in render_grouped_boxes
+ register_events(row) # needed for playing sounds
+ File "/omd/sites/event/share/check_mk/web/htdocs/views.py", line 2565, in register_events
+ html.register_event({0:"up", 1:"down", 2:"unreachable"}[host_state])
+KeyError: u'0'