您好,登錄后才能下訂單哦!
Ngios plugin forcacti(NPC)
1.實驗環境:
rhel6.3
cacti,ngios主機:desk32.example.com192.168.122.32
需要的安裝包:
ndoutils-1.4b9.tar.gz
php-devel-5.3.3-3.el6_2.8.x86_64.rpm
PDO_MYSQL-1.0.2.tgz
cacti的安裝配置參見:http://wangziyin.blog.51cto.com/6948950/1305443
nagios的安裝配置參見:http://wangziyin.blog.51cto.com/6948950/1305465
2.NPC的安裝配置:
(1).npc是cacti的一個插件,其作用是將nagios的監控信息整合到cacti的監控頁面中。
(2).npc的安裝:
首先確保你的php 支持 pdo 和json 模塊
選擇Setting
選擇NPC:
保存退出,
[root@desk32 ~]# vim/usr/local/nagios/etc/nagios.cfg
broker_module=/usr/local/nagios/bin/ndomod.oconfig_file=/usr/local/nagios/etc/ndomod.cfg
[root@desk32 ~]# tar zxf ndoutils-1.4b9.tar.gz
[root@desk32ndoutils-1.4b9]# ./configure –enable-mysql
[root@desk32ndoutils-1.4b9]# make && make install
[root@desk32ndoutils-1.4b9]# cd src/
[root@desk32 src]# cpndomod-3x.o /usr/local/nagios/bin/ndomod.o
[root@desk32 src]# cpndo2db-3x /usr/local/nagios/bin/ndo2db
[root@desk32 src]# cd../config
[root@desk32 config]# cpndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
[root@desk32 config]# cpndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
[root@desk32 config]# cd/usr/local/nagios/bin/
[root@desk32 bin]# chownnagios.nagios * -R
[root@desk32 bin]# cd/usr/local/nagios/etc/
[root@desk32 etc]# chownnagios.nagios * -R
[root@desk32 etc]# vimndo2db.cfg
lock_file=/usr/local/nagios/var/ndo2db.lock
ndo2db_user=nagios
ndo2db_group=nagios
socket_type=tcp
socket_name=/usr/local/nagios/var/ndo.sock
tcp_port=5668
use_ssl=0
db_servertype=mysql
db_host=localhost
db_port=3306
db_name=cacti
db_prefix=npc_
db_user=cacti
db_pass=cacti
max_timedevents_age=1440
max_systemcommands_age=10080
max_servicechecks_age=10080
max_hostchecks_age=10080
max_eventhandlers_age=44640
max_externalcommands_age=44640
debug_level=1
debug_verbosity=1
debug_file=/usr/local/nagios/var/ndo2db.debug
max_debug_file_size=1000000
[root@desk32 etc]# vimndomod.cfg
instance_name=default
output_type=tcpsocket
output=127.0.0.1
tcp_port=5668
use_ssl=0
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@desk32 etc]#/usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg
沒有報錯即可
[root@desk32 etc]# ps ax
6798? Ss 0:00 /usr/local/nagios/bin/ndo2db -c/usr/local/nagios/etc/ndo2db.cfg
[root@desk32 etc]#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
[root@desk32 etc]#/etc/init.d/nagios restart
[root@desk32 html]# vim/var/www/html/cacti/include/config.php
打開:$cacti_session_name= "Cacti";
測試:
http://desk32/cacti
選擇NPC插件:
然后選擇Reporting下的Nagios:
可以看見cacti下可以查看nagios的頁面.
此時執行cat /var/log/messages 可看到如下報錯:
Aug 3003:51:18 desk32 ndo2db: mysql_error: 'Unknown column 'long_output' in'field list''
在NPC下的
所有的界面都沒有顯示:
解決方法如下:
[root@desk32 ~]# mysql-pwestos cacti < add.sql
[root@desk32 ~]# cat add.sql
ALTERTABLE `npc_hostchecks` ADD COLUMN `long_output` varchar(8192) NOTNULL default '' AFTER `output`;
ALTERTABLE `npc_hoststatus` ADD COLUMN `long_output` varchar(8192) NOTNULL default '' AFTER `output`;
ALTERTABLE `npc_servicechecks` ADD COLUMN `long_output` varchar(8192) NOTNULL default '' AFTER `output`;
ALTERTABLE `npc_servicestatus` ADD COLUMN `long_output` varchar(8192) NOTNULL default '' AFTER `output`;
ALTERTABLE `npc_statehistory` ADD COLUMN `long_output` varchar(8192) NOTNULL default '' AFTER `output`;
ALTERTABLE `npc_eventhandlers` ADD COLUMN `long_output` varchar(8192) NOTNULL default '' AFTER `output`;
ALTERTABLE `npc_systemcommands` ADD COLUMN `long_output` varchar(8192) NOTNULL default '' AFTER `output`;
ALTERTABLE `npc_notifications` ADD COLUMN `long_output` varchar(8192) NOTNULL default '' AFTER `output`;
[root@desk32 ~]# tar zxfPDO_MYSQL-1.0.2.tgz
[root@desk32 ~]# cdPDO_MYSQL-1.0.2
[root@desk32 ~]# rpm -ivhphp-devel-5.3.3-3.el6_2.8.x86_64.rpm
[root@desk32PDO_MYSQL-1.0.2]# phpize
如果是源碼安裝的php與mysql的化可能會出現找不到include文件,與mysql的位置:
{# ln -s/usr/local/lnmp/mysql/include/* /usr/local/include/
[# ./configure --with-php-config=/usr/local/lnmp/php/bin/php-config–with-pdo-mysql=/usr/local/lnmp/mysql/
}
[root@desk32PDO_MYSQL-1.0.2]# ./configure
[root@desk32PDO_MYSQL-1.0.2]# make
[root@desk32PDO_MYSQL-1.0.2]# make install
[root@desk32PDO_MYSQL-1.0.2]# vim /etc/php.ini
添加:extension=pdo_mysql.so
測試:
[root@desk32 html]# vim/var/www/html/index.php
<?php
phpinfo();
?>
http://desk32/index.php
出現php包含了pdo_mysql模塊,即可以:
再訪問cacti:http://desk32/cacti
一切搞定.有什么問題聯系!!!!!
西安石油大學計算機學院
王茲銀
904483782
mailofwzy@qq.com
2013-10-07
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。