A photo of Mitesh Shah

Mitesh Shah

Linux Expert | Automation Enthusiast | Security Consultant

Email Skype Github Twitter Resume Hire Me Keybase LinkedIn Stackoverflow


How to Setup Nagios Monitoring System


# Ubuntu/Debian
$ sudo apt-get install wget build-essential openssl libssl-dev apache2 php apache2-mod-php7.0 php-gd libgd-dev unzip apache2-utils

Adding the Nagios User and Group

$ useradd nagios
$ groupadd nagcmd
$ usermod -a -G nagcmd nagios
$ usermod -a -G nagios,nagcmd www-data

Download Nagios Core, Nagios Plugins & NRPE Tarballs

$ cd /tmp
$ wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.2.0.tar.gz
$ wget http://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz
$ wget https://github.com/NagiosEnterprises/nrpe/archive/3.0.tar.gz

Extract Nagios Core, Nagios Plugins & NRPE Tarballs

$ tar zxvf nagios-4.2.0.tar.gz
$ tar zxvf nagios-plugins-2.1.2.tar.gz
$ tar zxvf 3.0.tar.gz

Nagios Core Installation

$ cd nagios-4.2.0
$ ./configure  --with-nagios-group=nagios --with-command-group=nagcmd --with-httpd-conf=/etc/apache2/sites-available/

$ make all
$ make install
$ make install-init
$ make install-config
$ make install-commandmode
$ make install-webconf

Copy Nagios Core Files

$ cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
$ chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

Setup Apache

$ sudo a2ensite nagios
$ sudo a2enmod rewrite cgi
$ htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Nagios Plugins Installation

$ cd /tmp/nagios-plugins-2.1.2
$ ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl --with-ping-command=ping
$ make
$ make install

Setup NRPE

$ cd /tmp/nrpe-3.0/
$ ./configure
$ make all
$ make install
$ make install-config
$ make install-init

Restart Services

$ service apache2 restart
$ service nagios restart
$ service nrpe restart

Enable Services

$ sudo update-rc.d nagios defaults

Check NRPE & Nagios

$ /usr/local/nagios/libexec/check_nrpe -H
NRPE vnrpe-3.0

$ /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Web Interface

  • After correctly following the procedures you should now be able to access your Nagios Core installation from a web browser.
  • Simply use the following:
  • Log in with the credentials you chose when adding the nagiosadmin user to the htpasswd.users file.

Post Navigation