zabbix monitoring mysql survival and performance

The Zabbix environment has been deployed:Zabbix_aget: installed in / etc/zabbix1. Open port 10050 firewall-cmd --zone=public --add-port=10050/tcp --p...

The Zabbix environment has been deployed:
Zabbix_aget: installed in / etc/zabbix
1. Open port 10050

firewall-cmd --zone=public --add-port=10050/tcp --permanent firewall-cmd--reload

2. Close setenforce r
setenforce 0

3.vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
Write:

####Scripts for monitoring mysql performance UserParameter=mysql.status[*],/etc/zabbix/zabbix_agentd.d/check_ mysql.sh $1 #####Monitor whether mysql survives UserParameter=mysql.ping,systemctl status mysqld | grep -c "active" #####mysql version UserParameter=mysql.version,mysql -V

4.
cat /etc/zabbix/zabbix_agentd.d/check_mysql.sh

```#!/bin/sh # ---------------------------------------------------------------------------------------- # FileName: check_mysql.sh # Revision: 1.0 # Date: 2019/05/15 # Author: salarh # Email: [email protected] //User name MYSQL_USER='zabbix' //Password MYSQL_PWD='zabbix@123' //Host address / IP MYSQL_HOST='ip' //port MYSQL_PORT='3306' //data connection MYSQL_CONN="/usr/bin/mysqladmin -u$ -p$ -h$ -P$" //Is the parameter correct if [ $# -ne "1" ];then echo "arg error!" fi //get data case $1 in Uptime) result=`$ status 2>/dev/null |cut -f2 -d":"|cut -f1 -d"T"` echo $result ;; Com_update) result=`$ extended-status 2>/dev/null |grep -w "Com_update"|cut -d"|" -f3` echo $result ;; Slow_queries) result=`$ status 2>/dev/null |cut -f5 -d":"|cut -f1 -d"O"` echo $result ;; Com_select) result=`$ extended-status 2>/dev/null |grep -w "Com_select"|cut -d"|" -f3` echo $result ;; Com_rollback) result=`$ extended-status 2>/dev/null |grep -w "Com_rollback"|cut -d"|" -f3` echo $result ;; Questions) result=`$ status 2>/dev/null |cut -f4 -d":"|cut -f1 -d"S"` echo $result ;; Com_insert) result=`$ extended-status 2>/dev/null |grep -w "Com_insert"|cut -d"|" -f3` echo $result ;; Com_delete) result=`$ extended-status 2>/dev/null |grep -w "Com_delete"|cut -d"|" -f3` echo $result ;; Com_commit) result=`$ extended-status 2>/dev/null |grep -w "Com_commit"|cut -d"|" -f3` echo $result ;; Bytes_sent) result=`$ extended-status 2>/dev/null |grep -w "Bytes_sent" |cut -d"|" -f3` echo $result ;; Bytes_received) result=`$ extended-status 2>/dev/null |grep -w "Bytes_received" |cut -d"|" -f3` echo $result ;; Com_begin) result=`$ extended-status 2>/dev/null |grep -w "Com_begin"|cut -d"|" -f3` 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

To grant authorization:

chmod +x /etc/zabbix/zabbix_agentd.d/check_mysql.sh chown zabbix.zabbix /etc/zabbix/zabbix_agentd.d/check_mysql.sh

5. Test on ZABBIX agent:

zabbix_agentd -t mysql.ping

6. ZABBIX? Server test

zabbix_get -s ip -P port -k mysql.ping

7. On the ZABBIX interface, select:

Add it up

About debugging: mainly looking at the log
When ZABBIX get is used to test the value on the server side, it is found that 0 is not the same as the script executed on the agent side.
When this problem occurred, I still couldn't get the clue at first, and I took a lot of detours. Later, I found that I could debug logs:
Skip the log level of zabbix agent to the highest 4, and restart zabbix agent.
DebugLevel=4
All log levels for zabbix are as follows:

  • no debug no log
  • critical information disaster log
  • error information error level
  • warnings alert level
  • for debugging (produces lots of information) debugging level

Such as:
Find that selinux is not closed, just close it

10 November 2019, 09:56 | Views: 7642

Add new comment

For adding a comment, please log in
or create account

0 comments