zabbix指令碼監控mysql

來源:互聯網
上載者:User

標籤:監控mysql   ini   ext   uptime   ati   live   user   tmp   touch   

Zabbix監控mysql

1.1 用戶端配置1.1.1 安裝用戶端包
yum -y install unixODBC rpm -ivh zabbix-agent-3.0.3-1.el6.x86_64.rpm
1.1.2 編輯設定檔
注釋所有添加以下內容vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.confUserParameter=mysql.version,mysql -VUserParameter=mysql.status[*],/etc/zabbix/scripts/chk_mysql.sh $1UserParameter=mysql.ping,mysqladmin -uzabbix -p123456 -P3306 -h192.168.1.77  ping | grep -c alive

 

1.1.3 建立mysql監控指令檔
mkdir /etc/zabbix/scripts/touch /etc/zabbix/scripts/chk_mysql.shchmod u+x /etc/zabbix/scripts/chk_mysql.shchown -R zabbix.zabbix /etc/zabbix/scripts/chk_mysql.sh vim  /etc/zabbix/scripts/chk_mysql.sh#!/bin/sh# -------------------------------------------------------------------------------MYSQL_SOCK="/tmp/mysql.sock"MYSQL_USER=‘zabbix‘MYSQL_PWD=‘123456‘MYSQL_HOST=‘127.0.0.1‘MYSQL_PORT=‘3306‘ARGS=1if [ $# -ne "$ARGS" ];then    echo "Please input one arguement:"ficase $1 in    Uptime)        result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK status|cut -f2 -d":"|cut -f1 -d"T"`            echo $result            ;;        Com_update)            result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status |grep -w "Com_update"|cut -d"|" -f3`            echo $result            ;;        Slow_queries)        result=`/application/mysql/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK status |cut -f5 -d":"|cut -f1 -d"O"`

 

1.1.4 修改zabbix用戶端指向服務端IP
sed -i ‘s#ServerActive=127.0.0.1#ServerActive=192.168.1.72#g‘ /etc/zabbix/zabbix_agentd.conf sed -i ‘s#Server=127.0.0.1#Server=192.168.1.72#g‘ /etc/zabbix/zabbix_agentd.conf   /etc/init.d/zabbix-agent restart

 

1.1.5 Web端操作

 

 

 

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.