当前位置:网站首页>Mysql 监控3
Mysql 监控3
2022-06-30 01:19:00 【franket】
测试脚本
装完包后,再次执行测试脚本,就正常返回一个数字了
[[email protected] scripts]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
0
[[email protected] scripts]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gt
38409
这个数据从哪里来的呢, 执行脚本的过程中生成了这个文件 /tmp/localhost-mysql_cacti_stats.txt
[[email protected] scripts]# cat /tmp/localhost-mysql_cacti_stats.txt
gg:0 gh:0 gi:0 gj:0 gk:3275 gl:7096091357813 gm:0 gn:2 go:0 gp:0 gq:1310712 gr:560473 gs:747264 gt:38409 gu:666299 gv:81269 gw:3884351 gx:4850164 gy:666658 gz:22406662 hg:16685721 hh:0 hi:0 hj:0 hk:0 hl:0 hm:0 hn:0 ho:0 hp:0 hq:61117 hr:79688 hs:72627 ht:3483741 hu:46269304 hv:1477167 hw:10612667 hx:10992203 hy:712017 hz:11704230 ig:0 ih:358979056 ii:0 ij:23 ik:245 il:263 im:2048 in:10245 io:2048 ip:0 iq:2 ir:1 is:0 it:0 iu:1 iv:1 iw:1 ix:2048 iy:8 iz:12 jg:0 jh:0 ji:0 jj:0 jk:0 jl:1 jm:268417400 jn:0 jo:0 jp:0 jq:6 jr:0 js:1 jt:268435456 ju:52 jv:10816055 jw:10511991 jx:6 jy:719085 jz:0 kg:0 kh:0 ki:0 kj:0 kk:0 kl:0 km:0 kn:0 ko:0 kp:3 kq:0 kr:0 ks:0 kt:0 ku:3 kv:0 kw:6 kx:87998 ky:6025810131 kz:8388608 lg:8388608 lh:4347852912824 li:4347852916081 lj:575663419 lk:1048576 ll:0 lm:0 ln:638 lo:0 lp:0 lq:0 lr:0 ls:0 lt:0 lu:1 lv:0 lw:0 lx:0 ly:0 lz:0 mg:0 mh:0 mi:0 mj:0 mk:0 ml:2 mm:38445444 mn:712017 mo:0 mp:0 mq:6 mr:11974037 ms:10 mt:0 mu:11971670 mv:62 mw:0 mx:0 my:0 mz:10992203 ng:10612792 nh:0 ni:0 nj:-1 nk:-1 nl:21978152960 nm:0 nn:72550322 no:1 np:813 nq:815 nr:388741648 ns:2657176 nt:87248076 nu:1197592 nv:53125976 nw:0 nx:-1 ny:-1 nz:-1 og:0 oh:6119424 oi:33554432 oj:0 ok:0 ol:-1 om:-1 on:-1 oo:-1 op:-1 oq:-1 or:-1 os:-1 ot:-1 ou:-1 ov:-1 ow:-1 ox:-1 oy:-1 oz:-1 pg:-1 ph:-1 pi:-1 pj:-1 pk:-1 pl:-1 pm:-1 pn:-1 po:-1 pp:-1 pq:-1 pr:-1 ps:-1 pt:-1 pu:-1 pv:-1 pw:-1 px:-1 py:-1 pz:-1 qg:-1 qh:-1 qi:-1 qj:-1 qk:-1 ql:-1 qm:-1 qn:-1 qo:607839 qp:1964228995[[email protected] scripts]#
[[email protected] scripts]#
这个脚本并不长,总共只有43行,是对 ss_get_mysql_stats.php 的一层包装,罗辑非常简单,看看就知道了
[[email protected] scripts]# wc -l /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh
43 /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh
[[email protected] scripts]# cat /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh
#!/bin/sh
# The wrapper for Cacti PHP script.
# It runs the script every 5 min. and parses the cache file on each following run.
# Version: 1.1.5
#
# This program is part of Percona Monitoring Plugins
# License: GPL License (see COPYING)
# Copyright: 2015 Percona
# Authors: Roman Vynar
ITEM=$1
HOST=localhost
DIR=`dirname $0`
CMD="/usr/bin/php -q $DIR/ss_get_mysql_stats.php --host $HOST --items gg"
CACHEFILE="/tmp/$HOST-mysql_cacti_stats.txt"
if [ "$ITEM" = "running-slave" ]; then
# Check for running slave
RES=`HOME=~zabbix mysql -e 'SHOW SLAVE STATUS\G' | egrep '(Slave_IO_Running|Slave_SQL_Running):' | awk -F: '{print $2}' | tr '\n' ','`
if [ "$RES" = " Yes, Yes," ]; then
echo 1
else
echo 0
fi
exit
elif [ -e $CACHEFILE ]; then
# Check and run the script
TIMEFLM=`stat -c %Y /tmp/$HOST-mysql_cacti_stats.txt`
TIMENOW=`date +%s`
if [ `expr $TIMENOW - $TIMEFLM` -gt 300 ]; then
rm -f $CACHEFILE
$CMD 2>&1 > /dev/null
fi
else
$CMD 2>&1 > /dev/null
fi
# Parse cache file
if [ -e $CACHEFILE ]; then
cat $CACHEFILE | sed 's/ /\n/g; s/-1/0/g'| grep $ITEM | awk -F: '{print $2}'
else
echo "ERROR: run the command manually to investigate the problem: $CMD"
fi
[[email protected] scripts]#
边栏推荐
- Programmers with a monthly salary of less than 30K must recite the interview stereotype. I will eat it first!
- postman 之接口关联
- Internal class usage scenarios, syntax and principle explanations
- Transaction summary on June 25, 2022
- Machinery -- nx2007 (UG) finite element analysis tutorial 1 -- simple object
- Vant weave - remove (clear) < van button > button component Click to display gray background effect
- 英伟达Jetson Nano的初步了解
- How to refuse the useless final review? Ape tutoring: it is important to find a suitable review method
- Storage engine analysis
- Text classification using huggingface
猜你喜欢
Crmeb SMS for program configuration of knowledge payment system
I, 33 years old, ByteDance test development, unveiled the real income of Beijing "test post"
传统微服务框架如何无缝过渡到服务网格 ASM
How did the data center change from "Britney Spears" to "Mrs. bull"?
优秀的测试/开发程序员与普通的程序员对比......
How latex enters a matrix
If the amount exceeds 6 digits after the decimal point, only 6 digits will be reserved, and if it is less than 6 digits, it will remain the same - Basic accumulation
Machinery -- nx2007 (UG) finite element analysis tutorial 2 -- assembly
Machine learning notes: time series decomposition STL
Exercise "product": self made colorful Prompt string display tool (for loop and if condition judgment)
随机推荐
81. search rotation sort array II
MySQL function
[proteus simulation] 8-bit port detection 8 independent keys
Three text to speech artifacts, each of which is very practical
What is digital garbage? Follow the world's first AI artist to explore meta carbon Art
Using tsne to visualize the similarity of different sentences
Crmeb SMS for program configuration of knowledge payment system
VIM editor common instructions
shell 规范日期格式
2022 6 月25 日交易总结
In depth analysis of a large number of clos on the server_ The root of wait
What if you can't write your composition well? Ape counseling: parents should pay attention to these points
Outsourcing work for three years, waste a step confused
RubyMine开发工具,重构和意图操作
Ansible ad-hoc 临时命令
Quick pow: how to quickly find power
Equivalence class partition method for test case design method
Online sql to CSV tool
HC32M0+ GPIO
Sentinel source code analysis Part 8 - core process - sphu Entry current limiting execution