Using new NagVis in Nagios XI

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Using new NagVis in Nagios XI

Post by SteveBeauchemin »

Nagios XI comes with NagVis pre-installed. To get the latest version in place these are the steps I took. I ended up with NagVis 1.8.5 in Nagios XI.
Start by getting livestatus installed. The NagVis tool uses multiple back-ends for the data it presents, but I am only using livestatus.

To setup livestatus, download, compile, and install it. (The newest stable version I saw was 1.8.5)
Find the latest stable version number from here
https://mathias-kettner.de/check_mk_dow ... p?HTML=yes
download the mk_livestatus 'Stable' version number from here
https://mathias-kettner.de/download/
Extract the files using tar -xzvf [filename] and then cd to the location
To compile and install you need to tell Livestatus the version of Nagios core in Nagios XI
Tell the configure command to use Nagios version 4

Code: Select all

./configure --with-nagios4
make
make install
The livestatus.o file ends up in /usr/local/lib/mk-livestatus by default. That file is the NEB module. Add to the nagios.cfg file as shown. The broker_module should all be a single line and not wrapped.

Code: Select all

vi /usr/local/nagios/etc/nagios.cfg
# livestatus module
broker_module=/usr/local/lib/mk-livestatus/livestatus.o /usr/local/nagios/var/rw/live pnp_path=/usr/local/nagios/share/perfdata
If you want to be able to query livestatus from remote machines you can have xinetd make it available. Research the LQL - The Livestatus Query Language and you decide. Nagios XI 5 JSON may be better for your custom code. This is how it can be used from remote. There is more to livestatus and LQL and it can be useful, but this is about NagVis and livestatus just needs to run as a NEB. I could go on...

Code: Select all

vi /etc/xinetd.d/livestatus
service livestatus
{
        type            = UNLISTED
        port            = 6557
        socket_type     = stream
        protocol        = tcp
        wait            = no
# limit to 100 connections per second. Disable 3 secs if above.
        cps             = 100 3
# set the number of maximum allowed parallel instances of unixcat.
# Please make sure that this values is at least as high as
# the number of threads defined with num_client_threads in
# etc/mk-livestatus/nagios.cfg
        instances       = 500
# limit the maximum number of simultaneous connections from
# one source IP address
        per_source      = 250
# Disable TCP delay, makes connection more responsive
        flags           = NODELAY
        user            = nagios
        server          = /usr/local/bin/unixcat
        server_args     = /usr/local/nagios/var/rw/live
# configure the IP address(es) of your Nagios server here:
        only_from       = 127.0.0.1 [b]add space delimited IP addresses here[/b]
        disable         = no
}

Code: Select all

service restart xinetd
Okay, now that livestatus is available, NagVis needs to be upgraded. Backup your current NagVis in case you encounter problems and need to revert.

Code: Select all

tar -czvf /tmp/nagvis-backup.tar.gz /usr/local/nagvis
Download the NagVis install file, extract it, and run the upgrade/install.

Code: Select all

tar -xzvf nagvis-1.8.5.tar.gz
cd nagvis-1.8.5
./install.sh
Answer each question carefully.
Now you are upgraded and the configuration fun begins.
Post Upgrade tasks
Change the NagVis ini file and make sure these values exist in the sections shown. These are the changes I use. Some are already in place. Verify them.

Code: Select all

vi /usr/local/nagvis/etc/nagvis.ini.php
[global]
file_group="nagios"
file_mode=664

logonmodule="LogonEnv"
logonenvvar="PHP_AUTH_USER"
logonenvcreateuser=1
logonenvcreaterole="Guests"

[paths]
htmlcgi="/nagiosxi/includes/components/xicore"

[defaults]
backend="live_1"
eventsound=0
onlyhardstates=1
hosturl="[htmlcgi]/status.php?host=[host_name]"
hostgroupurl="[htmlcgi]/status.php?show=services&hostgroup=[hostgroup_name]"
serviceurl="[htmlcgi]/status.php?show=servicedetail&host=[host_name]&service=[service_description]&dest=auto"
servicegroupurl="[htmlcgi]/status.php?show=services&servicegroup=[servicegroup_name]"

[backend_live_1]
backendtype="mklivestatus"
socket="unix:/usr/local/nagios/var/rw/live"
custom_1="/nagiosxi/includes/components/nagioscore/ui"
custom_2="/nagiosxi/includes/components/xicore"
Initially, after the upgrade, the Javascript complained bitterly. Turns out it was cached and needed refresh. In the GUI - I had to tell the frame to reload - removing old cache data, using Chrome - shift right-click reload frame. And all my Maps and content were still there. Any Javascript errors are cache related, or map related. If you cannot get past a page, use an editor to look at the map content. Or remove the offending file from the maps directory. I typically move files from /usr/local/nagvis/etc/maps to /tmp to remove them from the maps directory, and if the problem goes away I know what file to edit.

We use a specific map as a default home page on NagVis startup.

Code: Select all

cd /usr/local/nagiosxi/html/includes/components/nagvis
vi nagvis.inc.php
//"href" => '/nagvis/',
"href" => '/nagvis/frontend/nagvis-js/index.php?mod=Map&act=view&show=[My Preferred Startup Map]',
This gets us the startup page for NagVis that we prefer.

