標籤:如何 otto bre tor too 分享圖片 neu hit sha
1.mysql流量有哪些?
(1)接收的流量(Bytes_received)
(2)發出的流量(Bytes_sent)
2.如何擷取接收和發出的流量?
擷取接收的流量:
[[email protected] usr]# mysqladmin extended-status | awk '/\<Bytes_received\>/{print $4}'72671
擷取發出的流量:
[[email protected] usr]# mysqladmin extended-status | awk '/\<Bytes_sent\>/{print $4}'136264
3.如何統計兩秒內或更多時間內流量的統計?
Eg:計算兩秒內MYSQL的接收和發出的流量的統計?
cat /etc/zabbix/shell/monitor_mysql.sh
#!/bin/bash#統計2秒內MYSQL的接收和發出的流量統計Bytes_sent() { Bytes_sent1=`mysqladmin extended-status | awk '/\<Bytes_sent\>/{print $4}'` sleep 2 Bytes_sent2=`mysqladmin extended-status | awk '/\<Bytes_sent\>/{print $4}'` echo $(($Bytes_sent2-$Bytes_sent1))}Bytes_recive() { Bytes_recive1=`mysqladmin extended-status | awk '/\<Bytes_received\>/{print $4}'` sleep 2 Bytes_recive2=`mysqladmin extended-status | awk '/\<Bytes_received\>/{print $4}'` echo $(($Bytes_recive2-$Bytes_recive1))}$1
4.在agent定義模板
vim userparameter_my.conf
UserParameter=monitor_mysql[*],/bin/bash /etc/zabbix/shell/monitor_mysql.sh "$1"
monitor_mysql[*]:是自訂key,*是傳參
server端自訂索引值,monitor_mysql[Bytes_sent],調用Bytes_sent函數
server端自訂索引值,monitor_mysql[Bytes_recive],調用Bytes_recive函數
5.準備更新一個關於zabbix監控的專題,歡迎加入我們的Linux技術交流群:642921645,zabbix監控交流群:832462735 ,我們不定期去更新很多關於系統營運的資料在群裡,期待你的加入!
6.文章也會推送到公眾號
zabbix企業級監控之監控MYSQL流量