Module: check_mk
Branch: master
Commit: 913ca325c0c286aedad1e08e0172c7a7841b82d1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=913ca325c0c286…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Mon Mar 31 16:53:53 2014 +0200
Added a simple icon to show links to navis maps. (located in treasures/nagvis_icon)
---
doc/treasures/nagvis_icon/nagvis_icon.mk | 18 ++++++++++++++++++
doc/treasures/nagvis_icon/nagvis_icon.py | 16 ++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/doc/treasures/nagvis_icon/nagvis_icon.mk
b/doc/treasures/nagvis_icon/nagvis_icon.mk
new file mode 100644
index 0000000..9ac6056
--- /dev/null
+++ b/doc/treasures/nagvis_icon/nagvis_icon.mk
@@ -0,0 +1,18 @@
+#This config file adds the name of each nagvis map contaning a host as custom macro.
+#The information is used for the nagvis_icon.py to show a nagvis icon in the gui
+
+# Just place this file to check_mk/conf.d
+
+_path = '/omd/sites/%s/etc/nagvis/maps/*.cfg' % omd_site
+_hosts = {}
+for _nm in glob.glob(_path):
+ _mapname = _nm.split("/")[-1].split('.')[0]
+ for _nhost in [ _l for _l in file(_nm).readlines() if
_l.startswith('host_name')]:
+ _nhost = _nhost.split('=')[-1].strip()
+ _hosts.setdefault(_nhost, [])
+ _hosts[_nhost].append(_mapname)
+
+extra_host_conf['_nagvismaps'] = []
+for _nhost, _maps in _hosts.items():
+ extra_host_conf['_nagvismaps'].append( ( ",".join(_maps), [_nhost]
) )
+
diff --git a/doc/treasures/nagvis_icon/nagvis_icon.py
b/doc/treasures/nagvis_icon/nagvis_icon.py
new file mode 100644
index 0000000..2d7dff2
--- /dev/null
+++ b/doc/treasures/nagvis_icon/nagvis_icon.py
@@ -0,0 +1,16 @@
+#!/usr/bin/python
+# Please refer to nagvis_icon.mk to see a way how to add the nagvismaps custom macro
+
+def paint_nagvis_image(what, row, tags, custom_vars):
+ if what != 'host' or not custom_vars.get('NAGVISMAPS'):
+ return
+ h = ""
+ for nagvis_map in custom_vars['NAGVISMAPS'].split(','):
+ h += '<a
href="../nagvis/frontend/nagvis-js/index.php?mod=Map&act=view&show=%s"
title="%s"><img class=icon
src="images/icon_nagvis.png"/></a>' \
+ % ( nagvis_map, nagvis_map )
+
+ return h
+
+multisite_icons.append({
+ 'paint': paint_nagvis_image,
+})