I work as the nagios user, so I needed to change some file permissions that would let me edit the maps using vi. Sometimes I find it easier to copy and change files to add new maps. Sometimes I fix problems that the GUI hides.

In order for the Nagios User to be able to edit map configuration files - you may need other permission changes...

Code: Select all

chown -R apache:nagios /usr/local/nagvis/etc/maps
chmod 775 /usr/local/nagvis/etc/maps
chmod 664 /usr/local/nagvis/etc/maps/*
chmod u+s,g+s /usr/local/nagvis/etc/maps

chown -R apache:nagios /usr/local/nagvis/share/userfiles
chmod 775 /usr/local/nagvis/share/userfiles
chmod 775 /usr/local/nagvis/share/userfiles/*
chmod 664 /usr/local/nagvis/share/userfiles/templates/*
chmod u+s,g+s /usr/local/nagvis/share/userfiles

chmod 755 /var/log/httpd
chmod 644 /var/log/httpd/*
In order to be able to change admin rights, make sure to copy the special script to /usr/local/nagvis/etc as stated in the NagVis FAQ. The file is named nagvis-make-admin.sh and if you lose admin rights in NagVis, you can reclaim them.

Code: Select all

cd /usr/local/nagvis/etc
sh nagvis-make-admin.sh [username]
In the code above for nagvis.ini.php I created some variables named custom_#...
In NagVis, if you right-click items, you get a context menu to perform operations. They are by default set to work with Nagios cgi modules from the old version. To get them working, I found the templates directory and made a couple changes. In the template directory, copy a default file, and make some changes.

Code: Select all

cd /usr/local/nagvis/share/userfiles/templates
cp default.context.html vi default-xi.context.html
vi default-xi.context.html

The file name extensions need to stay consistent, but the first part of the name can change. I am attaching the template I created named default-xi.context.html which now allows right click selections to work in NagVis. I added a couple more commands to the menu that I find useful. In the file you will see custom_1 which is defined in the ini file above. Now that the new context file exists, you will see default-xi as an option in the NagVis menus. Launch NagVis and the context menu can be set for everything globally, or map by map, or object by object.

Code: Select all

(not really code, but close enough) - Launch NagVis
To set for ALL objects start with Menu - Open -> Overview
Options -> General Configuration
Object Defaults Tab
 - contextmenu - yes
  - contecttemplate - default  - can change to default-xi

To set in an individual Map start with Menu - Edit Map -> Map Options
 - contextmenu - yes
  - contecttemplate - default  - can change to default-xi

Or edit the map and right-click modify an object to see the same contextmenu choices.
---
EDIT 1 Note: It seems that the template does not like being used at the global level. So I had to assign it to each map.
In the map directory
find each cfg file and add a new line after "define global" (which is the top line)
The new line shall be "context_template=default-xi"

Code: Select all

cd /usr/local/nagvis/etc/maps
find ./*.cfg -type f -exec sed -i '/define global/a context_template=default-xi' {} +
This changed all the map cfg files, added a new line 2, and now the right-click menu is good.
end EDIT 1
---
You never realize how much work something is until you write it all down after you are finished.

I hope this help folks get through the installation fun. Feel free to use this as you like.

Thanks and enjoy. (remember - context file is attached)

Steve B
You do not have the required permissions to view the files attached to this post.
Last edited by SteveBeauchemin on Tue Jan 12, 2016 11:54 am, edited 1 time in total.
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Using new NagVis in Nagios XI

Post by tmcdonald »

We're at the end of our day so I won't have time to read through until tomorrow, but this looks solid!

One thing I need to point out, and I hate having to say this, is that we technically cannot support/guarantee a system that is running a newer NagVis version. If we start distributing XI with the newest NagVis that's a different story, but at the time of this writing the above steps will put your system in an unsupportable state.

We'll get around to testing this when we can carve out some time, and if the developers agree we'll see about getting the latest running with stock XI installs.
Former Nagios employee
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Using new NagVis in Nagios XI

Post by SteveBeauchemin »

Trevor,

I only added this as I thought I saw folks on the forum asking about it a while back. I do understand about the support aspect.

For what it's worth, I have run the new version for a long time with the only user complaint being that the authentication method requires an additional login to access NagVis. If nothing else good comes from my post, at least folks can fix their broken right click in NagVis now from the template I included.

Thanks

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Using new NagVis in Nagios XI

Post by WillemDH »

One thing I need to point out, and I hate having to say this, is that we technically cannot support/guarantee a system that is running a newer NagVis version. If we start distributing XI with the newest NagVis that's a different story, but at the time of this writing the above steps will put your system in an unsupportable state.
I'm really looking forward to the day it will be officially supported. Thanks Steve for your contributions!
Nagios XI 5.8.1
https://outsideit.net
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Using new NagVis in Nagios XI

Post by hsmith »

I'm looking forward to it as well, it seems to be a pretty nice upgrade to the project. I am not sure where exactly it is on the development timeline, but I know it has been looked into.
Former Nagios Employee.
me.
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Using new NagVis in Nagios XI

Post by SteveBeauchemin »

You can lock this too. The data is here for those who dare the bleeding edge...
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
Locked