Share this page : facebooktwitterlinkedinmailfacebooktwitterlinkedinmail
Prerequisites

Compiler:
yum install httpd php gcc glibc glibc-common gd gd-devel make net-snmp  net-snmp-utils unzip

Accounts:

/usr/sbin/useradd -m nagios
passwd nagios
/usr/sbin/groupadd nagcmd # Used for Web Interface
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
Installation

For  RHEL/CentOS  users:

./configure --with-command-group=nagcmd

For Ubuntu users:

./configure --with-command-group=nagcmd -–with-mail=/usr/bin/sendmail
 --with-httpd-conf=/etc/apache2/

All systems:

make all
make install 
make install-init 
make install-config 
make install-commandmode 
make install-webconf 
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

For Ubuntu  users:

sudo a2ensite nagios
sudo a2enmod rewrite cgi

For RHEL/CentOS  users:

/etc/init.d/nagios start
/etc/init.d/httpd start
or
service httpd start

For Ubuntu users using

systemd
 :
 sudo cp /etc/init.d/skeleton /etc/init.d/nagios
 sudo vi /etc/init.d/nagios
 (and add the following lines)
 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
 systemctl restart apache2
 systemctl start nagios

Create a Default User for Web Access.

Add a default user for Web Interface Access:

htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Nagios Plugin Installation

Downloads

cd /tmp/nagios-plugins-2.2.0
./configure --with-nagios-user=nagios --with-nagios-group=nagios 
make 
make install
Add Nagios services

 

chkconfig --add nagios
chkconfig nagios on

Verify the sample Nagios configuration files:

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios start

Check SELinux

getenforce

Change to permissive mode.

setenforce 0

Modifiy /etc/selinux/config for system to remain in permission mode

OR modifiy selinux permissions to allow nagios:

chcon -R -t httpd_sys_script_exec_t /usr/local/nagios/sbin/
chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
Test:

Restart the nagios and httpd service:

sudo service nagios restart

sudo service httpd restart

enter url: ip_address/nagios