2010年6月24日 星期四

[Cacti][Nagios] 安裝nagios plugin for Cacti (一) 未完...

yum -y install nagios nagios-plugins

nagios Configure

此時需要configure apache for nagios
[root@localhost conf.d]# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
[root@localhost conf.d]#

[root@localhost conf.d]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@localhost conf.d]#

php-json Installation steps on CentOs 5.3 include
[root@localhost conf.d]# yum -y install php-devel php-pear gcc
[root@localhost conf.d]# pear install pecl/json
........

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).

running: make INSTALL_ROOT="/var/tmp/pear-build-root/install-json-1.2.1" install
Installing shared extensions: /var/tmp/pear-build-root/install-json-1.2.1/usr/lib/php/modules/
running: find "/var/tmp/pear-build-root/install-json-1.2.1" -ls
919127 4 drwxr-xr-x 3 root root 4096 Jun 14 15:41 /var/tmp/pear-build-root/install-json-1.2.1
919154 4 drwxr-xr-x 3 root root 4096 Jun 14 15:41 /var/tmp/pear-build-root/install-json-1.2.1/usr
919155 4 drwxr-xr-x 3 root root 4096 Jun 14 15:41 /var/tmp/pear-build-root/install-json-1.2.1/usr/lib
919156 4 drwxr-xr-x 3 root root 4096 Jun 14 15:41 /var/tmp/pear-build-root/install-json-1.2.1/usr/lib/php
919157 4 drwxr-xr-x 2 root root 4096 Jun 14 15:41 /var/tmp/pear-build-root/install-json-1.2.1/usr/lib/php/modules
919153 80 -rwxr-xr-x 1 root root 76122 Jun 14 15:41 /var/tmp/pear-build-root/install-json-1.2.1/usr/lib/php/modules/json.so

Build process completed successfully
Installing '/var/tmp/pear-build-root/install-json-1.2.1//usr/lib/php/modules/json.so'
install ok: channel://pear.php.net/json-1.2.1

[root@localhost conf.d]# cd /etc/php.d
[root@localhost php.d]# vim json.ini
[root@localhost php.d]# echo "extension=json.so" > json.ini
[root@localhost php.d]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@localhost php.d]#


After that phpinfo() would output

json support enabled
json version 1.2.1


安裝 ndoutils
download ndoutils-1.4b9.tar.gz
[root@localhost config]# tar zxvf ndoutils-1.4b9.tar.gz
[root@localhost config]# cd ndoutils-1.4b9
[root@localhost config]# ./configure
[root@localhost config]# make clean
[root@localhost config]# make

###copy file
[root@localhost config]# cd src
[root@localhost config]# cp ndomod-3x.o ndo2db-3x log2ndo file2sock /usr/bin/
[root@localhost config]# cd ../config
[root@localhost config]# cp ndo2db.cfg-sample ndomod.cfg-sample /etc/nagios/
[root@localhost config]# cd /etc/nagios/
[root@localhost nagios]# cp ndo2db.cfg-sample ndo2db.cfg
[root@localhost nagios]# cp ndomod.cfg-sample ndomod.cfg

change Configure
[root@localhost nagios]#vim /etc/nagios/ndo2db.cfg

socket_name=/var/nagios/ndo.sock
db_name=cacti
db_prefix=npc_
db_user=cacti
db_pass=cacti
debug_level=1
debug_file=/var/log/ndo2db.debug

[root@localhost nagios]# vim /etc/nagios/ndomod.cfg
output=/var/nagios/ndo.sock
buffer_file=/var/nagios/ndomod.tmp
[root@localhost nagios]# vim /etc/nagios/nagios.cfg
check_external_commands=1
command_check_interval = -1
event_broker_options = -1
#20100622 Change By Yen
broker_module = /usr/bin/ndomod-3x.o config_file=/etc/nagios/ndomod.cfg
#20100622 Change By Yen
process_performance_data=1

安裝NPC
download npc-2.0.4.tar.gz
[root@localhost nagios]# tar -zxvf npc-2.0.4.tar.gz
# 複製npc 到Cacti 的 plugins 裡面
[root@localhost nagios]# cp -pRP npc /var/www/html/plugins/.
[root@localhost nagios]#

在Cacti 裡面新增 npc 這個plugin
[root@localhost nagios]# vim /var/www/html/include/global.php
$plugins[] = 'npc';

使用有管理權限的User ,
登入 Cacti 以後,
Console -> Configuration->Plugin Management -> Install (NPC)
Console -> Configuration->Plugin Management -> Enable (NPC)
Console -> User Management -> (Edit) ->Realm Permissions (check NPC 權限是否已設定)

###
可能出現的問題
1.npc頁面空白
確認安裝並配置php-json正確


沒有留言: