Sunday, July 22, 2007

Nagios 2.9 installation

If you want to install Nagios into VMware, please see the post about the VMware additions.
  • Log in with root or use sudo
  • Create a downloads folder : mkdir ~/downloads
  • Download the tarball with "wget" : wget
  • Create a "src" folder if necessary to put the nagios into in : mkdir /usr/local/src
  • Extract the tarball into the "src" folder : tar xvfz ~/downloads/nagios-2.9.tar.gz
  • groupadd -g 9000 nagios (Create the group nagios)
  • groupadd -g 9001 nagcmd (Create the group nagcmd)
  • useradd -u 9000 -g nagios -G nagioscmd -d /usr/local/nagios -c "Nagios Admin" nagios (Create the user nagios, member of nagios, nagioscmd, and home directory)
  • Install the tools needed for the compilation : apt-get install build-essential
  • Install the PNG, JPEG libraries : apt-get install libpng12-0 libpng12-dev libjpeg62 libjpeg62-dev
  • Install the last GD library into the downloads diretory : wget
  • Uncompress the tarball : tar xvfz ~/downloads/gd-2.0.35.tar.gz
  • ./configure in the GD directory
  • make all
  • make install
  • Install Apache2 with apt-get install apache2
  • You need to find the user for Apache2, you can do it with the following command : grep "^User" /etc/apache2/apache2.conf. Normally you will see www-data
  • Add "www-data" to the "nagcmd" group : usermod -G nagcmd www-data
  • Create the following directories : mkdir /usr/local/nagios /etc/nagios /var/nagios
  • Change the owner of these directories : chown nagios.nagios /usr/local/nagios /etc/nagios /var/nagios
  • Go to the source directory : ./configure --sysconfigdir=/etc/nagios --localstatedir=/var/nagios --with-command-groupe=nagcmd
  • make all
  • make install
  • make install-init
  • make install-commandmode
  • make install-config
  • Create symbolic link to run Nagios at the startup : ln -s /etc/init.d/nagios /etc/rc2.d/S99nagios
  • Create symbolic link to stop Nagios : ln -s /etc/init.d/nagios /etc/rc2.d/K99nagios
  • Repeat these steps for rc3 and rc5
  • We need to install the plugings, download it into ~/downloads : wget
  • Uncompress into the "src" folder : tar xvfz ~/downloads/nagios-plugins-1.4.9
  • apt-get install fping
  • apt-get install smbclient
  • apt-get install libradius1 libradius1-dev
  • apt-get install libldap2 libldap2-dev
  • apt-get install libsnmp-base libsnmp9 libsnmp9-dev snmp
  • apt-get install libssl-dev libssl0.9.8
  • apt-get install postgresql-dev
  • apt-get install mysql-client libmysql++-dev
  • perl -MCPAN -e 'install Net::SNMP'
  • ./configure --sysconfdir=/etc/nagios --localstatedir=/var/nagios
Some modules will no be installed as qstat and lmstat. To be honest, I don't want to monitor Quake servers and I don't know lmstat.
  • make all
  • make install

The plugin check_icmp must have the SUID bit to function correctly.

  • chown root.nagios /usr/local/nagios/libexec/check_icmp
  • chmod 4711 /usr/local/nagios/libexec/check_icmp
  • Go to the /etc/apache2/conf.d
  • Create the nagios.conf and follow the instructions from there
  • Edit the cgi.cfg to use the authentication : use_authentication=1
  • Create a .htaccess in the following directory /usr/local/nagios/sbin with the following content :
    AuthName "Nagios-Monitoring"
    AuthType Basic
    AuthUserFile /etc/nagios/htpasswd
    require valid-user
  • In /etc/nagios : htpasswd -c htpasswd nagios
  • Change the owner of the file to www-data : chown htpasswd
  • Give "rw" to the user www-data only : chmod 600 htpasswd

No comments: