天天看點

Linux下cacti的安裝與配置

1.安裝net-snmp

yum -y install net-snmp net-snmp-libs net-snmp-utils

2.配置net-snmp

vim /etc/snmpd.conf

view    systemview    included   .1.3.6.1.2.1.1 修改為

view    systemview    included   .1.3.6.1.2.1.

3啟動snmp

service snmpd start

4.安裝rrdtool

wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz

tar -xzf rrdtool-1.4.7.tar.gz

cd rrdtool-1.4.7

./configure --prefix=/usr/local/

如果報錯lib*,則需要安裝如下

yum -y install pango*

然後在執行./configure --prefix=/usr/local/

然後執行make && make install

如果執行make的過程中報錯,則需要安裝如下包

yum -y install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

5.下載下傳并安裝cacti

wget http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz

tar -xzf cacti-0.8.8b.tar.gz

cd cacti-0.8.8b

mv -f * /var/www/html/cacti

6.進入資料庫并建立cacti庫

/usr/mysql/bin/mysql -p

create dadtabase cacti;

grant all on cacti.* to cacti@’%’identified by ‘cacti’;

7.導入cacti.sql

use cacti;

source cacti.sql;

如果報ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 

則需要編輯cacti.sql修改TYPE=MyISAM,産生此報錯的原因是cacti.sql是在mysql5.1部署的,而我安裝的是高版本的mysql5.6是以需要進行下面的修改

vim cacti.sql

:%s/TYPE=MyISAM/ENGINE=MyISAM/g 替換并儲存

然後在執行導入cacti.sql

8.配置include/config.php和include/global.php

vim include/config.php

vim include/global.php

9.設定rra目錄權限

chmod -R 777 rra

10.執行看是否正常

php /var/www/html/cacti/poller.php

11.加入定時任務

*/1 * * * * /usr/local/php/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1

12.打開浏覽器輸入http://ip/cacti進行安裝和初始化

預設密碼為admin,第一次需要重置密碼

 13.配置被監控端

首先安裝SNMP服務

配置snmp

vim /etc/snmp/snmpd.conf

修改如下配置

com2sec mynetwork ip/24      COMMUNITY //改成監控端的ip或者ip段

view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc //去掉此注釋

#以下為通路項目,如果想監控磁盤空間,load等需把注釋去掉

#  Make sure mountd is running

proc mountd #去掉前面的"#"

#  Make sure there are no more than 4 ntalkds running, but 0 is ok too.

proc ntalkd 4

#  Make sure at least one sendmail, but less than or equal to 10 are running.

proc sendmail 10 1

# Check the / partition and make sure it contains at least 10 megs.

disk / 10000

# Check for loads:

load 12 14 14

儲存并重新開機snmpd服務

service snmpd restar