How to install nagios

In the nagios server

1)Download the tarball of nagios (Here I use nagios-1.0b5 version)

#wget http://heanet.dl.sourceforge.net/sourceforge/nagios/nagios-1.0b5.tar.gz

2)Extract the tarball

# tar zxvf nagios-1.0b5.tar.gz

3) Create a folder named nagios under /usr/local
# mkdir /usr/local/nagios

4)Create a user and group named nagios. In many of the linux flavours, a corresponding group will be created for evry user.

#useradd nagios
#groupadd nagios

5) Enter the extracted folder. # cd nagios-1.0b5

6) Type the following script on a single line without line breaks: # ./configure –prefix=/usr/local/nagios –with-cgiurl=/nagios/cgi-bin –with-htmurl=/nagios/ –with-nagios-user=nagios –with-nagios-grp=nagios

7)# make all

8)# make install

9)#make install-init

10)#make install-commandmode

11) If you take a look into the /usr/local/nagios directory right now, you will see that there are four directories.
bin      sbin      share     var

12) # make install-config

Congrats, the nagios installation is completed!!! But to function properly, we need to install nagios plugin also. Come on, lets run to the next stage…

Install the nagios Plugin

1)Download the plugin. I used nagios-plugins-1.3.0 without any much problems. You can download it usng wget http://www.sreeforyou.com/tools/nagios/nagios-plugins-1.3.1.tar.gz

2)#tar zxvf nagios-plugins-1.3.0.tar.gz

3)Type the following script on a single line without line breaks: # ./configure –prefix=/usr/local/nagios –with-nagios-user=nagios –with-nagios-grp=nagios

4)#make all

5)#make install

6)#cd /usr/local/nagios/libexec/

7) To test the working, run the command ./check_ssh www.example.com
SSH ok – protocol version 1.99- – server version

8)#cd /usr/local/nagios/etc

9)# mkdir sample

10)# cp *.cfg-sample sample/

11)Rename each file manually, or use the following command to take care of them all at once.

for i in *cfg-sample; do mv $i `echo $i | sed -e s/cfg-sample/cfg/`; done;

12)../bin/nagios -v nagios.cfg

Run this command will show a lot of errors with the nagios configuration. Lets have to clear all the errors one-by-one.

13)#rm -f hosts.cfg services.cfg contacts.cfg contactgroups.cfg hostgroups.cfg dependencies.cfg escalations.cfg

14)#touch dependencies.cfg escalations.cfg contacts.cfg services.cfg

The nagios installation in completed. Now we have to configure the files related to nagios. This is a very easy step once you go through the steps.