Module: check_mk
Branch: master
Commit: 07d5bda89a096cffe938e0ada14838a055131ef8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=07d5bda89a096c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Jan 8 17:50:02 2012 +0100
Improve check_bi_local.py
---
.bugs/410 | 7 +++++--
ChangeLog | 4 ++++
doc/treasures/check_bi_local.py | 36 ++++++++++++++++++++++++++----------
web/plugins/views/builtin.py | 31 +++++++++++++++++++++++++++++++
4 files changed, 66 insertions(+), 12 deletions(-)
diff --git a/.bugs/410 b/.bugs/410
index 08a82af..c2c0248 100644
--- a/.bugs/410
+++ b/.bugs/410
@@ -1,12 +1,15 @@
Title: BI: make sample local check for monitoring aggregations
Component: bi
+State: done
+Class: todo
Benefit: 3
-State: open
Cost: 2
Date: 2011-10-28 11:15:39
Targetversion:
-Class: todo
A simple local check can connect to Multisite, fetch the current state
of all BI aggregates and output them in the style of a local check.
The admin just needs to add the URL and user/password.
+
+2012-01-08 17:49:09: changed state open -> done
+Sample check is in doc/treasures.
diff --git a/ChangeLog b/ChangeLog
index e2ea348..ad4f67a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -32,6 +32,10 @@
* Added filter for log state (UP,DOWN,OK,CRIT...) to all log views
* New painter for normal and retry check interval (added to detail views)
+ BI:
+ * improve doc/treasures/check_bi_local.py: local check that creates
+ Nagios services out of BI aggregates
+
1.1.13i2:
Core, Setup, etc.:
* cmk -I: accept host tags and cluster names
diff --git a/doc/treasures/check_bi_local.py b/doc/treasures/check_bi_local.py
index ed9ef38..dffb84b 100755
--- a/doc/treasures/check_bi_local.py
+++ b/doc/treasures/check_bi_local.py
@@ -24,18 +24,31 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-#!/usr/bin/python
+# Example for creating real Nagios checks from BI aggregations.
+
+# Installation:
+# 1. Put this file in /usr/lib/check_mk_agent/local
+# 2. Make the file executable
+# 3. Add a correct url_prefix (OMD site and slash)
+# user and password with read access to Multisite.
+
+user = "omdadmin"
+password = "omd"
+url_prefix = "" # non-OMD installations
+# url_prefix = "mysite/" # with OMD site name
-# Example for creating real Nagios checks from BI
-# aggregations. You need to create a view with
-# the name aggr_service with the two columns
-# Aggr State and Aggr Name.
+# Do not change anything below
-import os
+import os, sys
-url =
'http://omdadmin:omd@localhost/bi/check_mk/view.py?view_name=aggr_webservice&output_format=python'
+url =
'http://%s:%s@localhost/%scheck_mk/view.py?view_name=aggr_summary&output_format=python'
% \
+ (user, password, url_prefix)
-data = eval(os.popen("curl --silent '%s'" % url).read())
+try:
+ data = eval(os.popen("curl --silent '%s'" % url).read())
+except:
+ sys.stderr.write("Invalid output from URL %s\n" % url)
+ sys.exit(1)
states = {
"OK" : 0,
@@ -44,9 +57,12 @@ states = {
"UNKNOWN" : 3,
}
-for state, name in data[1:]:
+for name, state, output in data[1:]:
state_nr = states.get(state, -1)
descr = "BI_Aggr_" + name.replace(" ", "_")
if state_nr != -1:
- print "%d %s - %s" % (state_nr, descr, state)
+ text = "%d %s - %s" % (state_nr, descr, state)
+ if output:
+ text += " - " + output
+ print text
diff --git a/web/plugins/views/builtin.py b/web/plugins/views/builtin.py
index d4cd442..d07eba8 100644
--- a/web/plugins/views/builtin.py
+++ b/web/plugins/views/builtin.py
@@ -2471,6 +2471,37 @@ multisite_builtin_views.update({
'topic': u'Business Intelligence',
'user_sortable': None},
+# Summary of all aggregations for usage as web services
+'aggr_summary': {'browser_reload': 0,
+ 'column_headers': 'off',
+ 'datasource': 'bi_aggregations',
+ 'description': u'Simple summary page of all BI aggregates
that is used as a web services.',
+ 'group_painters': [],
+ 'hard_filters': [],
+ 'hard_filtervars': [],
+ 'hidden': True,
+ 'hide_filters': [],
+ 'hidebutton': True,
+ 'icon': None,
+ 'layout': 'boxed',
+ 'linktitle': u'BI Aggregations Summary State',
+ 'mobile': False,
+ 'mustsearch': False,
+ 'name': 'aggr_summary',
+ 'num_columns': 1,
+ 'painters': [('aggr_name', None, ''),
+ ('aggr_state', None, ''),
+ ('aggr_output', None, '')],
+ 'play_sounds': False,
+ 'public': False,
+ 'show_checkboxes': None,
+ 'show_filters': [],
+ 'sorters': [],
+ 'title': u'BI Aggregations Summary State',
+ 'topic': u'Business Intelligence',
+ 'user_sortable': 'on'},
+
+
# +----------------------------------------------------------------------+
# | _ _ _ _ __ _ _ _ |
# | | \ | | ___ | |_(_)/ _(_) ___ __ _| |_(_) ___ _ __ ___ |