cacti監控mysql

yum 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
service httpd start
service mysqld start

安裝rrtools

yum localinstall rrdt* --nogpgcheck

拆解 cacti的數據包

將cacti 搬移致/var/www/html

tar -zxvf cacti-0.8.7g.tar.gz -C /var/www/html
cd /var/www/html
mv cacti-0.8.7g/ cacti
# mysqld_safe --user=mysql &
# mysqladmin –u root -p password

配置mysql

CREATE DATABASE cacti;

//若只監控本機,這句就夠了

grant all privileges on cacti.* to cacti@localhost identified by 'cacti';

#grant all privileges on cacti.* to [email protected] identified by 'cacti';

//否則,要在那臺服務器上的mysql中授權允許cacti主機的連接

grant Process,Super on *.* to 'cacti'@'172.16.1.6' identified by 'cacti';
#grant Process,Super on *.* to 'cacti'@'monitor.cactimon.com' identified by 'cacti';
flush privileges;

實驗過程中,很多人出現graps下爲空表,或無表,大多是因爲這裏未正確授權,導致無法連接到數據庫造成的,可以用以下命令測試是否可以正常連接

mysql -h 192.168.0.1 -ucacti -pcacti

# use mysql;
# 直接插入
# insert into user(Host,User,Password) values ('172.16.1.6','cacti','cacti');
# 更新
# update user set host='monitor.cactimon.com' where host='172.16.1.6';
# update user set password=password('cacti') where host='monitor.cactimon.com';
# 刪除
# delete from user where user='cacti';

cacti 網頁默認登陸密碼:admin admin

無法登陸:

mysql>use cacti;
mysql>update user_auth set password=md5("新密碼") where username='admin';

clip_p_w_picpath002

clip_p_w_picpath003

################################

創建賬號

useradd cacti -p cacti

改變權限

cd /var/www/html/cacti/

chown -R cacti rra log

配置snmp

62 access notConfigGroup "" any noauth exact all none none
85 view all included .1 80

編輯 crontab -e //每5分鐘採集一次數據

*/5 * * * * php /var/www/html/cacti/poller.php >/dev/null 2>&1

導入數據庫

mysql -ucacti -pcacti cacti </var/www/html/cacti/cacti.sql

編輯cacti的配置腳本

vim /var/www/html/cacti/include/config.php

clip_p_w_picpath004

http://cacti地址/cacti

p_w_picpath

p_w_picpath

安裝插件管理器

tar -zxvf cacti-plugin-0.8.7g-PA-v2.8.tar.gz
cp -R cacti-plugin-arch/* /var/www/html/cacti/
進入控制檯,對管理員啓用插件管理器
進入cacti的目錄
cd /var/www/html/cacti/
mysql -ucacti -pcacti cacti &lt;pa.sql
有些人老是補丁打不上,此處必須在 cacti/目錄下
patch -p1 -N &lt;cacti-plugin-0.8.7g-PA-v2.8.diff
網頁無圖片,或無法顯示,編輯php的配置文件,修改路徑
vim /var/www/html/cacti/include/config.php
42 $url_path = "/cacti/";
拆解插件
tar -zxvf monitor-latest.tgz
tar -zxvf settings-latest.tgz
tar -zxvf thold-latest.tgz
安裝插件
mv monitor-0.9/ /var/www/html/cacti/plugins/monitor
mv thold-0.41/ /var/www/html/cacti/plugins/thod
mv settings-0.6/ /var/www/html/cacti/plugins/settings

到控制檯中啓用插件 Utilities下 User Management > admin &gt;Realm Permissions &gt;Plugin Management &gt;save

p_w_picpath

Configureation下 Plugin Management &gt;Actions 下Install Plugin(藍色向下的箭頭) &gt;Enable Plugin(綠色向右的箭頭)

clip_p_w_picpath006

監控mysql

# tar xvfz mysql-cacti-templates-1.1.2.tar.gz
# cp cacti-templates-1.1.2/scripts/ss_get_mysql_stats.php /var/www/html/cacti/scripts/

修改腳本文件

# vim /var/www/html/cacti/scripts/ss_get_mysql_stats.php
43 $mysql_user = ¨cacti¨;
44 $mysql_pass = ¨cacti¨;
45 $mysql_port = 3306;
49 $cache_dir = ¨/var/www/html/cacti/cache¨;
# mkdir /var/www/html/cacti/cache
#chown cacti:cacti /var/www/html/cacti/cache
#chmod 777 /var/www/html/cacti/cache

導入模版

Import Templates &gt;瀏覽&gt; templates/cacti_host_template_x_mysql_server_ht_0.8.6i-sver1.1.8.xml&gt;Import

p_w_picpath

clip_p_w_picpath007

Devices 》add》 》Create Graphs for this Host

clip_p_w_picpath009

##################################################

email

settings&gt;mail/dns &gt;send a test mail

clip_p_w_picpath011

告警郵件

clip_p_w_picpath013

Down機郵件

clip_p_w_picpath015

clip_p_w_picpath017

msn通知(昨天的聊天記錄):

clip_p_w_picpath019

短信報警:

p_w_picpath

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章