Chinaunix首页 | 论坛 | 博客
  • 博客访问: 174935
  • 博文数量: 29
  • 博客积分: 2110
  • 博客等级: 大尉
  • 技术积分: 325
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-01 11:32
文章分类

全部博文(29)

文章存档

2012年(3)

2010年(4)

2009年(5)

2007年(16)

2006年(1)

我的朋友

分类: LINUX

2010-08-12 17:55:18

CactiEZ中文0.91+Nagios集成

 

环境描述:

CactiEZ 中文0.91 (Red Hat Enterprise Linux Server release 5.2 (Tikanga))

 

待按照软件及包:

Nagios3.2.1

nagios-plugins-1.4.15.tar.gz

ndoutils-1.4b7.tar.gz

npc-2.0.4.tar.gz

php-json-ext-1.2.1.tar.bz2

cacti-plugin-0.8.7e-PA-v2.6.zip

autoconf-2.59-12.noarch.rpm           

libgomp-4.1.2-42.el5.i386.rpm

automake-1.9.6-2.1.noarch.rpm         

libjpeg-devel-6b-37.i386.rpm

cpp-4.1.2-42.el5.i386.rpm             

libpng-devel-1.2.10-7.1.el5_0.1.i386.rpm

fontconfig-devel-2.4.1-7.el5.i386.rpm 

libX11-devel-1.0.3-9.el5.i386.rpm

freetype-devel-2.2.1-19.el5.i386.rpm  

libXau-devel-1.0.1-3.1.i386.rpm

gcc-4.1.2-42.el5.i386.rpm             

libXdmcp-devel-1.0.1-2.1.i386.rpm

gd-2.0.33-9.4.el5_1.1.i386.rpm        

libXpm-3.5.5-3.i386.rpm

gd-devel-2.0.33-9.4.el5_1.1.i386.rpm  

libXpm-devel-3.5.5-3.i386.rpm           mesa-libGL-devel-6.5.1-7.5.el5.i386.rpm

glibc-devel-2.5-24.i386.rpm           

php-devel-5.1.6-20.el5.i386.rpm

glibc-headers-2.5-24.i386.rpm         

pkgconfig-0.21-2.el5.i386.rpm

imake-1.0.2-3.i386.rpm                

xorg-x11-proto-devel-7.1-9.fc6.i386.rpm

kernel-headers-2.6.18-92.el5.i386.rpm

 

安装步骤:

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%]

 

2nagios安装

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-3.2.1.tar.gz

[root@cactiez Nagios]# cd nagios-3.2.1

[root@cactiez nagios-3.2.1]# ./configure --with-command-group=nagcmd

[root@cactiez nagios-3.2.1]# make all && make install &&make install-init&&\

make install-config&&make install-commandmode

    [root@cactiez nagios-3.2.1]# vi /usr/local/nagios/etc/objects/contacts.cfg 编辑下行:如图

3)      Configure the Web Interface

[root@cactiez nagios-3.2.1]# make install-webconf

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-3.2.1]# htpasswd –c usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart Apache to make the new settings take effect.

[root@cactiez nagios-3.2.1]# service httpd restart

4)      Compile and Install the Nagios Plugins

[root@cactiez Nagios]# tar -zxvf nagios-plugins-1.4.15.tar.gz

[root@cactiez Nagios]# cd nagios-plugins-1.4.15

[root@cactiez nagios-plugins-1.4.15]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

[root@cactiez nagios-plugins-1.4.15]# make && make install

5)      Start Nagios

Add Nagios to the list of system services and have it automatically start when the system boots.

[root@cactiez nagios-plugins-1.4.15]# chkconfig --add nagios

[root@cactiez nagios-plugins-1.4.15]# chkconfig nagios on

Verify the sample Nagios configuration files.

[root@cactiez nagios-plugins-1.4.15]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

[root@cactiez nagios-plugins-1.4.15]# service nagios restart

 

3NDOUtils安装

[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-0.8.7e-PA-v2.6.zip

[root@cactiez Nagios]# cd cacti-plugin-arch/

[root@cactiez cacti-plugin-arch]# cp cacti-plugin-0.8.7e-PA-v2.6.diff pa.sql /var/www/html/

[root@cactiez cacti-plugin-arch]# cd /var/www/html/

[root@cactiez html]# patch -p1 -N < cacti-plugin-0.8.7e-PA-v2.6.diff

import the pa.sql file into your mysql database

[root@cactiez html]# mysql -u root -p  cacti

 

4NPC安装

安装php-json

[root@cactiez Nagios]# tar jxvf php-json-ext-1.2.1.tar.bz2

[root@cactiez Nagios]# cd php-json-ext-1.2.1

[root@cactiez php-json-ext-1.2.1]# phpize

[root@cactiez php-json-ext-1.2.1]# ./configure &&make &&make install

[root@cactiez php-json-ext-1.2.1]# echo "extension=json.so">/etc/php.d/json.ini

安装NPC

[root@cactiez Nagios]# tar zxvf npc-2.0.4.tar.gz

[root@cactiez Nagios]# mv npc/ /var/www/html/plugins

[root@cactiez Nagios]# vi /var/www/html/include/global.php添加如下行:如图

Install the plugin in Cacti

  • Go to 控制台 -> 插件管理 -> Uninstalled
  • Click the Install link under the npc section
  • Next, click the Installed tab
  • To enable NPC click the Enable link under the npc section

 

Next, there are a few NPC settings to add/update. click the Console tab -> Settings (under Configuration heading) -> NPC tab.

  • Remote Commands
    • Check the checkbox to enable remote commands. At the moment this is system wide so all users that can access NPC will be able to execute commands.
  • Nagios Command File Path
    • Add the path to the nagios command file. It will be something like /usr/local/nagios/var/rw/nagios.cmd
  • Nagios URL
    • The URL to the Nagios web interface is used to get access to the status map and reporting CGI's. You can also access the Nagios UI by clicking the "Nagios" link in the left hand "Navigation" pane in NPC.
  • Set the date and time format to your liking.

Configuring Nagios

 [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

Configuring NDO2DB

[root@cactiez etc]# vi /usr/local/nagios/etc/ndo2db.cfg

/usr/local/nagios/etc/ndo2db.cfg and add/update the following parameters:

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

[root@cactiez etc]# vi /usr/local/nagios/etc/ndomod.cfg

Edit /usr/local/nagios/etc/ndomod.cfg and add/update the following parameters:

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

 

创建cacti 数据库用户并赋予权限

[root@cactiez etc]# mysql -u root –p

mysql> grant all privileges on cacti.* to nagios@localhost identified by 'nagios';

启动ndo2db daemon

[root@cactiez etc]/usr/local/nagios/bin/ndo2db-2x -c /usr/local/nagios/etc/ndo2db.cfg

重启apache

[root@cactiez etc]apachectl restart

重启nagios

[root@cactiez etc]service nagios restart

 

至此nagios + cacti v0.91整合完成,如下为测试页面

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