Installing Nagios3 on RHEL5 from source
OS: CentOS-5.6
MySQL: 5.0.77
Nagios-core: 3.2.3
Nagios-plugins: 1.4.15
NDOUtils: 1.4b9
0. Required Packages
# yum install gcc imake binutils cpp \
openssl openssl-devel httpd \
libpng libpng-devel \
libjpeg libjpeg-devel perl mysql-devel \
gd gd-devel php glibc glibc-common
1. Create Account Information
# groupadd nagios
# groupadd nagcmd
# useradd -g nagios -G nagioscmd -d /opt/nagios nagios
# grep -r ^User /etc/httpd/*
/etc/httpd/conf/httpd.conf:User apache
# usermod -G nagcmd apache
# mkdir -p /opt/nagios /etc/nagios /var/nagios
# chown nagios.nagios /opt/nagios /etc/nagios /var/nagios
# chmod 775 /opt/nagios /etc/nagios /var/nagios
2. Installing Nagios Core
# tar xvf nagios-3.2.3.tar.gz.gz
# cd nagios-3.2.3
# ./configure --prefix=/opt/nagios \
--sysconfdir=/etc/nagios \
--localstatedir=/var/nagios \
--libexecdir=/opt/nagios/plugins \
--with-command-group=nagcmd
# make all
# make install
# make install-init
# make install-config
# make install-commandmode
# make install-webconf
# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
# chkconfig --add nagios
# chkconfig nagios on
3. Installing Nagios Plugins
# tar xzf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins-1.4.15
# ./configure --prefix=/opt/nagios \
--sysconfdir=/etc/nagios \
--localstatedir=/var/nagios \
--libexecdir=/opt/nagios/plugins \
--with-nagios-user=nagios \
--with-nagios-group=nagios
# make
# make install
4. Installing NDO Utilities
# tar xzf ndoutils-1.4b9.tar.gz
# cd ndoutils-1.4b9
# ./configure --prefix=/opt/nagios \
--sysconfdir=/etc/nagios \
--localstatedir=/var/nagios \
--libexecdir=/opt/nagios/plugins \
--with-ndo2db-user=nagios \
--with-ndo2db-group=nagios
# make
# cd src
# cp ndomod-3x.o ndo2db-3x log2ndo file2sock /opt/nagios/bin
# cd ../db
# mysql -uroot -p
> create database `nagios`;
> grant all on `nagios`.* to 'nagios'@'localhost' identified by 'nagios';
> exit;
# ./installdb -unagios -pnagios -dnagios
# cp /etc/nagios/nagios.cfg /etc/nagios/nagios.cfg.org
# cd ../config
# vi nagios.cfg
# commont out this line:
# broker_module=/opt/nagios/bin/ndomod-2x.o config_file=/etc/nagios/ndomod.cfg
# uncommont this line:
broker_module=/opt/nagios/bin/ndomod-3x.o config_file=/etc/nagios/ndomod.cfg
# cat nagios.cfg >> /etc/nagios/nagios.cfg
# cp ndo2db.cfg-sample /etc/nagios/ndo2db.cfg
# cp ndomod.cfg-sample /etc/nagios/ndomod.cfg
# vi /etc/nagios/ndo2db.cfg
# change db_user and db_pass to:
db_user=nagios
db_pass=nagios
# chown -R nagios.nagios /etc/nagios/
# chown -R nagios.nagios /opt/nagios/
# vi /etc/nagios/nagios.cfg
# make sure that the line is uncommented:
event_broker_options=-1
# vi /etc/init.d/nagios
# add the following contents:
NDOBin=${prefix}/bin/ndo2db-3x
NDOCfgFile=${prefix}/etc/ndo2db.cfg
NDOPidFile=${prefix}/var/ndo2db.pid
# Check that ndo2db exists.
if [ ! -f $NDOBin ]; then
echo "Executable file $NDOBin not found. Exiting."
exit 1
fi
# Check that ndo2db.cfg exists.
if [ ! -f $NDOCfgFile ]; then
echo "Configuration file $NDOCfgFile not found. Exiting."
exit 1
fi
echo "Starting nagios database connection"
su - $NagiosUser -c "$NDOBin -c $NDOCfgFile"
if [ $? -ne 0 ]; then
echo "Error starting database connection"
exit 1
else
echo `ps -ef | grep ndo2db | grep -v 'grep' | gawk '{ print $2 }' ` > $NDOPidFile
fi
echo "Stopping nagios database connection"
if test ! -f $NDOPidFile; then
echo "No lock file found in $NDOPidFile"
return 1
fi
NDOPID=`head -n 1 $NDOPidFile`
kill $2 $NDOPID
rm -f $NDOPidFile
Please refer to the attachment for full version.
5. Starting Services
# service httpd restart
# service nagios start
Starting nagios database connection
Starting nagios: done.
check syslog for info