NagVis : Cartographier son architecture avec ses alertes nagios

From / Bloc Notes Informatique
Jump to: navigation, search

1 Introduction

NagVis is a really great product, easy to use but not to install. That's why I did this documentation. You also need to install NDOUtils. We'll see the installation too.

2 NDOUtils

2.1 Prepair System

Make sure your System meets the requirements:

  • Nagios v2.X (stable) is running
  • mysql (Version > 4)

2.2 Download NDOUtils

You can get the latest version of NDOUtils on the Nagios website

2.3 Unpack NDOUtils

Unpack NDOUtils in a path of your choice

tar xvzf tar ndoutils-1.4.tar.gz

You should have at least the following files and directories:

  • Config: This directory contains all the configuration file of NDOUtils.
  • db: This directory contains all the sql information to install or upgrade the mysql database.
  • docs: This directory contains the technical documentation of NDOUtils.
  • Include: This directory contains all the libraries.
  • src: This directory contains the source code.
  • configure: This file will be use to compile the program

2.4 Compiling NDOUtils

Use the following commands to compile the NDO broker module, NDO2DB daemon, and additional utilities:


After the compilation open the config.log file and take care that there’s no failed status inside. If there is some failed status it’s probably because you don’t have all the libraries installed in your C compiler. Install it and recompile it.
Note :

tail config.log

2.5 Initializing the SQL Database

You have to create a database for storing the data.

mysql -u root -p
Enter password: 
Mysql> CREATE DATABASE nagios; 

You also have to create a specific user for nagios with the rights: SELECT, INSERT, UPDATE, and DELETE.

mysql -u root -p
Enter password: 

Then now you can run the DB installation script in the db/ subdirectory.

cd db

Make sure the script create the tables in the database (use phpmyadmin for exemple)

2.6 Configuration

Sample config files are included in the config/ subdirectory. You have 2 files to modify:

  • Ndomod.cfg, you have to change and uncomment the following lines :

Feel free to change the other parameters according to your configuration.

  • Ndo2db.cfg, you have to change and uncomment the following lines :

Feel free to change the other parameters according to your configuration.

  • There is another file to modify: Nagios.cfg . This file is located in the /etc/nagios/ directory. You have to enable the event_broker_option like this :
#broker_module=/somewhere/module2.o arg1 arg2=3 debug=0
broker_module=/usr/lib/nagios/ndoutils/ndomod.o config_file=/etc/nagios2/ndomod.cfg

2.7 Installation

To install the script you have to copy files compiled and the configuration files in the right directories.

mkdir /usr/lib/nagios/ndoutils/
cp ./src/ndomod-2x.o /usr/lib/nagios/ndoutils/ndomod.o
cp ./src/ndo2db-2x /usr/lib/nagios/ndoutils/ndo2db
cp. /src/file2sock /usr/lib/nagios/ndoutils/file2sock
cp. /src/log2ndo /usr/lib/nagios/ndoutils/log2ndo

2.8 Getting Things Running

Start the NDO2DB daemon:

/usr/lib/nagios/ndoutils/ndo2db -c /etc/nagios2/ndo2db.cfg

Start or restart nagios if is already running:

/etc/init.d/nagios2 restart

Check the Nagios logs to make sure it started okay:

vi /var/log/nagios2

You should some entries in the database. If you want that the NDO2DB start at the system, you have to create a script.

3 NagVis

3.1 Prepair System

Make sure your System meets the requirements:

  • Nagios v2.X is running and authentication is configured (.htaccess file placed and configured properly!)
  • NDOUtils v1.X is installed and worked (
  • Working PHP installation (Version > 4.2.0) with "php-gd" support
  • php-mysql support is needed for the strongly recommended "ndomy" backend

3.2 Download NagVis

You can get the latest version of Nagvis on the Nagvis’ website.

3.3 Unpack NagVis

Unpack NagVis in a path of your choice

tar xvzf nagvis-1.2.x.tar.gz

You should have the following files :

  • etc : This directory contain configuration file and demo Map.
  • nagvis : This directory contain all the templates, images and functions of Nagvis.
  • wui : This directory contain all Ajax functionalities (to configure map)
  • Config.php : This file is used to configure maps.
  • Index.php : This will be the index of Nagvis.

3.4 Move NagVis

Place the NagVis directory tree (with etc, nagvis, wui, config.php and index.php inside) into your Nagios share folder.

mv nagvis /usr/share/nagios2/htdocs/

3.5 Configure

Move to new NagVis directory

cd /usr/share/nagios2/htdocs/nagvis

An example for the configuration file can be found in etc/nagvis.ini.php-sample. Copy this example to nagvis/etc/nagvis.ini.php.

cp etc/nagvis.ini.php-sample etc/nagvis.ini.php

Now you can edit this file with your favorite text editor:

vi etc/nagvis.ini.php

The most lines in the fresh copied config.ini.php are commented out. If you want to set different settings, than there are set, uncomment the line and change the value of it. Edit the following lines :

; absolute physical NagVis path
; absolute html NagVis path
; absolute html NagVis cgi path
; hostname for NDO-db
dbhost="localhost"	<- The hostname of your database host
; portname for NDO-db
dbport=3306	<- The port of listened by your database
; database-name for NDO-db
dbname="nagios"	<- The name of your database
; username for NDO-db
dbuser="nagios"	<- The login
; password for NDO-db
dbpass="nagios"	<- The password
; prefix for tables in NDO-db
dbprefix="nagios_"	<- The prefix of your tables
; path to the cgi-bin of this backend

3.6 Permissions

First check which user the webserver is running with (In my case it is www-data). If you don't know which user the webserver is running on have a look at the webservers configuration. In case of apache you can do this by the following command:

grep -e '^User' /etc/apache2/httpd.conf

If your configuration file is located in another path you should correct this in the command above. The set the permissions to your NagVis directory (In my case the path are like this):

chown www-data. /usr/share/nagios2/htdocs/nagvis -R
chmod 664 /usr/share/nagios2/htdocs/nagvis/etc/nagvis.ini.php
chmod 775 /usr/share/nagios2/htdocs/nagvis/nagvis/images/maps
chmod 664 /usr/share/nagios2/htdocs/nagvis/nagvis/images/maps/*
chmod 775 /usr/share/nagios2/htdocs/nagvis/etc/maps
chmod 664 /usr/share/nagios2/htdocs/nagvis/etc/maps/*

It's possible to set lower permissions on the files, in my setup it's ok like this. Only change them if you know, what you are doing.

3.7 The WUI

NagVis has an included web based config tool called WUI. If you want to use it use your browser to open the page:


Hint: If you have some script or popup blockers, disable them for the WUI.
When you see the NagVis image, right click on it, a context menu should open, now you can configure NagVis and create maps with the WUI . The Config Tools DOES NOT display the current Nagios States of Objects configured. Its only for configuring! To "use" your configured Maps afterwards, see STEP 7!

If this does't work for you, or if you don't want to use the WUI, you can simply edit the map config files in the nagvis/etc/maps/ directory with your favorite text editor. For valid format and values have a look at Map Config Format Description on (

3.8 Watch the Maps

You should now be able to watch your defined maps in your browser:


4 Resources