Thursday, February 4, 2010

Howto install Nagios in Ubuntu 9.10 Karmic

0) Install OS
Ubuntu server 9.10
Use expert mode and set static ip (no dhcp in server room)
select to install openssh server

sudo apt-get update
sudo apt-get upgrade

Add core gnome desktop:
sudo apt-get install xorg gnome-core

Add nx server:
mkdir downloads
cd downloads

wget http://64.34.161.181/download/3.4.0/Linux/nxclient_3.4.0-5_i386.deb
wget http://64.34.161.181/download/3.4.0/Linux/nxnode_3.4.0-6_i386.deb
wget http://64.34.161.181/download/3.4.0/Linux/FE/nxserver_3.4.0-8_i386.deb

sudo dpkg -i nxclient_3.4.0-5_i386.deb nxnode_3.4.0-6_i386.deb nxserver_3.4.0-8_i386.deb

add browser
sudo apt-get install epiphany-browser epiphany-extensions


Required Packages

sudo apt-get install apache2
sudo apt-get install libapache2-mod-php5
sudo apt-get install build-essential
sudo apt-get install libgd2-xpm-dev

a) Create Account Information

Become the root user.
sudo -s

Create a new nagios user account and give it a password.
useradd -m -s /bin/bash nagios

passwd nagios
/usr/sbin/usermod -G nagios nagios

Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.

/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd www-data

b) Download Nagios and the Plugins

Create a directory for storing the downloads.

mkdir ~/downloads
cd ~/downloads

Download the source code tarballs of both Nagios and the Nagios plugins (visit http://www.nagios.org/download/ for links to the latest versions).

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz

wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz

c) Compile and Install Nagios

Extract the Nagios source code tarball.
tar xzf nagios-3.2.0.tar.gz

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

d) Customize Configuration


Edit the /usr/local/nagios/etc/objects/contacts.cfg config file and change the email address associated with the nagiosadmin contact definition to the address you'd like to use for receiving alerts.

sudo nano /usr/local/nagios/etc/objects/contacts.cfg

e) Configure the Web Interface
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
/etc/init.d/apache2 reload

Note: Consider implementing the ehanced CGI security measures described here to ensure that your web authentication credentials are not compromised.

f) Compile and Install the Nagios Plugins
cd ~/downloads

tar xzf nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.14

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

g) Start Nagios

Configure Nagios to automatically start when the system boots.
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Verify the sample Nagios configuration files.
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If there are no errors, start Nagios
sudo /etc/init.d/nagios start

h) Login to the Web Interface (nagiosadmin) and password you specified earlier.
http://localhost/nagios/

i) Other Modifications

If you want to receive email notifications for Nagios alerts, you need to install the mailx (Postfix) package.

sudo apt-get install mailx
Select sattellite and enter relay server (in this case the exchange server)

test in terminal
mail sss@sss.com
(NB: company server only accept relay for local addresses)
Enter to end subject
CTRL-D to end body


Edit the Nagios email notification commands found in /usr/local/nagios/etc/objects/commands.cfg and change any '/bin/mail' references to '/usr/bin/mail'. Once you do that you'll need to restart Nagios to make the configuration changes live.

sudo /etc/init.d/nagios restart

See next few posts about configuring Nagios and NSClient

No comments:

Post a Comment