当前位置:网站首页>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]# 边栏推荐
- What is digital garbage? Follow the world's first AI artist to explore meta carbon Art
- How does webapi relate to the database of MS SQL?
- 如何查看一个文件夹下所有文件的大小?
- SFDP super form development platform v6.0.4 was officially released
- Practical application of information security
- Stimulus reports reporting tool, stimulus creates and builds reports
- C language selection, loop overview
- [mrctf2020]ezpop-1 | PHP serialization
- MySQL function
- CSV文件格式——方便好用个头最小的数据传递方式
猜你喜欢

如何统一项目中包管理器的使用?

Machinery -- nx2007 (UG) finite element analysis tutorial 1 -- simple object

如何拒绝期末复习无用功?猿辅导:找准适合自己的复习方法很重要

在线SQL转CSV工具

第八届“互联网+”大赛 | 云原生赛道邀你来挑战

作文总写不好怎么办?猿辅导:家长要注意这几点

Sentinel source code analysis Part 7 - sentinel adapter module - Summary

赛芯电子冲刺科创板上市:拟募资6.23亿元,共有64项专利申请信息
![[535. encryption and decryption of tinyurl]](/img/b7/7748febe30852ca428fe86b045e9ca.png)
[535. encryption and decryption of tinyurl]

Mechanical --nx2007 (UG) -- gap analysis (interference inspection)
随机推荐
R语言线性回归模型拟合诊断异常值分析家庭燃气消耗量和卡路里实例带自测题
Crmeb SMS for program configuration of knowledge payment system
快手伸手“供给侧”,找到直播电商的“源头活水”?
Practical application of information security
“乘风破浪”的芒果超媒,能上岸吗?
Solution to webkitformboundaryk in post request
2022-06-29:x = { a, b, c, d }, y = { e, f, g, h }, x、y两个小数组长度都是4。 如果有: a + e = b + f = c + g = d + h
【推荐系统】基于用户的协同过滤简明原理与代码实现
作文总写不好怎么办?猿辅导:家长要注意这几点
ctfshow 大赛原题 680-695
[mrctf2020]ezpop-1 | PHP serialization
英伟达Jetson Nano的初步了解
[recommended] how to quickly locate a bug during testing
How latex enters a matrix
numpy的索引和图片的索引一样吗?
Online sql to CSV tool
[concurrent programming] if you use channel to solve concurrency problems?
latex如何输入一个矩阵
Visual Studio 2017 无法打开包括文件: “QOpenGLFunctions_3_3_Core”: No such file or directory
Cantilever beam calculation [matlab code]