Cacti和Nagios是现在使用比较多的网络监控软件了,对于这两款监控软件的区别,应该说是侧重点的不同。
Cacti比较着重于直观数据的监控,易于生成图形,用来监控网络流量、cpu使用率、硬盘使用率等可以说很在合适不过。而Nagios则比较注重于主机和服务的监控,并且有很强大的发送报警信息的功能。把两者结合起来,既可以使报警机制高效及时,又可以很容易的查看各项数据的情况。整合Nagios和Cacti是通过ndo2数据库来中转数据的,Nagios先把监控的数据保存到ndo2数据库,Cacti再通过读取数据库里的内容,将Nagios监控的信息通过NPC插件显示出来。
注意:整合后的Cacti不会直接对Nagios监控的内容绘图,如果需要绘图需要单独配置。
- [root@nagios ~]#yum –y install mysql-devel
- [root@nagios ~]#wget http://nchc.dl.sourceforge.net/sourceforge/nagios/ndoutils-1.4b7.tar.gz
- [root@nagios ~]#tar fvxz ndoutils-1.4b7.tar.gz
- [root@nagios ~]#cd ndoutils
- [root@nagios ndoutils]#./configure --prefix=/usr/local/nagios LDFLAGS=-L/usr/lib --with-mysql-inc=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql --enable-mysql --disable-pgsql --with-ndo2db-user=nagios --with-ndo2db-group=nagios
- [root@nagios ndoutils]#make
- #这里注意mysql的用户名和密码均为cacti要自定义,并注意空格
- [root@nagios ndoutils]#./db/installdb -ucacti -pcacti -d cacti
- [root@nagios ndoutils]#cp config/ndomod.cfg /usr/local/nagios/etc
- [root@nagios ~]#vim /usr/local/nagios/etc/nagios.cfg
- check_external_commands=1
- command_check_interval=-1
- event_broker_options=-1
- broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
- process_performance_data=1
- [root@nagios ndoutils]#cd src
- [root@nagios src]#cp ndomod-3x.o ndo2db-3x log2ndo file2sock /usr/local/nagios/bin
- [root@nagios src]#cp ndo2db-3x /usr/local/nagios/bin/ndo2db
- [root@nagios src]#mv /usr/local/nagios/bin/ndomod-3x.o /usr/local/nagios/bin/ndomod.o
- [root@nagios src]#cp ../config/ndo2db.cfg /usr/local/nagios/etc
- [root@nagios src]#vim /usr/local/nagios/etc/ndomod.cfg
- instance_name=default
- output_type=tcpsocket
- output=localhost
- tcp_port=5668
- output_buffer=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_optiongs=-1
- config_output_options=2
- [root@nagios src]#vim /usr/local/nagios/etc/ndo2db.cfg
- ndo2db_usr=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=cacti
- db_user=cacti
- db_pass=cacti
- db_prefix=npc_
- max_timedevents_age=1440
- max_systemconmmands_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@nagios ~]#/usr/local/nagios/bin/ndo2db –c /usr/local/nagios/etc/ndo2db.cfg
- [root@nagios ~]#yum –y install php-devel
- [root@nagios ~]#wget http://pkgs.fedoraproject.org/repo/pkgs/php-json/php-json-ext-1.2.1.tar.bz2/e06e701412a055f3372775216ec3d604/php-json-ext-1.2.1.tar.bz2
- [root@nagios ~]#tar fvxj php-json-ext-1.2.0.tar.bz2
- [root@nagios ~]#cd php-json-ext-1.2.0
- [root@nagios php-json-ext-1.2.1]#phpsize
- [root@nagios php-json-ext-1.2.1]#./configure
- [root@nagios php-json-ext-1.2.1]#make && make install
- [root@nagios php-json-ext-1.2.1]#vim /etc/php.d/json.ini
- extension=php_json.so
- [root@nagios php-json-ext-1.2.1]#cp /usr/lib/php/modules/json.so /usr/lib/php/modules/php_json.so
- <?php
- phpinfo();
- ?>
- [root@nagios ~]#mv npc /var/www/cacti/plugins/