Last active
January 4, 2018 10:47
-
-
Save php-cpm/eb551b8c610bd4f176ea8cae37d7ecc8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ------------------------------------------------------------------------------- | |
# FileName: chk_mysql.sh | |
# Revision: 1.0 | |
# Date: 2018/01/04 | |
# Author: zouyi | |
# Description: | |
# License: MIT | |
# DB Connection | |
MYCONN="mysqladmin " | |
# check args | |
if [ $# -ne "1" ];then | |
echo "arg error!" | |
fi | |
check_extended_status() | |
{ | |
data=$1 | |
echo `$MYCONN extended-status | grep -w $data | cut -d '|' -f3` | |
} | |
# fetch data | |
case $1 in | |
Com_update|Slow_queries|Com_select|Com_rollback|Questions|Com_insert|Com_delete|Com_commit|Bytes_sent|Bytes_received|Com_begin) | |
check_extended_status $1 | |
;; | |
Slow_queries) | |
result=`$MYCONN status |cut -f5 -d":"|cut -f1 -d"O"` | |
echo $result | |
;; | |
Questions) | |
result=`$MYCONN status|cut -f4 -d":"|cut -f1 -d"S"` | |
echo $result | |
;; | |
*) | |
echo "Usage:$0(Uptime|Com_update|Slow_queries|Com_select|Com_rollback|Questions|Com_insert|Com_delete|Com_commit|Bytes_sent|Bytes_received|Com_begin)" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
vim
/etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
modify linemysql.status
like this