Install Nagios Core on CentOS 8

Posted: November 4, 2019 in Linux

I disabled SELinux

sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
setenforce 0

 

Install python and other prerequisities

 

dnf install -y compat-openssl10 python3 perl gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix 
alternatives --set python /usr/bin/python3 

Add nagios user and group

useradd nagios
groupadd nagcmd 

Add both the nagios user and the apache user to the nagcmd group 

usermod -G nagcmd nagios
usermod -G nagcmd apache

Download nagios setup

mkdir setup 
cd setup 
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz 
tar xvf nagios-4.4.5.tar.gz

Install nagios

cd nagios-4.4.5 
./configure --with-command-group=nagcmd 
make all 
make install 
make install-init 
make install-commandmode 
make install-config 
make install-webconf 
# set nagiosadmin password 
htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 

Setup EventHandlers

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

 

 

Download and install nagios plugins

yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
tar zxf nagios-plugins.tar.gz
cd /tmp/nagios-plugins-release-2.2.1/
./tools/setup
./configure --with-openssl --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

 

Install NRPE

NRPE allows you to remotely execute Nagios plugins on other Linux/Unix machines. This allows you to monitor remote machine metrics (disk usage, CPU load, etc.). NRPE can also communicate with some of the Windows agent addons, so you can execute scripts and check metrics on remote Windows machines as well.

# install nrpe 
dnf install openssl-devel 
wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.1/nrpe-3.2.1.tar.gz 
tar -xvf nrpe-3.2.1.tar.gz 
cd nrpe-3.2.1 
./configure --disable-ssl --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --libexecdir=/usr/local/nagios/libexec/ --bindir=/usr/local/nagios/bin/ --prefix=/usr/local/nagios 
make 
make install 
cp src/check_nrpe /usr/local/nagios/libexec/

Install NCPA 

NCPA is a cross-platform monitoring agent that runs on Windows, Linux/Unix, and Mac OS/X machines. Its features include both active and passive checks, remote management, and a local monitoring interface.

 

wget https://assets.nagios.com/downloads/ncpa/check_ncpa.tar.gz 
tar -zxf check_ncpa.tar.gz 
mv check_ncpa.py /usr/local/nagios/libexec/ 
chown nagios:nagios /usr/local/nagios/libexec/check_ncpa.py 
chmod 775 /usr/local/nagios/libexec/check_ncpa.py 

Next add your command (ncpa into commands.cfg) 

vim /usr/local/nagios/etc/objects/commands.cfg 

define command { 

    command_name    check_ncpa 

    command_line    $USER1$/check_ncpa.py -H $HOSTADDRESS$ $ARG1$ 

} 

Adding contact

edit contacts.cfg and change email address

define contact{
        contact_name            nagiosadmin             ; Short name of user
        use                     generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                   Nagios Admin            ; Full name of user
        email                   dragan.vucanovic@hotmail.com       ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }

Enable and start nagios and httpd

systemctl start nagios
systemctl enable nagios
systemctl enable httpd
systemctl start httpd

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s