cacti監控mysql

roszhaodan481發表於2014-05-23

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 cacti@127.0.0.1 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';

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

建立賬號

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

http://cacti地址/cacti

安裝外掛管理器

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

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

監控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

Devices 》add》 》Create Graphs for this Host

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

email

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

告警郵件:

Down機郵件

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

簡訊報警:

詳細頁面:http://www.verydemo.com/demo_c152_i71390.html

相關文章