↑ Top
Kaai24
dev studios
| Sign in | DE EN

Install Nagios Core 4 from source

on Debian or Ubuntu


The most recent versions of Nagios are not available in the repositories (most common is version 3) but there are many important improvements since version 4, eg. performance. To install the most recent version use this tutorial.

Install everything needed to build Nagios from source

apt install apache2 libapache2-mod-php7.0 php7.0
apt install wget unzip zip  autoconf gcc libc6 make apache2-utils libgd-dev

Create the Nagios user

useradd nagios
usermod -a -G nagios www-data

Download the lastest version

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz

tar xzf nagios-4.3.4.tar.gz
cd nagios-4.3.4/

Configue and build it

./configure --with-httpd-conf=/etc/apache2/sites-enabled
make all
make install
make install-init
make install-commandmode
systemctl enable nagios.service
make install-config
make install-webconf

Setup the password for Nagios

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Configure the services

a2enmod cgi
systemctl restart apache2
systemctl start nagios
systemctl enable nagios

Nagios is now installed and accessible with a browser via http://hostname/nagios. But you should secure it with SSL later.

If you login to Nagios you will see some problems with the local services. This is because there are no plugins installed. To change this do

apt install libmcrypt-dev make libssl-dev bc gawk dc build-essential snmp libnet-snmp-perl gettext /
libldap2-dev smbclient fping libmysqlclient-dev qmail-tools libpqxx3-dev libdbi-dev

Download the lastest version of the plugins

wget https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
tar xfz release-2.2.1.tar.gz 
cd nagios-plugins-release-2.2.1/

Configure and build the plugins

./tools/setup 
./configure 
make
make install

Some plugins need a different path to work or they will throw "Can't locate utils.pm in @INC"

ln -s /usr/local/nagios /usr/lib/
ln -s /usr/local/nagios/libexec /usr/lib/nagios/plugins

apt install nagios-nrpe-plugin

ls /usr/lib/nagios/plugins/

systemctl restart nagios.service

The config for localhost is stored at

/usr/local/nagios/etc/objects/localhost.cfg

Next: Add Linux Host to Nagios Server.

(Edited 18-10-18)

Comments

Kaai
Nearly finished