Author:   Lars Michelsen <[email protected]>
Date:     Wed Nov 19 10:39:47 2014 +0100
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Wed Nov 19 10:39:47 2014 +0100

Taggroups, values and their titles can now be used to be displayed in hover menu

---

 ChangeLog                                          |    2 +
 docs/en_US/hover_templates.html                    |   28 ++++++++++++++++++++
 share/frontend/nagvis-js/js/hover.js               |   14 ++++++++++
 .../core/classes/objects/NagVisStatefulObject.php  |   13 ++++++---
 share/userfiles/templates/default.hover.html       |    1 +
 5 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3760150..e885bd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,8 @@ Core:
 
 Frontend:
   * Service-/Hosttags are shown in default hover template now (when available)
+  * Taggroups, values and their titles can now be used to be displayed in 
hover menu
+    (When using NagVis in an OMD environment together with Check_MK 1.2.5i6p4 
or newer)
   * FIX: Background images could not be deleted
   * FIX: Natural sorting object names in add/modify dialog
 
diff --git a/docs/en_US/hover_templates.html b/docs/en_US/hover_templates.html
index c64039f..42302e2 100644
--- a/docs/en_US/hover_templates.html
+++ b/docs/en_US/hover_templates.html
@@ -191,6 +191,34 @@
                 is fully available with this macro. This is available, for 
example, for all hosts
                 configured with CheckMK. <font color="#ff0000">(New in 
1.8rc1)</font></td>
         </tr>
+        <tr>
+            <td>[obj_taggroup_&lt;group_id&gt;_title]</td>
+            <td>When using NagVis together with Check_MK (version 1.2.5i6p4 or 
newer) in an OMD environment, you can use
+                this macro to display tag and taggroup related information in 
hover menus.
+                This macro can be used to display the title of a taggroup 
matching the given
+                group_id. <font color="#ff0000">(New in 1.8rc1)</font></td>
+        </tr>
+        <tr>
+            <td>[obj_taggroup_&lt;group_id&gt;_topic]</td>
+            <td>When using NagVis together with Check_MK (version 1.2.5i6p4 or 
newer) in an OMD environment, you can use
+                this macro to display tag and taggroup related information in 
hover menus.
+                This macro can be used to display the tag group topic of the 
taggroup
+                matching the given group_id. <font color="#ff0000">(New in 
1.8rc1)</font></td>
+        </tr>
+        <tr>
+            <td>[obj_taggroup_&lt;group_id&gt;_value]</td>
+            <td>When using NagVis together with Check_MK (version 1.2.5i6p4 or 
newer) in an OMD environment, you can use
+                this macro to display tag and taggroup related information in 
hover menus.
+                This macro can be used to display the raw value, means the 
choosen tag, of a taggroup
+                matching the given group_id. <font color="#ff0000">(New in 
1.8rc1)</font></td>
+        </tr>
+        <tr>
+            <td>[obj_taggroup_&lt;group_id&gt;_value_title]</td>
+            <td>When using NagVis together with Check_MK (version 1.2.5i6p4 or 
newer) in an OMD environment, you can use
+                this macro to display tag and taggroup related information in 
hover menus.
+                This macro can be used to display the title of the choosen 
tag, of a taggroup
+                matching the given group_id. <font color="#ff0000">(New in 
1.8rc1)</font></td>
+        </tr>
         </table>
         
         <h3> Service objects </h3>
diff --git a/share/frontend/nagvis-js/js/hover.js 
b/share/frontend/nagvis-js/js/hover.js
index e55919d..3895708 100644
--- a/share/frontend/nagvis-js/js/hover.js
+++ b/share/frontend/nagvis-js/js/hover.js
@@ -259,6 +259,20 @@ function replaceHoverTemplateStaticMacros(oObj, 
sTemplateCode) {
     if(oObj.conf.type === 'host' || oObj.conf.type === 'service') {
         oMacros.obj_address = oObj.conf.address;
         oMacros.obj_tags    = oObj.conf.tags.join(', ');
+
+        // Add taggroup information
+        for (var group_id in oObj.conf.taggroups) {
+            var group = oObj.conf.taggroups[group_id];
+            oMacros['obj_taggroup_' + group_id + '_title'] = group.title;
+            oMacros['obj_taggroup_' + group_id + '_topic'] = group.topic;
+            if (group.value) {
+                oMacros['obj_taggroup_' + group_id + '_value']       = 
group.value[0];
+                oMacros['obj_taggroup_' + group_id + '_value_title'] = 
group.value[1];
+            } else {
+                oMacros['obj_taggroup_' + group_id + '_value']       = '';
+                oMacros['obj_taggroup_' + group_id + '_value_title'] = '';
+            }
+        }
     } else {
         oMacros.obj_address = '';
         oMacros.obj_tags    = '';
diff --git a/share/server/core/classes/objects/NagVisStatefulObject.php 
b/share/server/core/classes/objects/NagVisStatefulObject.php
index 26eebe9..376fc32 100644
--- a/share/server/core/classes/objects/NagVisStatefulObject.php
+++ b/share/server/core/classes/objects/NagVisStatefulObject.php
@@ -363,10 +363,15 @@ class NagVisStatefulObject extends NagVisObject {
 
             // Now, to be very user friendly, we now try to use the Check_MK 
WATO php-api to gather
             // titles and grouping information of the tags. These can, for 
example, be used in the hover
-            // templates
-            //if ($arr['tags']) {
-            //    
-            //}
+            // templates. This has been implemented to only work in OMD 
environments.
+            $arr['taggroups'] = array();
+            if ($arr['tags'] && isset($_SERVER['OMD_ROOT'])) {
+                $path = $_SERVER['OMD_ROOT'] . 
'/var/check_mk/wato/php-api/hosttags.php';
+                if (file_exists($path)) {
+                    require_once($path);
+                    $arr['taggroups'] = all_taggroup_choices($arr['tags']);
+                }
+            }
 
             $arr['downtime_author'] = val($this->state, DOWNTIME_AUTHOR);
             $arr['downtime_data']   = val($this->state, DOWNTIME_DATA);
diff --git a/share/userfiles/templates/default.hover.html 
b/share/userfiles/templates/default.hover.html
index 13390d4..23b77e2 100644
--- a/share/userfiles/templates/default.hover.html
+++ b/share/userfiles/templates/default.hover.html
@@ -6,6 +6,7 @@
     <!-- END service -->
     <!-- BEGIN has_tags -->
     <tr><td 
class="label"><label>[lang_tags]</label></td><td>[obj_tags]</td></tr>
+    <tr><td 
class="label"><label>[obj_taggroup_criticality_title]</label></td><td>[obj_taggroup_criticality_value_title]
 ([obj_taggroup_criticality_value])</td></tr>
     <!-- END has_tags -->
     <!-- BEGIN host -->
     <tr><td class="label label[obj_state]"><label>[lang_state]</label></td><td 
class="state[obj_state]">[obj_state] 
[obj_in_downtime][obj_acknowledged][obj_stale] ([obj_state_type] - 
[obj_current_check_attempt]/[obj_max_check_attempts])</td></tr>


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to