Chinaunix首页 | 论坛 | 博客
  • 博客访问: 222264
  • 博文数量: 22
  • 博客积分: 1676
  • 博客等级: 上尉
  • 技术积分: 420
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-31 10:48
文章分类

全部博文(22)

文章存档

2011年(8)

2010年(1)

2009年(1)

2008年(12)

我的朋友

分类: 系统运维

2011-04-25 15:49:17

Installing Nagios3 on Debian5 from source

OS: Debian-5.0.8

MySQL: 5.0.51a

Nagios-core: 3.2.3

Nagios-plugins: 1.4.15

NDOUtils: 1.4b9


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

# apt-get install libmysqlclient15-dev


1. Create Account Information


# sudo -s

# useradd -m -s /bin/bash nagios

# passwd nagios

# groupadd nagios

# usermod -G nagios nagios

# groupadd nagcmd

# usermod -a -G nagcmd nagios

# usermod -a -G nagcmd www-data


2. Installing Nagios Core


# tar xvf nagios-3.2.3.tar.gz

# cd 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

# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

# /etc/init.d/apache2 reload


3. Installing Nagios Plugins

# tar xzf nagios-plugins-1.4.15.tar.gz

# cd nagios-plugins-1.4.15

# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

# make

# make install


ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

ln -s /usr/local/nagios/etc /etc/nagios

ln -s /usr/local/nagios/bin/nagios /usr/bin


4. Installing NDO Utilities

# tar xzf ndoutils-1.4b9.tar.gz

# cd ndoutils-1.4b9

# ./configure

# make

# cd src

# cp ndomod-3x.o ndo2db-3x log2ndo file2sock /usr/local/nagios/bin

# cd ../db

# mysql -uroot -p

> create database `nagios`;

> grant all on `nagios`.* to 'nagios'@'localhost' identified by 'nagios';

> exit;

# ./installdb -unagios -pnagios -dnagios


# cp /etc/nagios/nagios.cfg /etc/nagios/nagios.cfg.org

# cd ../config

# vi nagios.cfg

commont out this line: broker_module=/usr/local/nagios/bin/ndomod-2x.o config_file=/usr/local/nagios/etc/ndomod.cfg

uncommont this line: broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg

# cat nagios.cfg >> /etc/nagios/nagios.cfg

# cp ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg

# cp ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg

# vi /usr/local/nagios/etc/ndo2db.cfg

change dbusername and dbpassword

# vi /usr/local/nagios/etc/nagios.cfg

make sure that the line is uncommented: event_broker_options=-1

# vi /etc/init.d/nagios

add the following contents:

NDOBin=${prefix}/bin/ndo2db-3x

NDOCfgFile=${prefix}/etc/ndo2db.cfg

NDOPidFile=${prefix}/var/ndo2db.pid

# Check that ndo2db exists.

if [ ! -f $NDOBin ]; then

echo "Executable file $NDOBin not found. Exiting."

exit 1

fi


# Check that ndo2db.cfg exists.

if [ ! -f $NDOCfgFile ]; then

echo "Configuration file $NDOCfgFile not found. Exiting."

exit 1

fi

echo "Starting nagios database connection"

su - $NagiosUser -c "$NDOBin -c $NDOCfgFile"

if [ $? -ne 0 ]; then

echo "Error starting database connection"

exit 1

else

echo `ps -ef | grep ndo2db | grep -v 'grep' | gawk '{ print $2 }' ` > $NDOPidFile

fi

echo "Stopping nagios database connection"

if test ! -f $NDOPidFile; then

echo "No lock file found in $NDOPidFile"

return 1

fi

NDOPID=`head -n 1 $NDOPidFile`

kill $2 $NDOPID

rm -f $NDOPidFile

Please refer to the attachment for full version.

 nagios.zip   

5. Starting Nagios

# /etc/init.d/nagios start

Starting nagios database connection

Starting nagios: done.

Q&A

When starting Nagios, a message like the following:


Support for the specified database server is either not yet supported, or was not found on your system.


This indicates that when you compiled ndo2db it was unable to find the MySQL development libraries. Verify that you have the MySQL development libraries installed.

# apt-get install libmysqlclient15-dev


References: 

Nagios Core Version 3.x Documentation

NDOUTILS Documentation Version 1.4

http://danielaliaman.com/blog///index.php/2008/07/08/new_nagios_startup_script_with_ndo_suppo?blog=2

http://blog.c1gstudio.com/archives/635



阅读(1515) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~