NagVis, which in NetEye 4 is called the “Maps” Application, is a visualization add-on for the well-known network management system Nagios® and Icinga. NagVis can visualize monitoring status data as objects overlaid on maps to display them in different layouts:
So in general, NagVis (Maps) is a presentation tool for information gathered in NetEye by Icinga 2 and transferred using a backend based on the NDomy Interface of Icinga2.
Now NagVis has a feature called Custom Context Templates where you can define context menus (right click menus) for the objects on the maps. The default context menu is the file default.context.html, and on NetEye it’s located at /neteye/shared/nagvis/data/share/userfiles/templates/default.context.html.
This context template uses a feature called “Custom Context Menu Actions” which is unfortunately implemented only inside the “livestatus” Backend, and is thus not available when using the NDomy Frontend as used in NetEye. For this to work you have to patch the file:
/neteye/shared/nagvis/data/share/server/core/classes/GlobalBackendPDO.php
Using this patch:
--- /neteye/shared/nagvis/data/share/server/core/classes/GlobalBackendPDO.php.orig 2023-12-15 15:10:01.544232457 +0100
+++ /neteye/shared/nagvis/data/share/server/core/classes/GlobalBackendPDO.php 2024-12-19 11:50:17.000000000 +0100
@@ -459,7 +459,7 @@
$filter = $this->parseFilter($objects, $filters, 'o', 'o', $isMemberQuery, false, HOST_QUERY);
$QUERYHANDLE = $this->DB->query('SELECT
- o.object_id, alias, display_name, address, o.name1,
+ o.object_id AS object_id, alias, display_name, address, o.name1,
has_been_checked,
last_hard_state,
UNIX_TIMESTAMP(last_hard_state_change) AS last_hard_state_change,
@@ -549,14 +549,6 @@
}
}
+ $custom_keys = array();
+ $custom_vals = array();
+ $Q2HANDLE = $this->DB->query('SELECT varname, varvalue FROM icinga_customvariables WHERE object_id='.$data['object_id']);
+ while($dt2 = $Q2HANDLE->fetch()) {
+ array_push($custom_keys, $dt2['varname']);
+ array_push($custom_vals, $dt2['varvalue']);
+ }
+ $custom_vars = array_combine($custom_keys, $custom_vals);
$arrReturn[$data['name1']] = array(
$state,
$output,
@@ -576,7 +568,7 @@
$data['address'],
$data['notes'],
$data['check_command'],
- null, // custom_vars
+ $custom_vars, // custom_vars
$dt_details[0], // downtime author
$dt_details[1], // downtime comment
$dt_details[2], // downtime start
Using this patch now (only) host custom variables are transferred to NagVis and can be used in the custom action definitions. These definitions are used in the context templates like this:
<!-- BEGIN action_ssh_url -->
<li><a href="ssh://[address]/">[lang_action_ssh]</a></li>
<!-- END action_ssh_url -->
and the action is defined inside a global configurations file which can be put into the directory:
/neteye/shared/nagvis/conf/conf.d
and can look like this:
; Adds the action "connect via ssh" to service/host objects which have the
; custon_variable has_ssh set to true. Is only added when NagVis
; detects that the client watching the map uses linux or mac os.
; When clicking on the link, the browser opens the URL ssh://<address>/,
; you need to configure your clients browser to handle these urls correctly.
[action_ssh_url]
action_type="ssh_url"
obj_type="host,service"
client_os="win,mac,lnx"
condition="has_ssh~true"
Please note that has_ssh is a Host-Custom-Variable and client_os is set from your Client Browser to the Operating System that the Browser runs on. So if you work on a Windows Client it is set to “win”.
All this now lets you open a context menu by right clicking on your Host Object on a map, as long as you have an ssh entry link inside the menu where the host to which the Host-Object points to has a custom-variable has_ssh set to TRUE.
I hope this helps you better understand how this feature works, as I had problems myself understanding how to make it work solely by reading the NagVis documentation.
Did you find this article interesting? Does it match your skill set? Our customers often present us with problems that need customized solutions. In fact, we’re currently hiring for roles just like this and others here at Würth Phoenix.