1. First we will need to install the prereq’s by running:
apt-get install apache2 build-essential libgd2-xpm-dev libperl-dev openssl gcc make autoconf automake mailutils libssl-dev libmysqld-dev libmysqlclient-dev libldap2-dev libradiusclient-ng-dev libapache2-mod-php5 libsnmp-perl nfs-common nfs-kernel-server libnet-dns-perl libnet-snmp-perl libdbi-perl libapache2-request-perl libdbd-mysql-perl libcrypt-ssleay-perl mysql-client libnet-tftp-perl snmp
2. Adding the Nagios user:
groupadd -g 9000 nagios && groupadd -g 9001 nagcmd && useradd -u 9000 -g nagios -G nagcmd -d /usr/local/nagios -c "Nagios User" nagios
3. Download Nagios and Nagios plugins:
wget -c http://downloads.sourceforge.net/project/nagios/nagios-3.x/nagios-3.5.0/nagios-3.5.0.tar.gz
wget -c http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
4. Untar the archives:
tar xfvz nagios-3.5.0.tar.gz
tar xfvz nagios-plugins-1.4.16.tar.gz
5. Compile Nagios
cd nagios
./configure --enable-nanosleep --enable-embedded-perl --with-command-group=nagcmd --with-gd-lib=/usr/lib --with-gd-inc=/usr/include
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cd ..
6. Compile Nagios plugins:
cd nagios-plugins-1.4.16
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
cd ..
7. Add nagiosadmin user to the apache2
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
8. Restart apache2 webserver
/etc/init.d/apache2 restart
9. Add www-data user to nagcmd group
usermod -a -G nagcmd www-data
10. Install nrpe server
wget -c http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz
tar xfvz nrpe-2.14.tar.gz
cd nrpe-2.14
./configure --enable-command-args
make all
make install
cp init-script.debian /etc/init.d/nrpe-server
chmod 755 /etc/init.d/nrpe-server
11. Configure nrpe server
cp -a sample-config/nrpe.cfg /usr/local/nagios/etc/
12. Start services
/etc/init.d/nagios start
/etc/init.d/nrpe-server start
Troubleshooting
If you get something like bellow:
Error: Could not stat() command file ‘/usr/local/nagios/var/rw/nagios.cmd’!
The external command file may be missing, Nagios may not be running, and/or Nagios may not be checking external commands.
An error occurred while attempting to commit your command for processing.
Return from whence you came
Just do the following:
ls -l /usr/local/nagios/var/rw/nagios.cmd
prw-rw---- 1 nagios nagios 0 Aug 11 22:27 /usr/local/nagios/var/rw/nagios.cmd
chmod -R g+x /usr/local/nagios/var/rw
ls -l /usr/local/nagios/rw/nagios.cmd
prw-rwx--- 1 nagios nagios 0 Aug 11 22:27 /usr/local/nagios/var/rw/nagios.cmd
/etc/init.d/nagios restart
Also change group of the file
ls -l /usr/local/nagios/var/rw/nagios.cmd
prw-rw---- 1 nagios nagios 0 Aug 11 22:27 /usr/local/nagios/var/rw/nagios.cmd
chown nagios:www-data /usr/local/nagios/var/rw/nagios.cmd
And also, you may need to do the following and restart apache afterwards (I am pretty sure that you skipped by accident the step 9)
usermod -G nagios www-data
/etc/init.d/apache2 restart
10. Install nrpe server
here @ ./configure –enable-commom-args after done or maybe done an error apperas with can’t find ssl libraries
Hi,
Are you sure the libssl-dev is installed?
Regards!