当前位置:网站首页>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]# 边栏推荐
- Tetris game based on STM32F103
- I, 33 years old, ByteDance test development, unveiled the real income of Beijing "test post"
- 赛芯电子冲刺科创板上市:拟募资6.23亿元,共有64项专利申请信息
- How to build your own blog website by yourself
- Application of pointer in STC89C52 single chip microcomputer and demonstration of practical cases
- ResizeKit2.NET大小和分辨率独立
- 测试用例设计方法之等价类划分方法
- Interview summary
- What if you can't write your composition well? Ape counseling: parents should pay attention to these points
- 81. 搜索旋转排序数组 II
猜你喜欢

numpy的索引和图片的索引一样吗?

Precautions for postoperative fundus hemorrhage / / must see every day

利用huggingface进行文本分类

STC89C52 single chip microcomputer simple calculator design and code demonstration

81. search rotation sort array II

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

Wechat applet - requestsubscribemessage:fail can only be invoked by user tap gesture

Newton method (optimization of two variable functions)

Interface Association of postman

Solving plane stress problem with MATLAB
随机推荐
Solve the problem of repairing Visual Basic exceptions with excel/wps plug-in of choice financial terminal
Resizekit2.net size and resolution independent
Transaction summary on June 25, 2022
Stimulus reports reporting tool, stimulus creates and builds reports
Quality management of functional modules of MES management system
英伟达Jetson Nano的初步了解
Netease cloud music beta music social app "mus" matches friends of the same frequency through music
Command line Basics
Questions about database: database attachment
Clean, talk, bring children, and get rid of the label of "artificial mental retardation" for the sweeper
Stringredistemplate disconnects and the value disappears
Vl6180x distance and light sensor hands-on experience
在线文本数字识别列表求和工具
关于c语言main函数中int argc,char **argv的理解
latex如何输入一个矩阵
Common settings in idea
[recommendation system] concise principle and code implementation of user based collaborative filtering
xshell中怎么切换到root用户
Wechat applet - requestsubscribemessage:fail can only be invoked by user tap gesture
Too voluminous ~ eight part essay, the strongest king of interview!