Tag Archives: plugins

How to install nagios3 from source on debian squeeze

1. First we will need to install the prereq’s by running:
[codesyntax lang="bash"]

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

[/codesyntax]

2. Adding the Nagios user:
[codesyntax lang="bash"]

groupadd -g 9000 nagios && groupadd -g 9001 nagcmd && useradd -u 9000 -g nagios -G nagcmd -d /usr/local/nagios -c "Nagios User" nagios

[/codesyntax]

3. Download Nagios and Nagios plugins:
[codesyntax lang="bash"]

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

[/codesyntax]

4. Untar the archives:
[codesyntax lang="bash"]

tar xfvz nagios-3.5.0.tar.gz
tar xfvz nagios-plugins-1.4.16.tar.gz

[/codesyntax]

5. Compile Nagios
[codesyntax lang="bash"]

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 ..

[/codesyntax]
6. Compile Nagios plugins:
[codesyntax lang="bash"]

cd nagios-plugins-1.4.16
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
cd ..

[/codesyntax]
7. Add nagiosadmin user to the apache2
[codesyntax lang="bash"]

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

[/codesyntax]

8. Restart apache2 webserver
[codesyntax lang="bash"]

/etc/init.d/apache2 restart

[/codesyntax]

9. Add www-data user to nagcmd group

[codesyntax lang="bash"]

usermod -a -G nagcmd www-data

[/codesyntax]

10. Install nrpe server

[codesyntax lang="bash"]

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

[/codesyntax]

11. Configure nrpe server

[codesyntax lang="bash"]

cp -a sample-config/nrpe.cfg /usr/local/nagios/etc/

[/codesyntax]

12. Start services

[codesyntax lang="bash"]

/etc/init.d/nagios start
/etc/init.d/nrpe-server start

[/codesyntax]

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:

[codesyntax lang="bash"]

ls -l /usr/local/nagios/var/rw/nagios.cmd

[/codesyntax]
prw-rw---- 1 nagios nagios 0 Aug 11 22:27 /usr/local/nagios/var/rw/nagios.cmd

[codesyntax lang="bash"]

chmod -R g+x /usr/local/nagios/var/rw
ls -l /usr/local/nagios/rw/nagios.cmd

[/codesyntax]
prw-rwx--- 1 nagios nagios 0 Aug 11 22:27 /usr/local/nagios/var/rw/nagios.cmd

[codesyntax lang="bash"]

/etc/init.d/nagios restart

[/codesyntax]

Also change group of the file
[codesyntax lang="bash"]

ls -l /usr/local/nagios/var/rw/nagios.cmd

[/codesyntax]
prw-rw---- 1 nagios nagios 0 Aug 11 22:27 /usr/local/nagios/var/rw/nagios.cmd

[codesyntax lang="bash"]

chown nagios:www-data /usr/local/nagios/var/rw/nagios.cmd

[/codesyntax]

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)
[codesyntax lang="bash"]

usermod -G nagios www-data
/etc/init.d/apache2 restart

[/codesyntax]