分类: LINUX
2010-08-12 17:55:18
CactiEZ中文0.91+Nagios集成
环境描述:
CactiEZ 中文0.91 (Red Hat Enterprise Linux Server release 5.2
(Tikanga))
待按照软件及包:
Nagios
nagios-plugins-
ndoutils-1.4b7.tar.gz
npc-
php-json-ext-
cacti-plugin-
autoconf-2.59-12.noarch.rpm
libgomp-
automake-
libjpeg-devel-6b-37.i386.rpm
cpp-
libpng-devel-
fontconfig-devel-
libX11-devel-
freetype-devel-
libXau-devel-
gcc-
libXdmcp-devel-
gd-
libXpm-
gd-devel-
libXpm-devel-
glibc-devel-2.5-24.i386.rpm
php-devel-
glibc-headers-2.5-24.i386.rpm
pkgconfig-0.21-2.el5.i386.rpm
imake-
xorg-x11-proto-devel-7.1-9.fc6.i386.rpm
kernel-headers-
安装步骤:
1、软件环境安装
进入npc需求包目录并安装软件包:
[root@cactiez nagios_packages]# cd
/root/Nagios/nagios_packages/
[root@cactiez nagios_packages]# rpm -ivh *.rpm –nodeps
warning:
autoconf-2.59-12.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ###########################################
[100%]
1:xorg-x11-proto-devel ###########################################
[ 4%]
2:autoconf
########################################### [ 8%]
3:automake ###########################################
[ 13%]
4:cpp
########################################### [ 17%]
5:fontconfig-devel
########################################### [ 21%]
6:freetype-devel ###########################################
[ 25%]
7:gcc
########################################### [ 29%]
8:gd
########################################### [ 33%]
9:gd-devel
########################################### [ 38%]
10:glibc-devel
########################################### [ 42%]
11:glibc-headers
########################################### [ 46%]
12:imake
########################################### [ 50%]
13:kernel-headers
########################################### [ 54%]
14:libgomp
########################################### [ 58%]
15:libjpeg-devel
########################################### [ 63%]
16:libpng-devel ###########################################
[ 67%]
17:libX11-devel
########################################### [ 71%]
18:libXau-devel
########################################### [ 75%]
19:libXdmcp-devel ###########################################
[ 79%]
20:libXpm
########################################### [ 83%]
21:libXpm-devel
########################################### [ 88%]
22:mesa-libGL-devel
########################################### [ 92%]
23:php-devel
########################################### [ 96%]
24:pkgconfig
########################################### [100%]
2、nagios安装
1)
Create Account Information
以root用户登录,创建nagios账户
[root@cactiez Nagios]# useradd -m nagios
[root@cactiez Nagios]# passwd 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.
[root@cactiez Nagios]# groupadd nagcmd
[root@cactiez Nagios]# usermod -a -G nagcmd nagios
[root@cactiez Nagios]# usermod -a -G nagcmd apache
2)
Compile and Install Nagios
[root@cactiez Nagios]# tar -zxvf nagios-
[root@cactiez Nagios]# cd nagios-
[root@cactiez nagios-
[root@cactiez nagios-
make install-config&&make
install-commandmode
[root@cactiez nagios-
3)
Configure the Web Interface
[root@cactiez nagios-
Create a nagiosadmin account for logging into the Nagios
web interface. Remember the password you assign to this account - you’ll need
it later.
[root@cactiez nagios-
Restart Apache to make the new settings take effect.
[root@cactiez nagios-
4)
Compile and Install the Nagios Plugins
[root@cactiez
Nagios]# tar -zxvf nagios-plugins-
[root@cactiez
Nagios]# cd nagios-plugins-
[root@cactiez
nagios-plugins-
[root@cactiez
nagios-plugins-
5)
Start Nagios
Add Nagios to the list of system services and have it
automatically start when the system boots.
[root@cactiez
nagios-plugins-
[root@cactiez
nagios-plugins-
Verify the sample Nagios configuration files.
[root@cactiez
nagios-plugins-
[root@cactiez
nagios-plugins-
3、NDOUtils安装
[root@cactiez Nagios]# tar -zxvf
ndoutils-1.4b7.tar.gz
[root@cactiez Nagios]# cd ndoutils-1.4b7
[root@cactiez ndoutils-1.4b7]# ./configure
--with-mysql-inc=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql
--enable-mysql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
[root@cactiez ndoutils-1.4b7]# make
copy the sample NDOUtils config files to the Nagios etc/
directory:
[root@cactiez ndoutils-1.4b7]# cd config
[root@cactiez config]# cp ndo2db.cfg ndomod.cfg
/usr/local/nagios/etc/
In order to install the NDOUtils components on your
system, you'll need to copy the compiled binaries into your Nagios binary
directory (usually /usr/local/nagios/bin)
[root@cactiez ndoutils-1.4b7]# cd src/
[root@cactiez src]# cp ndomod-3x.o ndomod.o
[root@cactiez src]# cp ndo2db-3x ndo2db
[root@cactiez src]# cp file2sock log2ndo ndo2db
ndomod.o /usr/local/nagios/bin/
1、
[root@cactiez Nagios]# unzip cacti-plugin-
[root@cactiez Nagios]# cd cacti-plugin-arch/
[root@cactiez cacti-plugin-arch]# cp
cacti-plugin-
[root@cactiez cacti-plugin-arch]# cd
/var/www/html/
[root@cactiez html]# patch -p1 -N <
cacti-plugin-
import the pa.sql file into your mysql database
[root@cactiez html]# mysql -u root -p cacti
4、NPC安装
安装php-json
[root@cactiez
Nagios]# tar jxvf php-json-ext-
[root@cactiez
Nagios]# cd php-json-ext-
[root@cactiez
php-json-ext-
[root@cactiez
php-json-ext-
[root@cactiez
php-json-ext-
安装NPC
[root@cactiez
Nagios]# tar zxvf npc-
[root@cactiez
Nagios]# mv npc/ /var/www/html/plugins
[root@cactiez
Nagios]# vi /var/www/html/include/global.php添加如下行:如图
Install the plugin in Cacti
Next, there are a few NPC settings to add/update. click
the Console tab -> Settings (under Configuration heading) -> NPC tab.
[root@cactiez
Nagios]# vi /usr/local/nagios/etc/nagios.cfg
编辑nagios配置文件,添加或更改如下行内容为:
check_external_commands=1
command_check_interval=-1
event_broker_options=-1
process_performance_data=1
broker_module=/usr/local/nagios/bin/ndomod.o
config_file=/usr/local/nagios/etc/ndomod.cfg
ndo2db_user=nagios
ndo2db_group=nagios
socket_type=tcp
socket_name=/usr/local/nagios/var/ndo.sock
tcp_port=5668
db_servertype=mysql
db_host=localhost
db_port=3306
db_name=DATABSE_NAME
db_user=DATABASE_USER
db_pass=DATABASE_PASSWORD
db_prefix=npc_
max_timedevents_age=1440
max_systemcommands_age=10080
max_servicechecks_age=10080
max_hostchecks_age=10080
max_eventhandlers_age=44640
debug_level=1
debug_verbosity=1
debug_file=/usr/local/nagios/var/ndo2db.debug
max_debug_file_size=1000000
instance_name=default
output_type=tcpsocket
output=127.0.0.1
tcp_port=5668
output_buffer_items=5000
buffer_file=/usr/local/nagios/var/ndomod.tmp
file_rotation_interval=14400
file_rotation_timeout=60
reconnect_interval=15
reconnect_warning_interval=15
data_processing_options=-1
config_output_options=2
[root@cactiez etc]# mysql -u root –p
mysql> grant all privileges on cacti.* to
nagios@localhost identified by 'nagios';
[root@cactiez etc]/usr/local/nagios/bin/ndo2db-2x
-c /usr/local/nagios/etc/ndo2db.cfg
[root@cactiez etc]apachectl restart
[root@cactiez etc]service nagios restart