1. Project Description1.1 Background In addition, after In summary, it is necessary to monitor the operating status of MHA. 1.2 Implementation Design MHA runs on the 1.2.1 Previous methods In the seventh part of the article "Taking the monitoring of MongoDB replica set status as an example to see how to write and deploy the Exec input plug-in in 1.2.2 Optimized method The deployment steps are as follows: 2. Implementation details2.1 Editing the Python executable The executable file is #!/usr/bin/python # -*- coding: UTF-8 -*- import os import io import re import ConfigParser Path='/cnf/mhacnf' #fout=open('output file name','w') for Name in os.listdir(Path) : Pathname = os.path.join(Path,Name) ## print(Pathname) ## print(Name) config = ConfigParser.ConfigParser() try: config.read(Pathname) server_item = config.sections() server1_host = '' ##Node 1 in the MHA cnf configuration file server2_host = '' ##Node 2 in the MHA cnf configuration file server3_host = '' ##Node 3 in the MHA cnf configuration file mha_cnf_remark = '' if 'server1' in server_item: server1_host = config.get('server1','hostname') else: server1_host = '' mha_cnf_remark = mha_cnf_remark + 'Server1 is not configured;' if 'server2' in server_item: server2_host = config.get('server2','hostname') else: server2_host = '' mha_cnf_remark = mha_cnf_remark + 'Server2 is not configured;' if 'server3' in server_item: server3_host = config.get('server3','hostname') ##print(mha_cnf_remark) except Exception as e: print(e) mha_status_result = '' if server1_host <> '' and server2_host <> '': cmd_mha_status ='/usr/local/bin/masterha_check_status --conf='+Pathname with os.popen(cmd_mha_status) as mha_status: mha_status_result = mha_status.read() if 'running(0:PING_OK)' in mha_status_result: print('masterha_check_status,server='+server1_host+' Status=1i') print('masterha_check_status,server='+server2_host+' Status=1i') if 'stopped(2:NOT_RUNNING)' in mha_status_result: ##else: print('masterha_check_status,server='+server1_host+' Status=0i') print('masterha_check_status,server='+server2_host+' Status=0i') illustrate:
2.2 Modify telegraf file The default directory of the file is Embed the execution file into The code is as follows: [[inputs.exec]] ##Commands array commands = ["python /data/check_mha_status/check_mha_status.py",] timeout='60s' data_format="influx" 2.3 Modify the running account of telegraf service The default startup account of Modify The modified code is as follows: [Unit] Description=The plugin-driven server agent for reporting metrics into InfluxDB Documentation=https://github.com/influxdata/telegraf After=network.target [Service] EnvironmentFile=-/etc/default/telegraf ##User=telegraf User=root ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d $TELEGRAF_OPTS ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure RestartForceExitStatus=SIGPIPE KillMode=control-group [Install] WantedBy=multi-user.target 2.4 Start Telegraf serviceservice telegraf start ####Start the serviceservice telegraf status ####Check the service statusservice telegraf stop ####Shut down the service 2.5 Configure Grafana and add Panel Because The data reported on the MySQL instance node is First , regularize instance(Server IP:port) and remove the port data. To do this, add a grafana variable --server_ip, as follows : Note that the data source above is from Then, add another In this way, the two Finally, add the The SQL statement is as follows: SELECT mean("Status") FROM "masterha_check_status" WHERE ("server" =~ /^$mha_server$/) AND $timeFilter GROUP BY time(1m) fill(null) 3. ImplementationThe running status is 1, and the abnormal or closed status is 0. You can also add One more thing: Because of the optimized monitoring method, monitoring is automatically discovered and adjusted according to the configuration file. Therefore, if a new To avoid this situation, it is recommended to add a new This is the end of this article about MySQL MHA operation status monitoring. For more relevant MySQL MHA operation status monitoring content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of CSS label mode display property
>>: Linux type version memory disk query command introduction
This article shares the specific code for impleme...
During the project, I started using the js reques...
We will install phpMyAdmin to work with Apache on...
Table of contents question extend Solving the pro...
Table of contents 1. Introduction 2. Use 1. Diffe...
Table of contents What is a skeleton screen? Demo...
The main function of the brower module is to dete...
Effect Preview Ideas Scroll the current list to t...
This is an interview question, which requires the...
IFNULL(expr1,expr2) If expr1 is not NULL, IFNULL(...
This article shares the specific code for WeChat ...
location matching order 1. "=" prefix i...
This article example shares the specific code of ...
Messy log Nginx in daily use is mostly used as bo...
1. Enter the Docker official website First, go to...