Install Nagios

How to install nagios

In the nagios server

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


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

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

Exim mail queue clear

To clear SPAMS and unwanted mails from the mail queue

exim -bp | awk ‘$6~”frozen” {print $3 }’ | xargs exim -Mrm
grep -lr ‘nobody@’ /var/spool/exim/input/ | \sed -e ‘s/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g’ | xargs exim -Mrm
grep -rl ‘From: Mail Delivery System’ /var/spool/exim/input/ | \sed -e ‘s/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g’ | xargs exim -Mrm
grep -rl ‘X-Spam-Status: Yes’ /var/spool/exim/input/ | \sed -e ‘s/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g’ | xargs exim -Mrm
grep -rl ‘Subject: Mail delivery failed’ /var/spool/exim/input/ | \sed -e ‘s/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g’ | xargs exim -Mrm
grep -rl ‘Message rejected’ /var/spool/exim/input/ | \sed -e ‘s/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g’ | xargs exim -Mrm
grep -rl ‘retry time not reached for any host’ /var/spool/exim/input/ | \sed -e ‘s/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g’ | xargs exim -Mrm
grep -lr ‘Cialis’ /var/spool/exim/input/ | \sed -e ‘s/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g’ | xargs exim -Mrm
grep -lr ‘viagra’ /var/spool/exim/input/ | \sed -e ‘s/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g’ | xargs exim -Mrm
grep -lr ‘Pharmaceutical’ /var/spool/exim/input/ | \sed -e ‘s/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g’ | xargs exim -Mrm
grep -lr ‘***SPAM***’ /var/spool/exim/input/ | \sed -e ‘s/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g’ | xargs exim -Mrm

To remove all mails from the email account

grep -lr ‘’ /var/spool/exim/input/ | \sed -e ‘s/^.*\/\([a-zA-Z0-9-]*\)-[DH]$/\1/g’ | xargs exim -Mrm

Kernel Compilation

Kernel compilation

Go to the /usr/src directory

Unpack the source code with tar -xvzf linux-2.x.x.tag.gz.

Move to the /usr/src/linux sub-directory.

make mrproper

make menuconfig

make all

—    make vmlinux
—    make modules
—    make bzimage

make modules_install

make install

cp /usr/src/linux/arch/i386/boot/zImage /zImage

Making an initrd Image

An initrd image is needed for loading your SCSI module at boot time or if you are compiling the kernel with ext3 support as a module. If you do not need an initrd image, do not make one and do not edit lilo.conf or grub.conf to include this image.

Use the /sbin/mkinitrd shell script to build an initrd image for your machine. To use this command, the loopback block device must be available.

To build the new initrd image, run /sbin/mkinitrd with parameters such as this:

/sbin/mkinitrd /boot/initrd-2.4.18-0.12-jul2001.img 2.4.18-0.12-jul2001

In the above example, /boot/initrd-2.4.18-0.12-jul2001.img is the file name of the new initrd image. 2.4.18-0.12-jul2001 is the kernel whose modules (from /lib/modules) should be used in the initrd image. This is not necessarily the same as the version number of the currently running kernel.

Cleaning targets:

clean – Remove most generated files but keep the config and enough build support to build external modules

mrproper – Remove all generated files + config + various backup files

distclean – mrproper + remove editor backup and patch files

Configuration targets:

config          – Update current config utilising a line-oriented program

menuconfig      – Update current config utilising a menu based program

xconfig         – Update current config utilising a QT based front-end

gconfig         – Update current config utilising a GTK based front-end

oldconfig       – Update current config utilising a provided .config as base

silentoldconfig – Same as oldconfig, but quietly

randconfig      – New config with random answer to all options

defconfig       – New config with default answer to all options

allmodconfig    – New config selecting modules when possible

allyesconfig    – New config where all options are accepted with yes

allnoconfig     – New config where all options are answered with no

Other generic targets:

all             – Build all targets marked with [*]

vmlinux         – Build the bare kernel

modules         – Build all modules

modules_install – Install all modules to INSTALL_MOD_PATH (default: /)

dir/            – Build all files in dir and below

dir/file.[ois]  – Build specified target only

dir/file.ko     – Build module including final link

rpm             – Build a kernel as an RPM package

tags/TAGS       – Generate tags file for editors

cscope          – Generate cscope index

kernelrelease   – Output the release version string

kernelversion   – Output the version stored in Makefile

headers_install – Install sanitised kernel headers to INSTALL_HDR_PATH(default: /usr/src/linux-.6.24.3/usr)

Static analysers

checkstack      – Generate a list of stack hogs

namespacecheck  – Name space analysis on compiled kernel

export_report   – List the usages of all exported symbols

headers_check   – Sanity check on exported headers

Kernel packaging:

rpm-pkg         – Build the kernel as an RPM package

binrpm-pkg      – Build an rpm package containing the compiled kernel and modules

deb-pkg         – Build the kernel as an deb package

tar-pkg         – Build the kernel as an uncompressed tarball

targz-pkg       – Build the kernel as a gzip compressed tarball

tarbz2-pkg      – Build the kernel as a bzip2 compressed tarball

Documentation targets:

Linux kernel internal documentation in different formats:

htmldocs        – HTML

installmandocs  – install man pages generated by mandocs

mandocs         – man pages

pdfdocs         – PDF

psdocs          – Postscript

xmldocs         – XML DocBook

Architecture specific targets (i386):

bzImage       – Compressed kernel image (arch/x86/boot/bzImage)

install       – Install kernel using

(your) ~/bin/installkernel or

(distribution) /sbin/installkernel or

install to $(INSTALL_PATH) and run lilo

bzdisk       – Create a boot floppy in /dev/fd0

fdimage      – Create a boot floppy image

isoimage     – Create a boot CD-ROM image

make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build

make V=2   [targets] 2 => give reason for rebuild of target

make O=dir [targets] Locate all output files in “dir”, including .config

make C=1   [targets] Check all c source with $CHECK (sparse by default)

make C=2   [targets] Force check of all c source with $CHECK

Execute “make” or “make all” to build all targets marked with [*]

For further info see the ./README file

Horde Issue

Cant find file: horde_sessionhandler.MYI

If you get this error, you ve most likely done a file-based MySQL backup restore, and the InnoDB files are hosed. The horde_sessionhandler table isnt a MyISAM table at all – its actually an InnoDB table. The easiest way to fix the issue is to stop MySQL and trash the .frm:

# /etc/init.d/mysqld stop

# rm /var/lib/mysql/horde/horde_sessionhandler.frm

Now start MySQL and re-create the table:

# /etc/init.d/mysqld start

# mysql -u admin -p`cat /etc/psa/.psa.shadow`
Here is the SQL statements to run:

CREATE TABLE horde_sessionhandler (session_id VARCHAR(32) NOT NULL, session_lastmodified INT NOT NULL, session_data LONGBLOB, PRIMARY KEY (session_id)) ENGINE = InnoDB;
GRANT SELECT, INSERT, UPDATE, DELETE ON horde_sessionhandler TO horde@localhost;

Horde Loopback

Loops back to login page in horde


mysql> use horde;
mysql> drop table horde_sessionhandler;
mysql> CREATE TABLE horde_sessionhandler (
session_id VARCHAR(32) NOT NULL,
session_lastmodified INT NOT NULL,
session_data LONGBLOB,

PRIMARY KEY (session_id)
) ENGINE = InnoDB;