Using new NagVis in Nagios XI
Posted: Mon Jan 11, 2016 6:06 pm
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
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.
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...
Okay, now that livestatus is available, NagVis needs to be upgraded. Backup your current NagVis in case you encounter problems and need to revert.
Download the NagVis install file, extract it, and run the upgrade/install.
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.
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.
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...
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.
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.
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.---
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"
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
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 installCode: 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
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 xinetdCode: Select all
tar -czvf /tmp/nagvis-backup.tar.gz /usr/local/nagvisCode: Select all
tar -xzvf nagvis-1.8.5.tar.gz
cd nagvis-1.8.5
./install.sh
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"
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]',
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/*
Code: Select all
cd /usr/local/nagvis/etc
sh nagvis-make-admin.sh [username]
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' {} +
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