1、安装rrdtool
#yum install rrdtool
2、安装net-snmp
#yum install net-snmp net-snmp-devel net-snmp-libs net-snmp-utils
3、配置net-snmp
#vim /etc/snmp/snmpd.conf
找到(41行),把default修改为需要主监控IP,这里修改为127.0.0.1:
com2sec notConfigUserdefaultpublic
修改为:
com2sec notConfigUser 127.0.0.1 public
找到(52行):
access notConfigGroup""anynoauth exact systemview none none
修改为:
access notConfigGroup""anynoauth exactallnone none
找到并去除最前面的“#”号(85行):
#viewallincluded .1 80
启动服务并设置开机自动启动
#service snmpd start
#chkconfig snmpd on
测试net-snmp
#snmpwalk -v2c -cpublic127.0.0.1 .1.3.6.1.4.1.2021.10.1.5.1
UCD-SNMP-MIB::laLoadInt.1 = INTEGER: 1
4、Cacti安装及配置
1)、解压cacti到一个web目录
#tar xzf cacti-0.8.8a.tar.gz
#mv cacti-0.8.8a /data/wwwroot/cacti.xxx.com
2)、创建数据库并导入数据
>createdatabasecacti;
>use cacti;
>source /data/wwwroot/cacti.xxx.com/cacti.sql;
>grant all on cacti.* to cacti@'127.0.0.1' identified by 'password';
3)、修改Cacti配置文件
#cd /data/rsync/data/wwwroot/cacti.xxx.com/
#vim include/config.php
修改数据库配置为上面的设置:
$database_type ="mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "Jyw8!k;j>mOdq=Cucap-G%5Tsaaxax1V";
$database_port = "3306";
$database_ssl = false;
$url_path = "/";
3)、初始化Cacti
#groupadd -g 2000 cacti
#useradd -u 2000 -g cacti -d /data/cacti -M cacti
#chown cacti:cacti /data/rsync/data/wwwroot/cacti.xxx.com/ -R
WEB打开http://cacti.xxx.com/install/进行安装Cacti
#su - cacti
#env LANG=C /usr/local/php-5.3.xx/bin/php /data/rsync/data/wwwroot/cacti.xxx.com/poller.php
4)、计划任务
* * * * * root env LANG=C /usr/local/php-5.3.xx/bin/php /data/rsync/data/wwwroot/cacti.xxx.com/poller.php >> /data/logs/cacti.log 2>&1