How To Install Nagios Server Monitoring and NAgVis On Ubuntu
How To Install Nagios Server Monitoring and NAgVis On Ubuntu
Root/Sudo access
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagios,nagcmd www-data
Installing Nagios
Step 1 - Download and extract the Nagios core
cd ~
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz
tar -xzf nagios*.tar.gz
cd nagios-4.2.0
Before you build Nagios, you will have to configure it with the user and the group
you have created earlier.
make all
sudo make install
sudo make install-commandmode
sudo make install-init
sudo make install-config
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-
available/nagios.conf
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
After the installation phase is complete, you can find the default configuration of
Nagios in /usr/local/nagios/.
vim /usr/local/nagios/etc/nagios.cfg
cfg_dir=/usr/local/nagios/etc/servers
mkdir -p /usr/local/nagios/etc/servers
The Nagios contact can be configured in the contact.cfg file. To open it use:
vim /usr/local/nagios/etc/objects/contacts.cfg
Configuring Apache
Step 1 - enable Apache modules
You can use the htpasswd command to configure a user nagiosadmin for the nagios
web interface
cd /etc/init.d/
cp /etc/init.d/skeleton /etc/init.d/nagios
vim /etc/init.d/nagios
DESC="Nagios"
NAME=nagios
DAEMON=/usr/local/nagios/bin/$NAME
DAEMON_ARGS="-d /usr/local/nagios/etc/nagios.cfg"
PIDFILE=/usr/local/nagios/var/$NAME.lock
vim /etc/nagios/nrpe.cfg
server_address=192.168.1.9
ssh [email protected]
Then create a new file for the host configuration in /usr/local/nagios/etc/servers/.
vim /usr/local/nagios/etc/servers/ubuntu_host.cfg
define host {
use linux-server
host_name ubuntu_host
alias Ubuntu Host
address 192.168.1.10
register 1
}
define service {
host_name ubuntu_host
service_description PING
check_command check_ping!100.0,20%!500.0,60%
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Check Users
check_command check_local_users!20!50
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Local Disk
check_command check_local_disk!20%!10%!/
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Check SSH
check_command check_ssh
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Total Process
check_command check_local_procs!250!400!RSZDT
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Open the Nagios server from the browser and see the ubuntu_host being monitored.
Conclusion
Nagios is an open source application for monitoring a system. Nagios has been widely
used because of the ease of configuration. Nagios in support by various plugins, and
you can even create your own plugins. Look here for more information.
NagVis is a visualization addon for the well known network managment system
Nagios and Icinga. NagVis can be used to visualize Nagios Data, e.g. to display IT
processes like a mail system or a network infrastructure.
We already have shown you how to install icinga on ubuntu in our previous articles.
In this how-to let us learn how to install NagVis add-on that can be used to visualize
Icinga data details.
I assume that you have already installed and configured Icinga and its working well.
First of all, switch to root user, so that we don’t have to put ‘sudo’ in-front of every
command:
$ su
Download NagVis
Download the latest version of NagVis here or just the following command to
download:
# wget http://sourceforge.net/projects/nagvis/files/NagVis
%201.7/nagvis-1.7.9.tar.gz
The above command will extract nagvis tarball in your current directory. Change to
nagvis directory:
# cd nagvis-1.7.9
Sample Output:
+--------------------------------------------------------------------
----------+
| Welcome to NagVis Installer
1.7.9
|
+--------------------------------------------------------------------
----------+
| This script is built to facilitate the NagVis installation and
update |
| procedure for you. The installer has been tested on the following
systems: |
| - Debian, since Etch
(4.0)
|
| - Ubuntu, since Hardy
(8.04)
|
| - SuSE Linux Enterprise Server 10 and
11
|
|
|
| Similar distributions to the ones mentioned above should work as
well. |
| That (hopefully) includes RedHat, Fedora, CentOS,
OpenSuSE |
|
|
| If you experience any problems using these or other distributions,
please |
| report that to the NagVis
team.
|
+--------------------------------------------------------------------
----------+
| Do you want to proceed? [y]: <-------- Press Enter
+--------------------------------------------------------------------
----------+
| Starting installation of NagVis
1.7.9
|
+--------------------------------------------------------------------
----------+
| OS : Ubuntu
12.10
|
|
|
+--- Checking for tools
-------------------------------------------------------+
| Using packet manager
/usr/bin/dpkg
found |
|
|
+--- Checking paths
-----------------------------------------------------------+
|
|
+--- Checking prerequisites
---------------------------------------------------+
|
|
+--- Checking for existing NagVis
---------------------------------------------+
|
|
+--------------------------------------------------------------------
----------+
|
Summary
|
+--------------------------------------------------------------------
----------+
| NagVis home will be:
/usr/local/nagvis
|
| Owner of NagVis files will be: www-
data
|
| Group of NagVis files will be: www-
data
|
| Path to Apache config dir is:
/etc/apache2/conf.d
|
| Apache config will be created:
yes
|
|
|
| Installation mode:
install
|
|
|
| Do you really want to continue? [y]: <------- Press Enter
+--------------------------------------------------------------------
----------+
| Starting
installation
|
+--------------------------------------------------------------------
----------+
| Creating directory
/usr/local/nagvis...
done |
| Creating directory
/usr/local/nagvis/var...
done |
| Creating directory
/usr/local/nagvis/var/tmpl/cache...
done |
| Creating directory
/usr/local/nagvis/var/tmpl/compile...
done |
| Creating directory
/usr/local/nagvis/share/var...
done |
| Copying files to
/usr/local/nagvis...
done |
| Creating directory
/usr/local/nagvis/etc/profiles...
done |
| Creating main configuration
file...
done |
| Adding webserver group to
file_group...
done |
| Creating web configuration
file...
done |
| Setting permissions for web configuration
file... done |
|
|
|
|
|
|
+--- Setting permissions...
---------------------------------------------------+
| /usr/local/nagvis/etc/nagvis.ini.php-
sample done |
|
/usr/local/nagvis/etc
done |
|
/usr/local/nagvis/etc/maps
done |
|
/usr/local/nagvis/etc/maps/*
done |
|
/usr/local/nagvis/etc/geomap
done |
|
/usr/local/nagvis/etc/geomap/*
done |
|
/usr/local/nagvis/etc/profiles
done |
|
/usr/local/nagvis/share/userfiles/images/maps
done |
|
/usr/local/nagvis/share/userfiles/images/maps/*
done |
|
/usr/local/nagvis/share/userfiles/images/shapes
done |
|
/usr/local/nagvis/share/userfiles/images/shapes/*
done |
|
/usr/local/nagvis/var
done |
|
/usr/local/nagvis/var/*
done |
|
/usr/local/nagvis/var/tmpl
done |
|
/usr/local/nagvis/var/tmpl/cache
done |
|
/usr/local/nagvis/var/tmpl/compile
done |
|
/usr/local/nagvis/share/var
done |
|
|
+--------------------------------------------------------------------
----------+
| Installation
complete
|
|
|
| You can safely remove this source
directory.
|
|
|
| For later update/upgrade you may use this command to have a faster
update: |
| ./install.sh
|
|
| What to do
next?
|
| - Read the
documentation
|
| - Maybe you want to edit the main configuration
file? |
| Its location is:
/usr/local/nagvis/etc/nagvis.ini.php
|
| - Configure NagVis via
browser
|
|
<http://localhost/nagvis/config.php>
|
| - Initial admin
credentials:
|
| Username:
admin
|
| Password:
admin
|
+--------------------------------------------------------------------
----------+
NagVis has been installed now. Note down the default admin crdentials of NagVis.
# nano /usr/local/nagvis/etc/nagvis.ini.php
Scroll down to ‘Path definitions’ section and uncomment the lines as shown below.
; Path definitions
[paths]
; absolute physical NagVis path
base="/usr/local/nagvis/"
; absolute html NagVis path
htmlbase="/nagvis"
; absolute html NagVis cgi path
htmlcgi="/nagios/cgi-bin"
Scroll down further, you may find the section called ‘Backend definitions’.
Comment out the mklivestatus line.
; ----------------------------
; Backend definitions
; ----------------------------
Finally set the backend to use Icinga IDOUtils in the configuration file.
[backend_ndomy_1]
; type of backend - MUST be set
backendtype="ndomy"
## Add the following lines ##
dbname="icinga"
dbuser="icinga"
dbpass="icinga"
dbprefix="icinga_"
Save and close the file. Restart apache service to take effect the saved changes.
# /etc/init.d/apache2 restart