三种监控平台配置及其整合(Cacti Nagios Ganglia)
三种软件的官方文档地址:
cacti:http://docs.cacti.net/manual:087:1_installation#installation
nagios:http://www.nagios.org/documentation
ganglia:http://ganglia.info/
在监控平台领域,这三款监控软件各有所长各有所短,这篇文档先介绍三款软件的安装配置方法,然后再将三种软件整合起来,使得每款软件的优点得到利用。
系统环境:rhel6 selinux and iptables disabled
cacti:
cacti软件通过net-snmp协议定时采集主机信息,并保存在mysql数据库中,当用户要查看的时候数据库中找到对应的rra文件,通过rrdtool软件进行绘图,然后将图形返回给用户。他的优势在于可以生成直观的报表。
所以cacti运行的前提是安装了rrdtool,mysql,php以及一个网页发布程序,本文采用apache。
首先安装需要的软件及依赖性:
# yum install httpd mysql mysql-server mysql-devel php php-mysql php-snmp net-snmp net-snmp-utils net-snmp-libs net-snmp-devel libart_lgpl-devel libpng-devel freetype-devel cairo-devel pango-devel gcc make
注意php-snmp包在Optional库里
安装好以后启动mysql和apache
# /etc/init.d/httpd start # /etc/init.d/mysqld start
配置PHP:只需要修改/etc/php.ini文件,将时区设置为上海:
date.timezone = Asia/shanghai
配置snmp:
cacti官方文档中snmp的配置过于繁琐,建议按照http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/mrtg/mrtg_config_step_3.php中的步骤进行配置。
# vi /etc/snmp/snmpd.conf
对配置中的一些语句进行替换
#com2sec notConfigUser default public com2sec local localhost public com2sec mynetwork 192.168.0.0/24 public #group notConfigGroup v1 notConfigUser #group notConfigGroup v2c notConfigUser group MyRWGroup v1 local group MyRWGroup v2c local group MyRWGroup usm local group MyROGroup v1 mynetwork group MyROGroup v2c mynetwork group MyROGroup usm mynetwork #view systemview included .1.3.6.1.2.1.1 #view systemview included .1.3.6.1.2.1.25.1.1 view all included .1 #access notConfigGroup "" any noauth exact systemview none none access MyROGroup "" any noauth exact all none none access MyRWGroup "" any noauth exact all all none #syslocation Unknown (edit /etc/snmp/snmpd.conf) #syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf) syslocation Linux (RH3_UP2), Home Linux Router. syscontact yejk <[email protected]>
# chkconfig snmpd on # service snmpd start
安装rrdtool
# yum install libxml2-devel # tar zxf rrdtool-1.4.4.tar.gz # cd rrdtool-1.4.4 # ./configure # make # make install # ln -s /opt/rrdtool-1.4.4/bin/rrdtool /usr/local/bin
安装cacti:
# tar zxf cacti-0.8.7h.tar.gz # mv cacti-0.8.7h /var/www/html/cacti # cd /var/www/html/cacti/ # useradd cacti # chown -R cacti rra log # mysql cacti < cacti.sql
在数据库中创建一个供cacti使用的用户,仅有对cacti库操作的权限:
# vim include/config.php $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cacti"; $database_password = "cacti"; $database_port = "3306"; $database_ssl = false; $url_path = "/cacti/";