cacti 安装流程

#配置环境CentOS release 6.4 (Final)  2.6.32-358.el6.i686

clip_image002
yum -y  wget install rpm-build crontabs httpd* mysql* php* libart_lgpl* net-snmp* libtool gcc gcc-c++ --skip-broken

在安装期间,发现连接断开了,ssh也允许了,发现,虚拟机中动态获取的ip,发生了变化!重连.
mkdir -p /data0/soft/cacti
cd /data0/soft/cacti
yum install rrdtool ntpdate  -y
ntpdate asia.pool.ntp.org
#因为cactid 与spine功能一样,先不安装cactid
wget  http://www.cacti.net/downloads/spine/cacti-spine-0.8.8a.tar.gz
tar zxvf cacti-spine-0.8.8a.tar.gz
  cd cacti-spine-0.8.8a
./configure
  make && make install
cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf
在这里将原来的snmpd.conf文件,备份下!
  echo "com2sec notConfigUser default 000123a" > /etc/snmp/snmpd.conf
echo "group notConfigGroup v1 notConfigUser" >> /etc/snmp/snmpd.conf
echo "group notConfigGroup v2c notConfigUser" >> /etc/snmp/snmpd.conf
echo "view systemview included .1.3.6.1.2.1.1" >> /etc/snmp/snmpd.conf
echo "view systemview included .1.3.6.1.2.1.25.1.1" >> /etc/snmp/snmpd.conf
echo "access notConfigGroup \"\" any noauth exact all none none" >> /etc/snmp/snmpd.conf
echo "view all included .1 80" >> /etc/snmp/snmpd.conf
echo "syslocation Unknown (edit /etc/snmp/snmpd.conf)" >> /etc/snmp/snmpd.conf
echo "syscontact Root (configure /etc/snmp/snmp.local.conf)" >> /etc/snmp/snmpd.conf
service snmpd restart
chkconfig --level 2345 snmpd on
chkconfig --level 2345 httpd on
chkconfig --level 2345 mysqld on
/etc/init.d/httpd  restart
/etc/init.d/mysqld restart
cd /data0/soft
wget  http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz
tar xvf cacti-0.8.8a.tar.gz
mkdir -p /var/www/cacti
mv -f cacti-0.8.8a/* /var/www/cacti

cd /var/www/cacti
#编辑include/global.php   第47行 修改$url_path = "/cacti/"; 为$url_path = "/";
cacti_Dir=/var/www/cacti
[root@gjp cacti]# scp -P 2121 bj04.lonlife.net:/var/www/cacti/graphs_new_batch.php ./
sed -i 's#Cacti#'$HOSTNAME'#' $cacti_Dir/include/top_header.php
sed -i 's#Cacti#'$HOSTNAME'#' $cacti_Dir/graphs_new_batch.php
sed -i 's#Cacti#'$HOSTNAME'#' $cacti_Dir/include/auth.php
sed -i 's#Cacti#'$HOSTNAME'#' $cacti_Dir/include/top_graph_header.php
sed -i 's#Cacti#'$HOSTNAME'#' $cacti_Dir/install/index.php
sed -i 's#Cacti#'$HOSTNAME'#' $cacti_Dir/lib/graph_export.php
[root@gjp cacti]# scp -P 2121 bj04.lonlife.net:/home/testbj03/www/cacti/graph_xport2.php ./

root@bj04.lonlife.net's password:

graph_xport2.php 100% 3554 3.5KB/s 00:00
echo "10 0 * * * /usr/bin/php /var/www/html/graph_xport2.php" >> /var/spool/cron/root
#编辑/etc/php.ini 文件 设置date.timezone = 'Asia/Shanghai'
echo 'create database cacti;
grant all on cacti.* to cactiuser@localhost identified by "cactiuser";
use cacti
source /var/www/cacti/cacti.sql' | mysql
cacti_dir=/var/www/cacti
useradd -d $cacti_dir cacti
chown cacti:cacti -R $cacti_dir
chmod 755 -R $cacti_dir
chmod 777 -R $cacti_dir/rra
sed -i 's#Listen 443##' /etc/httpd/conf.d/ssl.conf
sed -i 's#Listen 80#Listen 1080#' /etc/httpd/conf/httpd.conf
sed -i 's#AddDefaultCharset UTF-8#AddDefaultCharset off#' /etc/httpd/conf/httpd.conf
sed -i 's#/var/www/html#/var/www/cacti#g' /etc/httpd/conf/httpd.conf
sed -i 's#128M#1024M#' /etc/php.ini
sed -i "s#{#{\nsize=10M\nrotate 4#g" /etc/logrotate.d/httpd
sed -i "s#/var/www/html#/var/www/cacti#g" /etc/httpd/conf/httpd.conf

[root@gjp cacti]# vim /etc/httpd/conf/httpd.conf

clip_image004
service httpd restart

clip_image006

clip_image008

echo "*/5 * * * * /usr/bin/php $cacti_dir/poller.php > /dev/null 2>&1" >> /var/spool/cron/cacti
注意php.ini里时区要跟系统时区一直(系统时区在/etc/sysconfig/clock)
rra文件夹下文件要是cacti用户权限
clip_image010

clip_image012

clip_image014

clip_image016

与上面是一个图,只要出现FILE  FOUND  就ok

clip_image018

默认用户名和密码:admin

clip_image020

这里修改为123456

clip_image022

在这里,进行如下修改:

settings > Paths > Spine Poller File Path > /usr/local/spine/bin/spine

clip_image024

Poller > Poller Type > spine

clip_image026

Import/Export > Import Templates > adv-ping见附件clip_image028

导入成功: clip_image030
Management > Devices > Host Template 选择 ucd/net SNMP Host > SNMP Options > Version2 > SNMP Community 000123a > save

clip_image032
Management > Devices > 选择服务器 > Create Graphs for this Host > 勾上启用的网卡号 如 eth0/eth1 > create

clip_image034

建立ping监控
http://xxxx.lonlife.net:1080/graphs_new_batch.php > 建立到要求ip的监控

例如:

clip_image036

clip_image038

cacti 每5分钟抓取下数据,现在数据已经呈现:

clip_image040