How to Install Nagios?

Nagios Installation

  • In this series we will be installing nagios on ubuntu. The versions used in this series are
    • Nagios: 4.4.5
    • Nagios Plugin: 2.2.1
    • Ubuntu: 18.04
  • The installation used in this series will be from the link over here
  • The nagios recommends installing the core version by downloading, compling and installing the code
  • Following are the steps which we will follow
  • Update Ubuntu packages and ensure the following softwares are installed
sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.2 libgd-dev

sudo apt-get install -y libmcrypt-dev libssl-dev bc gawk dc build-essential snmp libnet-snmp-perl gettext
  • Download the source of nagios and untar
cd /tmp
wget -O nagioscore.tar.gz
tar xzf nagioscore.tar.gz
  • Compile the code
cd /tmp/nagioscore-nagios-4.4.5/
sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled
sudo make all
  • Create user and group
sudo make install-groups-users
sudo usermod -a -G nagios www-data
  • Install Binaries
sudo make install
  • Install Service / Daemon
sudo make install-daemoninit
  • Install Command mode
sudo make install-commandmode
  • Install Apache Configuration Files
sudo make install-webconf
sudo a2enmod rewrite
sudo a2enmod cgi
  • Create nagiosadmin User Account
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 
# Enter password on prompt
  • Download the Nagios Plugin source code
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz
tar zxf nagios-plugins.tar.gz
  • Compile and Install
cd /tmp/nagios-plugins-release-2.2.1/
sudo ./tools/setup
sudo ./configure
sudo make
sudo make install
  • Restart Nagios and apache
sudo systemctl start nagios.service
sudo systemctl stop nagios.service
sudo systemctl restart nagios.service
sudo systemctl status nagios.service

Nagios Important Paths

Configuration Item Path
Configuration Directory /usr/local/nagios
Nagios Configuration File /usr/local/nagios/nagios.cfg
Nagios local state directory /usr/local/nagios/var/
Nagios current state file usr/local/nagios/var/status.dat

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner