Wednesday 6 July 2011

Nagios installation

Install Ubuntu with LAMP & postfix & Build essentials

Nagios User Setup

useradd -m -s /bin/bash nagios
passwd nagios
usermod -G nagios nagios
groupadd nagcmd
usermod -a -G nagcmd nagios

Download And Unzip Nagios And Nagios Plugins

cd /downloads
wget http://prdownloads.sourceforge.net/nagios/nagios-3.2.3.tar.gz
wget http://prdownloads.sourceforge.net/nagiosplug/nagios-plugins-1.4.15.tar.gz
tar -zxf /downloads/nagios-3.2.3.tar.gz
tar -zxf /downloads/nagios-plugins-1.4.15.tar.gz

Install Nagios

cd /downloads/nagios-3.2.3
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

Nagios Password

This is the password you will need to look at the nagios pages. If you install Nagios to a different directory please change this command to where the Nagios etc. folder will be.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Enter your password when prompted.
Now we will restart Apache to make sure all of the changes take effect:
/etc/init.d/apache2 restart

Nagios Plugins
cd /downloads/nagios-plugins-1.4.15/
make
make install
Now we need to make Nagios start at bootup:
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Change Default Email Address For Nagios Admin

Open your favorite editor and open /usr/local/nagios/etc/objects/contacts.cfg

Once you have saved your changes to the contacts.cfg we need to verify that there are no errors in the configuration of Nagios.

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


Now we are going to start nagios:
/etc/init.d/nagios start

Postfix Configuration For A Smarthost Relay

postconf -e 'relayhost=yourmailserver.com'
postconf -e 'smtp_sasl_auth_enabled = yes'
postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd'
postconf -e 'smtp_sasl_security_options ='
echo "yourmailserver.com emailusername:emailpassword" > /etc/postfix/sasl_passwd
Now we will need to change the password file attributes so only root has access to read it.
chown root:root /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd

Now we are going to set the map that will change your outbound messages from nagios to your email server username/email address.
echo "nagios mailusername@yourmailserver.com" /etc/postfix/canonical
echo "canonical_maps = hash:/etc/postfix/canonical" >> /etc/postfix/main.cf
postmap /etc/postfix/canonical


/etc/init.d/postfix restart
Now that this all has been completed you can restart your system.
Once your system has come back up you will be able to login to the website and look at your first Nagios installation.
http://yourserver/nagios/

 source: http://www.howtoforge.com/nagios-installation-on-ubuntu-10.04-lucid-lynx-p3






No comments:

Post a Comment