zabbix監控mysql的效能

來源:互聯網
上載者:User

標籤:mysql 效能 zabbix

參考  http://www.linuxidc.com/Linux/2016-04/130436.htm

環境:

zabbix sever: 192.168.234.131

mysql :192.168.234.130


mysql 用戶端操作:


1 添加監控使用者,登入到資料裡然後:

  GRANT USAGE ON *.* TO ‘zabbix‘@‘localhost‘ IDENTIFIED BY ‘zabbix‘ WITH GRANT OPTION; MariaDB [(none)]>  flush privileges;      ##重新整理系統授權 MariaDB [(none)]> grant all on zabbix.* to ‘zabbix‘@‘127.0.0.1‘ identified by ‘zabbix‘ with grant option;


 

2 編寫指令碼 vi /usr/local/zabbix/scripts/mysql_status.sh


User=‘zabbix‘Password=‘zabbix‘Mysql=‘/usr/bin/mysql‘Mysqladmin=‘/usr/bin/mysqladmin‘command(){  $Mysql -u $User -p$Password -e "show global status" | awk ‘$1 ~ /‘"$1"‘$/ {print $2}‘}case $1 in  Com_select)    command $1 ;;  Com_insert)    command $1 ;;  Com_update)    command $1 ;;  Com_delete)    command $1 ;;  Com_begin)    command $1 ;;  Com_commit)    command $1 ;;  Com_rollback)    command $1 ;;  Questions)    command $1 ;;  Slow_queries)    command $1 ;;  Bytes_received)    command $1 ;;  Bytes_sent)    command $1 ;;  Uptime)    command $1 ;;  Version)    $Mysql -V | awk -F ‘[ ,]‘ ‘{print $6}‘ ;;  Ping)    $Mysqladmin -u$User -p$Password ping | wc -l ;;  *)    echo "Usage: $0 { Com_select|Com_insert|Com_update|Com_delete|Com_begin|Com_commit|Com_rollback|Questions|Slow_queries|Bytes_received|Bytes_sent|Ping|Uptime|Version }" ;;esac

3、添加自訂 key 設定檔

vi /usr/local/zabbix/etc/zabbix_agentd.confUserParameter=mysql.status[*],/usr/local/zabbix/scripts/mysql_status.sh $1UserParameter=mysql.ping,/usr/local/zabbix/scripts/mysql_status.sh PingUserParameter=mysql.version,/usr/local/zabbix/scripts/mysql_status.sh Version


4 重啟zabbix_agentd服務

/etc/init.d/zabbix_agentd restart

5 最後可以在服務端驗證

zabbix_get -s 192.168.234.130 -k mysql.ping

如果返回1即是正常

6 添加zabbix內建的mysql模板,確認出圖

 1)在zabbix前端可以即時查看mysql發送接收的位元組數。其中bytes received表示從所有用戶端接收到的位元組數,bytes sent表示發送給所有用戶端的位元組數。

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M00/80/F2/wKiom1dFNbKzT5a9AAFazRrIKOI814.png" title="1.png" alt="wKiom1dFNbKzT5a9AAFazRrIKOI814.png" />

  2)即時查看SQL語句每秒鐘的操作次數

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M02/80/F0/wKioL1dFNsqjLuH_AAJwBtlK810504.png" title="2.png" alt="wKioL1dFNsqjLuH_AAJwBtlK810504.png" />

本文出自 “漸行漸遠” 部落格,請務必保留此出處http://825536458.blog.51cto.com/4417836/1782982

zabbix監控mysql的效能

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.