linux下cacti的搭建之詳細過程!

科技小能手發表於2017-11-12

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#{#{
size=10M
rotate 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

本文轉自 gjp0731 51CTO部落格,原文連結:http://blog.51cto.com/guojiping/1289379


相關文章