1、監控指令碼下載及配置
wget http://mysql-cacti-templates.googlecode.com/files/better-cacti-templates-1.1.8.tar.gz
tar zxvf better-cacti-templates-1.1.8.tar.gz
cd better-cacti-templates-1.1.8
cp scripts/ss_get_mysql_stats.php /var/www/html/cacti/scripts/
監控mysql只需要用到兩個檔案:
模板檔案:./templates/cacti_host_template_x_mysql_server_ht_0.8.6i-sver1.1.8.xml
外掛程式:./scriptsss_get_mysql_stats.php
修改ss_get_mysql_stats.php 檔案:
vim /var/www/html/cacti/scripts/ss_get_mysql_stats.php
配置MySQL伺服器,讓cacti所在機器能夠訪問MySQL伺服器的狀態資訊,必須擁有”process”許可權。如果要監控InnoDB狀態,還必須有”SUPER”許可權。
mysql> grant process,super on *.* to 'cactiuser'@'%' identified by 'cactiuser'; mysql> grant all privileges on cacti.* to cactiuser@"%" identified by "cactiuser"; mysql> flush privileges;
3、匯入模板
將模板cacti_host_template_x_mysql_server_ht_0.8.6i-sver1.1.8.xml從linux下到本地電腦,登陸web匯入:
4、添加mysql監控
在Console選項卡下的左側功能表列中選擇Devices,選擇一個Device或建立一個Device,在Associated Graph Templates中添加要監控的mysql狀態:
在Create Graphs for this Host中選中剛才添加的模板,在點擊下方create建立映像:
5、最後在左上方的graphs選項卡,查看裝置映像,就可以查看到監控的mysql映像: