Xtradb+haproxy High Availability DB cluster (quad) cluster Zabbix monitoring Chapter

Source: Internet
Author: User
Tags percona haproxy

xtradb ClusterCluster Zabbix monitoringMonitoring Metrics

Website Reference Address:

Https://www.percona.com/doc/percona-xtradb-cluster/5.6/manual/monitoring.html

1 , Alarm parameters

Each cluster node state:

wsrep_cluster_status   != Primary

< EM style= "Background-color:inherit;" >wsrep_connected  != On

Wsrep_ready ! = on

Replication Conflict Too high

Wsrep_local_cert_failures

Wsrep_local_bf_aborts

Flow control information

Wsrep_flow_control_sent

Wsrep_flow_control_recv

Replication Queue Size

Wsrep_local_recv_queue

2 , long-term chart collection parameters

Queue Size

Wsrep_local_recv_queue

wsrep_local_send_queue

Flow control

Wsrep_flow_control_sent

Wsrep_flow_control_recv

Number of exchanges in and out of this node

wsrep_replicated

Wsrep_received

Number of bytes in and out of exchange

Wsrep_replicated_bytes

Wsrep_received_bytes

Replication conflicts

Wsrep_local_cert_failures

Wsrep_local_bf_aborts

ZabbixMonitoring Scripts

[[email  protected] ~]# cat monit_xtradb.py

#!/usr/bin/python env#coding=utf-8#time: 2015-8-12#function: monit xtradb cluster  status#author: yangr import re,time,osimport commands## #variable     Database and Monitoring item variable definition area mysql_user= ' sstuser ' mysql_pass= ' s3cret ' mysql_host= ' localhost ' mysql_port= ' 3306 ' monit_message= ' Wsrep_cluster_statuswsrep_connectedwsrep_readywsrep_local_cert_failureswsrep_local_bf_abortswsrep_flow_control _sentwsrep_flow_control_recvwsrep_local_recv_queuewsrep_local_recv_queuewsrep_local_send_queuewsrep_flow_ Control_sentwsrep_flow_control_recvwsrep_replicatedwsrep_receivedwsrep_replicated_byteswsrep_received_ Byteswsrep_local_cert_failureswsrep_local_bf_aborts ' Monit_list=monit_message.split () # # # #zabbix   Related parameters define area zabbix_agent_file= '/usr/local/zabbix/etc/zabbix_agentd.conf ' zabbix_server=commands.getstatusoutput ("' grep  ' ^serveractive '  %s|awk -F[=]  ' {print $2} '   '%zabbix_agent_file] [1].strip () Zabbix_hostname=commands.getstatusoutpuT (' grep  ' ^hostname '  %s|awk -F[=]  ' {print $2} '    '%zabbix_agent_file) [1]. Strip () Zabbix_server_port=10051timestamp = int (Time.time ()) tmp_file_path= '/tmp/xtradb_cluster_ Status.txt ' zabbix_hostname= ' zabbix_server ' zabbix_server= ' zabbix_server '  ### #end  variable variable definition end   #获取全局状态信息status, Global_status=commands.getstatusoutput (" mysql -u%s -p%s -h%s -p%s  -e  ' show global status like  ' wsrep%% '; '   "% (Mysql_user,mysql_pass,mysql_host,mysql_port)) #print   '  mysql -u%s -p%s -h %s -p%s -e  ' show global status like  "wsrep%%";   "% (mysql_user,mysql_pass,mysql_host,mysql_port) #print  global_status global_status=global_ Status.split (' \ n ') #print  global_status# empty file With open (Tmp_file_path, ' WB ')  as f:          f.write (") #循环要监控的指标for  i in monit_list:   #循环状态列表, take out the current value of the indicator   for n in global_status:          if  "%s\t"%i in n:                    value=re.sub (R '. *\t ', "', N). Strip ()                      #print  i, ' Value: ',value                     #把值写入临时文件                     with open (Tmp_file_path, ' ab ')  as f:                              f.write ('%s %s %s %s\n '% (zabbix_ Hostname,i,timestamp,value))          #把临时文件通过zabbix_sender命令发送到server端send_data_cmd = '/usr/local/zabbix/bin /zabbix_sender -vv -z %s -p %s -t -i %s '% (zabbix_server,zabbix_server_ Port,tmp_file_path) print  '/usr/local/zabbix/bin/zabbix_sender -vv -z %s -p %s  -t -i %s '% (zabbix_server,zabbix_server_port,tmp_file_path) #print  send_data_cmdos.popen ( Send_data_cmd)


In the script monit_message corresponding monitoring items, you need to add the corresponding monitoring items on the Zabbix server, and then put this script in crontab every minute to execute.



This article from "Yang Cloud" blog, reproduced please contact the author!

Xtradb+haproxy High Availability DB cluster (quad) cluster Zabbix monitoring Chapter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.