1.系统环境
# uname -a Linux 10-6-8-200 2.6.32-279.22.1.el6.x86_64 #1 SMP Wed Feb 6 03:10:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux # cat /etc/redhat-release CentOS release 6.3 (Final) Nagios Stats 3.5.0 cacti-0.8.7e
2.下载包
ndoutils-1.4b9.tar.gz npc-2.0.4.tar.gz
3.解压编译安装
# tar zxf ndoutils-1.4b9.tar.gz # cd ndoutils-1.4b9 # ./configure --prefix=/usr/local/nagios/ --sysconfdir=/usr/local/nagios/etc/ --enable-mysql --disable-pgsql # make # make install ##这步可以省略
4.拷贝命令
#cp src/{ndomd-3x.o,ndo2db-3x,file2sock,log2ndo} /usr/local/nagios/bin/
5.更改命令权限
# chown nagios.nagios /usr/local/nagios/bin/ndo* # chmod 644 /usr/local/nagios/bin/ndo*
6.编辑配置文件
# vi /usr/local/nagios/etc/ndo2db.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=xxxx 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=0 debug_verbosity=1 debug_file=/usr/local/nagios//var/ndo2db.debug max_debug_file_size=1000000
# vi /usr/local/nagios/etc/ndomod.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
7.修改nagios的配置文件
# vi /usr/local/nagios/etc/nagios.cfg event_broker_options=-1 broker_module=/usr/local/nagios/bin/ndomod-3x.o config_file=/usr/local/nagios/etc/ndomod.cfg
8.修改数据库
# mysql -ucacti -p mysql> use catci; mysql> alter table npc_eventhandlers add long_output TEXT NOT NULL default '' after output; mysql> alter table npc_hostchecks add long_output TEXT NOT NULL default '' after output; mysql> alter table npc_hoststatus add long_output TEXT NOT NULL default '' after output; mysql> alter table npc_notifications add long_output TEXT NOT NULL default '' after output; mysql> alter table npc_servicechecks add long_output TEXT NOT NULL default '' after output; mysql> alter table npc_servicestatus add long_output TEXT NOT NULL default '' after output; mysql> alter table npc_statehistory add long_output TEXT NOT NULL default '' after output; mysql> alter table npc_systemcommands add long_output TEXT NOT NULL default '' after output;
9.拷贝服务启动脚本
# cp daemon-init /etc/init.d/ndo2db # chmod +x /etc/init.d/ndo2db # chkconfig --add ndo2db # chkconfig --level 35 ndo2db on # service ndo2db start # service nagios restart
10.解压npc,并拷贝到cacti目录
# tar zxf npc-2.0.4.tar.gz # mv npc/ /var/www/html/cacti/plugin/
11.打开网页进入cacti
console--->Configuration--->Plugin Management--->Npc
转载于:https://blog.51cto.com/charlie928/1303782