Cacti Server IP: 192.168.0.171
Centos 5 x86
安装包
# yum -y install httpd php php-mysql php-snmp mysql-server perl-DBD-MySQL php-pdo net-snmp net-snmp-libs net-snmp-utils net-snmp-devel ruby ruby-devel
# chkconfig httpd on
# chkconfig mysqld on
# chkconfig snmpd on
/etc/init.d/httpd start
/etc/init/d/mysqld start
/etc/init.d/snmpd start
安装rrdtool
yum install cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel
cd /usr/local/src/rrdtool-1.4.5
./configure --prefix=/usr/local/rrdtool
make
make install
mysql 添加数据库,用户
mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on cacti.* to cacti@'localhost' identified by 'cacti888';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> Bye
############################################
cacti
############################################
tar xf cacti-0.8.7g.tar.gz
mv cacti-0.8.7g /data/www/cacti
cd /data/www/cacti
导入cacti数据库
# mysql -ucacti -pcacti888 cacti<cacti.sql
修改配置文件
# vim include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti888";
修改apache配置文件开启虚拟机
<VirtualHost *:80>
ServerName www.cacti.com
DocumentRoot "/data/www/
DirectoryIndex index.php
<Directory "/data/www">
Options -Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
启动httpd 测试cacti
修改snmpd.conf
# vim snmpd.conf
com2sec notConfigUser 192.168.0.171 nick
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
access notConfigGroup "" any noauth exact all none none
view all included .1 80
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat
重启snmpd服务
# /etc/init.d/snmpd restart
手动执行查询数据,是不是有数据显示
/usr/bin/php /data/www/cacti/poller.php
查看 /data/www/cacti/rra 是不是有数据文件
增加入一个计划任务,使得 cacti 每分钟生成一个监控图表。
*/1 * * * * /usr/bin/php /data/www/cacti/poller.php > /dev/null &2>1
添加插件 cacti-plugin 扩展cacti架构
tar xf cacti-plugin-0.8.7g-PA-v2.8.tar.gz
cd cacti-plugin-arch/
cp cacti-plugin-0.8.7g-PA-v2.8.diff /data/www/cacti/
cp pa.sql /data/www/cacti/
cd /data/www/cacti/
打补丁
patch -p1 <cacti-plugin-0.8.7g-PA-v2.8.diff
导入数据
mysql -ucacti -pcacti888 cacti <pa.sql
修改配置文件
vim include/global.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti888";
测试游览器,如果打不开网页修改 include/config.php
$url_path="/"; 修改为 $usl_path="/cact/";
cacti配置
console --》 user mamagerment ---》 admin 在 realm permissons
选项中打开 plugin managerment --> save
settings 安装 邮件报警
tar xf settings-v0.71-1.tgz
mv settings /data/www/cacti/plugins/
monitor 图形方式显示设备
tar xf monitor-v1.3-1.tgz
mv monitor /data/www/cacti/plugins
thold 设备异常报警
tail xf thold-v0.4.9-3.tgz
mv thold /data/www/cacti/plugins
weathermap 网络状况视图
unzip php-weathermap-0.97a\(1\).zip
mv weathermap/ /data/www/cacti/plugins
chmod -R 777 /data/www/cacti/plugins/weathermap/
图形配置
console ==》 plugin management
监控linux服务器
yum -y install net-snmp
vim /etc/snmp/snmpd.conf
com2sec notConfigUser 192.168.0.171 nick
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
access notConfigGroup "" any noauth exact all none none
view all included .1 80
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
pass .1.3.6.1.4.1.4413.4.1 /usr/bin/ucd5820stat
/etc/init.d/snmpd start
chkconfig snmpd on