您好,登錄后才能下訂單哦!
1、設置mysql,創建Cacti數據庫和賬號
[root@nagios ~]# mysql -u root -p123456 mysql> create database cactidb; mysql> GRANT ALL ON cactidb.* TO cactier@localhost IDENTIFIED BY '123456'; mysql> flush privileges; mysql> quit
2、安裝rrdtool
[root@nagios ~]# yum -y install rrdtool rrdtool-devel rrdtool-php
3、安裝配置snmp
[root@nagios ~]# yum install -y net-snmp net-snmp-utils net-snmp-libs [root@nagios ~]# vi /etc/snmp/snmpd.conf 可修改community默認密碼public [root@nagios ~]# service snmpd restart [root@nagios ~]# chkconfig snmpd on
4、下載安裝Cacti
[root@nagios ~]# mkdir /home/nagios [root@nagios ~]# cd /home/nagios [root@nagios nagios]# wget http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz [root@nagios nagios]# tar xzf cacti-0.8.8b.tar.gz [root@nagios nagios]# mv cacti-0.8.8b /var/www/html/cacti [root@nagios cacti]# cd /var/www/html/cacti [root@nagios cacti]# mysql -uroot -p cactidb < cacti.sql
5、配置參數
[root@nagios cacti]# vi /var/www/html/cacti/include/config.php $database_type = "mysql"; $database_default = "cactidb"; $database_hostname = "localhost"; $database_username = "cactier"; $database_password = "123456"; $database_port = "3306"; #$url_path = "/cacti/";
6、添加用戶、修改權限和屬主
[root@nagios cacti]# useradd cactier [root@nagios cacti]# passwd cactier #輸入密碼123456 [root@nagios cacti]# usermod -G cactier apache [root@nagios cacti]# chown -R root:root /var/www/html/cacti/ [root@nagios cacti]# chown -R cactier:cactier rra/ log/
7、Apache設置
[root@nagios cacti]# vi /etc/httpd/conf/httpd.conf <Directory "/var/www/html/cacti "> Options FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from all </Directory> [root@nagios cacti]# vi /etc/php.ini date.timezone=Asia/Shanghai [root@nagios cacti]# service httpd restart
8、添加計劃
每5分鐘更新RRD圖形,poller是單線程程序,可以改用支持多線程和分布式的工具spine
[root@nagios cacti]# crontab -e */5 * * * * php /var/www/html/cacti/poller.php &> /dev/null [root@nagios cacti]# service crond restart [root@nagios cacti]# ntpdate 65.55.56.206
切換用戶,手動執行后在rra目錄下生成rrd圖形文件
[root@nagios cacti]# su - cactier [cactier@nagios cacti]# php /var/www/html/cacti/poller.php
也可以不執行手動操作,等待5分鐘,觀察rra目錄下是否自動生成rrd文件
9、WEB頁面初始化
http://localhost/cacti
用戶名admin 密碼admin
10、測試采集數據
(1)查看RRD文件中數據
[cactier@nagios cacti]# cd /var/www/html/cacti/rra [cactier@nagios rra]# rrdtool fetch -r 300 localhost_mem_buffers_3.rrd AVERAGE date +%s
- nan表示沒有數據,每隔300秒獲取一次數據。
(2)查看mysql中的更新時間
[cactier@nagios rra]# mysql -uroot -p123456 mysql>use cactidb; mysql>select * from poller_time; mysql>quit
正常的話是每五分鐘更新
(3)采集不到數據怎么辦
在網頁上清除緩存system utilities -->Rebuild poller cache
修改RRA權限#chmod 777 -R /srv/www/htdocs/cacti/rra
同步系統時間#ntpdate 65.55.56.206
(4)測試snmp抓取數據
[root@nagios ~]# snmpwalk -v 2c -c public <目標機器IP> system
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。