'}\\n'<\/span>\r\n<\/pre>\n\u6267\u884c\u5b9e\u4f8b\uff1a \u4ee5_ \u4e3a\u5206\u9694\u7b26\uff0c\u683c\u5f0f\u5316\u8f93\u51fa \u81ea\u52a8\u53d1\u73b0\u5b8f
\n.\/discovery_mysql.sh 3306_3307_3308<\/p>\n
{\r\n \"data\"<\/span>:[\r\n {\r\n \"{#MYSQLPORT}\"<\/span>:\"3306\"<\/span>},\r\n {\r\n \"{#MYSQLPORT}\"<\/span>:\"3307\"<\/span>},\r\n {\r\n \"{#MYSQLPORT}\"<\/span>:\"3308\"<\/span>}\r\n ]\r\n}\r\n<\/pre>\n2.mysql_filestype.sh \u76d1\u63a7mysql\u7684\u4e00\u4e9b\u6302\u8f7d\u76d8<\/strong><\/span><\/div>\nvar=$1<\/span>\r\nMYSQL_PORT=$2<\/span>\r\nMYSQL_NAME=`ps -ef |grep '\/mysql\/app\/bin\/mysqld'<\/span>| grep \"$MYSQL_PORT<\/span>\"<\/span> |grep -v grep | awk -F\" \"<\/span> '{print $11}'<\/span> |awk -F\"\/\"<\/span> '{print $2}'<\/span>` ;\r\nMYSQL_SOCk_DIR=\"\/$MYSQL_NAME<\/span>\/\"<\/span> ;\r\ndf -h \"${MYSQL_SOCk_DIR}<\/span>${var}<\/span>\"<\/span> |grep -v Filesystem |awk -F\" \"<\/span> '{print $5}'<\/span> | awk -F\"%\"<\/span> '{print $1}'<\/span> ;\r\n<\/pre>\n3.mysql_ping.sh \u76d1\u63a7mysql\u72b6\u6001<\/strong><\/span><\/div>\nMYSQL_PORT=$1<\/span>;\r\n\r\n[ \"${MYSQL_USER}<\/span>\"<\/span> = ''<\/span> ] && MYSQL_USER=xxx\r\n[ \"${MYSQL_PASSWORD}<\/span>\"<\/span> = ''<\/span> ] && MYSQL_PASSWORD=xxxxx\r\n\r\nmysqladmin=\/mysql\/app\/bin\/mysqladmin ;\r\n\r\nMYSQL_SOCk_DIR=`ps -ef |grep 'mysql'<\/span>| grep \"${MYSQL_PORT}<\/span>\"<\/span> |grep -v 'grep'<\/span> | awk -F\" \"<\/span> '{print $16}'<\/span>` ;\r\n\r\n${mysqladmin}<\/span> -u${MYSQL_USER}<\/span> -p${MYSQL_PASSWORD}<\/span> ${MYSQL_SOCk_DIR}<\/span> ping 2> \/dev\/null |grep 'alive'<\/span>|wc -l ;\r\n<\/pre>\n\u6ce8\u610f: \u8fd9\u8fb9\u8fde\u63a5\u5b9e\u4f8b \u90fd\u662f mysql -u -p -S \/xxx\/mysql.sock<\/p>\n
\u4f46\u662f\u540e\u6765\u53d1\u73b0\u90e8\u5206\u5ba2\u6237\u7aef\u603b\u662f\u65e0\u6cd5\u6b63\u786e\u663e\u793a\u503c\uff0c\u800c\u4e14\u5c31\u662f\u8fd9\u6761 \u8bed\u53e5\u62a5\u9519\uff0c \u611f\u89c9\u662f\u73af\u5883\u53d8\u91cf\u7684\u95ee\u9898<\/p>\n
\u6240\u4ee5\u62ff --socket=\/xxx\/mysql.sock \u6765\u4ee3\u66ff -S\/xxx\/mysql.sock \u3002 \u8fd9\u91cc\u7684\u53d8\u91cf${MYSQL_SOCk_DIR} \u5c31\u662f--socket=\/xxx\/mysql.sock \u3002<\/p>\n
4.mysql_repl.sh mysql\u4e3b\u4ece\u72b6\u6001\u76d1\u63a7<\/strong><\/span><\/div>\nvar=$1<\/span>\r\nMYSQL_PORT=$2<\/span>\r\nMYSQL_SOCk_DIR=`ps -ef |grep 'mysql'<\/span>| grep \"${MYSQL_PORT}<\/span>\"<\/span> |grep -v 'grep'<\/span> | awk -F\" \"<\/span> '{print $16}'<\/span>` ;\r\nmysql=\/mysql\/app\/bin\/mysql\r\n[ \"${MYSQL_USER}<\/span>\"<\/span> = ''<\/span> ] && MYSQL_USER=xxx\r\n[ \"${MYSQL_PASSWORD}<\/span>\"<\/span> = ''<\/span> ] && MYSQL_PASSWORD=xxxx\r\n${mysql}<\/span> -u${MYSQL_USER}<\/span> -p${MYSQL_PASSWORD}<\/span> ${MYSQL_SOCk_DIR}<\/span> -e \"show slave status\\G;\"<\/span> 2> \/dev\/null |grep \"\\b${var}<\/span>\\b\"<\/span>|awk -F\" \"<\/span> '{print $2}'<\/span> ;\r\n<\/pre>\n\u4e3b\u4ece\u72b6\u6001 \u6709\u51e0\u4e2a\u7aef\u53e3\u7684\u503c\u662f \u7a7a\u7684\uff0c \u8fd9\u4e2a\u5f97 \u5177\u4f53\u95ee\u9898\u5177\u4f53\u8bbe\u7f6e<\/p>\n
5.mysql_status2 mysql\u6027\u80fd\u4e4b\u7c7b\u7684\u76d1\u63a7<\/strong><\/span><\/div>\nmysql=\/mysql\/app\/bin\/mysql\r\nvar=$1<\/span>\r\nMYSQL_PORT=$2<\/span>\r\n[ \"${MYSQL_USER}<\/span>\"<\/span> = ''<\/span> ] && MYSQL_USER=xxx\r\n[ \"${MYSQL_PASSWORD}<\/span>\"<\/span> = ''<\/span> ] && MYSQL_PASSWORD=xxxxx\r\n\r\nMYSQL_SOCk_DIR=`ps -ef |grep 'mysql'<\/span>| grep \"${MYSQL_PORT}<\/span>\"<\/span> |grep -v 'grep'<\/span> | awk -F\" \"<\/span> '{print $16}'<\/span>` ;\r\n\r\n${mysql}<\/span> -u${MYSQL_USER}<\/span> -p${MYSQL_PASSWORD}<\/span> ${MYSQL_SOCk_DIR}<\/span> -e \"show global status;\"<\/span> 2> \/dev\/null |grep -v Variable_name|grep \"\\b${var}<\/span>\\b\"<\/span>|awk '{print $2}'<\/span> ;\r\n<\/pre>\n\u53d1\u73b0\u6709\u4e9b\u76d1\u63a7\u9879 \u6216\u56e0\u4e3a\u6570\u5b57\u8fc7\u957f\u800c\u65e0\u6cd5\u663e\u793a\uff0c\u5f85\u89e3\u51b3<\/p>\n
6.mysql_version.sh mysql\u7248\u672c\u76d1\u63a7<\/strong><\/span><\/div>\nMYSQL_PORT=$1<\/span>;\r\n\r\nMYSQL_SOCk_DIR=`ps -ef |grep 'mysql'<\/span>| grep \"${MYSQL_PORT}<\/span>\"<\/span> |grep -v 'grep'<\/span> | awk -F\" \"<\/span> '{print $16}'<\/span>` ;\r\n\r\nmysql=\/mysql\/app\/bin\/mysql ;\r\n\r\n[ \"${MYSQL_USER}<\/span>\"<\/span> = ''<\/span> ] && MYSQL_USER=xxx\r\n[ \"${MYSQL_PASSWORD}<\/span>\"<\/span> = ''<\/span> ] && MYSQL_PASSWORD=xxxx\r\n\r\n${mysql}<\/span> -u${MYSQL_USER}<\/span> -p${MYSQL_PASSWORD}<\/span> ${MYSQL_SOCk_DIR}<\/span> -e \"select version();\"<\/span> 2> \/dev\/null |awk 'END {print}'<\/span>\r\n<\/pre>\n7.mysql_status_many.conf \u751f\u6210\u53ef\u7528\u952e \u914d\u7f6e\u6587\u4ef6<\/strong><\/span><\/div>\nUserParameter=mysql.discovery[*],\/patrol\/zabbix<\/span>\/bin\/duoshili<\/span>_discovery\/discovery_mysql.sh $1 \r\nUserParameter=mysql.status_many[*],\/patrol\/zabbix<\/span>\/bin\/duoshili<\/span>_discovery\/mysql_status2 $1 $2\r\nUserParameter=mysql.ping_many[*],\/patrol\/zabbix<\/span>\/bin\/duoshili<\/span>_discovery\/mysql_ping.sh $1\r\nUserParameter=mysql.version_many[*],\/patrol\/zabbix<\/span>\/bin\/duoshili<\/span>_discovery\/mysql_version.sh $1\r\nUserParameter=mysqlcheck_repl[*],\/patrol\/zabbix<\/span>\/bin\/duoshili<\/span>_discovery\/mysql_repl.sh $1 $2\r\nUserParameter=mysql.filestyle_many[*],\/patrol\/zabbix<\/span>\/bin\/duoshili<\/span>_discovery\/mysql_filestype<\/pre>\n","protected":false},"excerpt":{"rendered":"\u4e3b\u673a\u5b8f\u683c\u5f0f\uff1a$MACRO \uff08\u76f4\u63a5\u5c31\u53ef\u4ee5 \u586b \u503c\uff09 \u81ea\u52a8\u53d1\u73b0\u5b8f\uff1a#MACRO \uff08\u9700\u8981\u914d\u5408 \u521b\u5efa\u7684 key \u53d6\u503c\uff09 […]<\/p>\n","protected":false},"author":63,"featured_media":145775,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-145766","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/145766","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=145766"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/145766\/revisions"}],"predecessor-version":[{"id":145901,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/145766\/revisions\/145901"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/145775"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=145766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=145766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=145766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}