In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you about how to use the Netdata Mysql health monitoring plug-in. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
One: mysql file configuration
/ usr/local/netdata/etc/netdata add profile mysql.conf
Mysql_ cmds [my _ A] = "/ usr/local/mysql/bin/mysql"
Mysql_ opts [my _ A] = "- h localhost-uroot"
Two: mysql.chart.sh plug-in script
#! / bin/bash
# http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html
#
# https://dev.mysql.com/doc/refman/5.1/en/show-status.html
# SHOW STATUS provides server status information (see Section 5.1.6, "Server Status Variables").
# This statement does not require any privilege.
# It requires only the ability to connect to the server.
Mysql_update_every=5
Mysql_priority=60000
Declare-A mysql_cmds= () mysql_opts= () mysql_ids= ()
Mysql_exec () {
Local ret
"${@}"-s-e "show global status;"
Ret=$?
[$ret-ne 0] & & echo "plugin_command_failure $ret"
Return $ret
}
Mysql_get () {
Unset\
Mysql_Bytes_received\
Mysql_Bytes_sent\
Mysql_Queries\
Mysql_Questions\
Mysql_Slow_queries\
Mysql_Handler_commit\
Mysql_Handler_delete\
Mysql_Handler_prepare\
Mysql_Handler_read_first\
Mysql_Handler_read_key\
Mysql_Handler_read_next\
Mysql_Handler_read_prev\
Mysql_Handler_read_rnd\
Mysql_Handler_read_rnd_next\
Mysql_Handler_rollback\
Mysql_Handler_savepoint\
Mysql_Handler_savepoint_rollback\
Mysql_Handler_update\
Mysql_Handler_write\
Mysql_Table_locks_immediate\
Mysql_Table_locks_waited\
Mysql_Select_full_join\
Mysql_Select_full_range_join\
Mysql_Select_range\
Mysql_Select_range_check\
Mysql_Select_scan\
Mysql_Sort_merge_passes\
Mysql_Sort_range\
Mysql_Sort_scan\
Mysql_Created_tmp_disk_tables\
Mysql_Created_tmp_files\
Mysql_Created_tmp_tables\
Mysql_Connection_errors_accept\
Mysql_Connection_errors_internal\
Mysql_Connection_errors_max_connections\
Mysql_Connection_errors_peer_addr\
Mysql_Connection_errors_select\
Mysql_Connection_errors_tcpwrap\
Mysql_Connections\
Mysql_Aborted_connects\
Mysql_Binlog_cache_disk_use\
Mysql_Binlog_cache_use\
Mysql_Binlog_stmt_cache_disk_use\
Mysql_Binlog_stmt_cache_use\
Mysql_Threads_connected\
Mysql_Threads_created\
Mysql_Threads_cached\
Mysql_Threads_running\
Mysql_Innodb_data_read\
Mysql_Innodb_data_written\
Mysql_Innodb_data_reads\
Mysql_Innodb_data_writes\
Mysql_Innodb_data_fsyncs\
Mysql_Innodb_data_pending_reads\
Mysql_Innodb_data_pending_writes\
Mysql_Innodb_data_pending_fsyncs\
Mysql_Innodb_log_waits\
Mysql_Innodb_log_write_requests\
Mysql_Innodb_log_writes\
Mysql_Innodb_os_log_fsyncs\
Mysql_Innodb_os_log_pending_fsyncs\
Mysql_Innodb_os_log_pending_writes\
Mysql_Innodb_os_log_written\
Mysql_Innodb_row_lock_current_waits\
Mysql_Innodb_rows_inserted\
Mysql_Innodb_rows_read\
Mysql_Innodb_rows_updated\
Mysql_Innodb_rows_deleted\
Mysql_Innodb_buffer_pool_pages_data\
Mysql_Innodb_buffer_pool_pages_dirty\
Mysql_Innodb_buffer_pool_pages_flushed\
Mysql_Innodb_buffer_pool_pages_free\
Mysql_Innodb_buffer_pool_pages_misc\
Mysql_Innodb_buffer_pool_pages_total\
Mysql_Innodb_buffer_pool_bytes_data\
Mysql_Innodb_buffer_pool_bytes_dirty\
Mysql_Innodb_buffer_pool_read_ahead_rnd\
Mysql_Innodb_buffer_pool_read_ahead\
Mysql_Innodb_buffer_pool_read_ahead_evicted\
Mysql_Innodb_buffer_pool_read_requests\
Mysql_Innodb_buffer_pool_reads\
Mysql_Innodb_buffer_pool_wait_free\
Mysql_Innodb_buffer_pool_write_requests\
Mysql_Qcache_free_blocks\
Mysql_Qcache_free_memory\
Mysql_Qcache_hits\
Mysql_Qcache_inserts\
Mysql_Qcache_lowmem_prunes\
Mysql_Qcache_not_cached\
Mysql_Qcache_queries_in_cache\
Mysql_Qcache_total_blocks\
Mysql_Key_blocks_not_flushed\
Mysql_Key_blocks_unused\
Mysql_Key_blocks_used\
Mysql_Key_read_requests\
Mysql_Key_reads\
Mysql_Key_write_requests\
Mysql_Key_writes\
Mysql_Open_files\
Mysql_Opened_files
Mysql_plugin_command_failure=0
Eval "$(mysql_exec" ${@} ") |\
Sed\
-e "s / [[: space:]]\ + / / g"\
-e "s /. / _ / g"\
-e "s / ^\ ([a-zA-Z0-9]\ +\) [[: space:]]\ +\ ([0-9]\ +\) $/ mysql_\ 1 =\ 2Unigram" |\
Egrep "^ mysql_ [a-zA-Z0-9] + = [[: digit:]] + $") "
[$mysql_plugin_command_failure-eq 1] & & return 1
[- z "$mysql_Connections"] & & return 1
Mysql_Thread_cache_misses=0
[$((mysql_Connections + 1-1))-gt 0] & & mysql_Thread_cache_misses=$ ((mysql_Threads_created * 10000 / mysql_Connections))
Return 0
}
Mysql_check () {
# this should return:
#-0 to enable the chart
#-1 to disable the chart
Local x m mysql_cmd tryroot=0 unconfigured=0
If ["${1}" = "tryroot"]
Then
Tryroot=1
Shift
Fi
[- z "${mysql_cmd}"] & & mysql_cmd= "$(which mysql)"
If [${# mysql_opts [@]}-eq 0]
Then
Unconfigured=1
Mysql_ cmds [local] = "$mysql_cmd"
If [$tryroot-eq 1]
Then
# the user has not configured us for mysql access
# if the root user is passwordless in mysql, we can
# attempt to connect to mysql as root
Mysql_ opts [local] = "- u root"
Else
Mysql_ opts [local]
Fi
Fi
# check once if the url works
For m in "${! mysql_opts [@]}"
Do
[- z "${mysql_cmds [$m]}] & & mysql_cmds [$m] =" $mysql_cmd "
If [- z "${mysql_cmds [$m]}"]
Then
Echo > & 2 "$PROGRAM_NAME: mysql: cannot get mysql command for'$m'. Please set mysql_cmds [$m] ='/ path/to/mysql', in $confd/mysql.conf"
Fi
Mysql_get "${mysql_cmds [$m]}" ${mysql_opts [$m]}
If [! $?-eq 0]
Then
Echo > & 2 "$PROGRAM_NAME: mysql: cannot get global status for'$m'. Please set mysql_opts [$m] = 'options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf"
Unset mysql_cmds [$m]
Unset mysql_opts [$m]
Unset mysql_ids [$m]
Continue
Fi
Mysql_ids [$m] = "$(fixid" $m ")"
Done
If [${# mysql_opts [@]}-eq 0]
Then
If [${unconfigured}-eq 1 & & ${tryroot}-eq 0]
Then
Mysql_check tryroot "${@}"
Return $?
Else
Echo > & 2 "$PROGRAM_NAME: mysql: no mysql servers found. Please set mysql_ opts [name] = 'options' to whatever needed to get connected to the mysql server, in $confd/mysql.conf"
Return 1
Fi
Fi
Return 0
}
Mysql_create () {
Local x
# create the charts
For x in "${mysql_ids [@]}"
Do
Cat
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.