epmmm performance monitor mysql(mysql, mariadb, percona), memcached, redis, tendis, numa cpu, linux tcp status, linux disk stats for zabbix 2.4 above
This is easy to monitor one physical machine with multiple mysql instances, multiple redis instances, multiple memcached instances, multiple tendis instances.
Authors: earl86
link:
https://github.com/earl86/epmmm
Info: The scripts only tested on python 3
install python3 and pip3 and zabbix_sender
yum install python3-devel
pip3 install py-zabbix
pip3 install argparse
pip3 install strip_ansi
pip3 install pexpect
pip3 install pymemcache
pip3 install PyMySQL
pip3 install redis
pip3 install configparser
Zabbix server call agent run the wrapper *.sh script every 10 seconds. and then zabbix agent put data to zabbix server in trapper mode.
- Modify the zabbix_meta.ini
[zabbix_server]
META_ZABBIX_SERVER_IP=192.168.0.100
META_ZABBIX_SERVER_PORT=10051
- Install the scripts and conf to zabbix agent server
- Import the template to zabbix web
- Restart the zabbix agent
On zabbix server test the script using:
##Zabbix agent key:
- epmmm.mysql.check[{HOST.NAME},{HOST.IP},{$MYSQL_PORT},check,{$SERVICEUNIQ},{$ZABBIXTYPE}]
- epmmm.mysql.check[{HOST.NAME},{HOST.IP},{$MYSQL_PORT},mysqld_cpu_use,{$SERVICEUNIQ},{$ZABBIXTYPE}]
- {$MYSQL_PORT} : 3306
- {$SERVICEUNIQ}: ''
- {$SERVICE_ROLE}: master/slave/backup
- {$ZABBIXTYPE}: name in zabbix_meta.ini
ps -ef |grep mysql
root 157401 1 0 2021 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my-mysql-instance.cnf
mysql 159694 157401 99 2021 ? 28847-16:16:22 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my-mysql-instance.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/mysql-instance/data --plugin-dir=/usr/local/mysql/lib/mysql/plugin --user=mysql --log-error=/data/mysql/mysql-instance/log/log-error.log --pid-file=/data/mysql/mysql-instance/tmp/mysqld.pid --socket=/data/mysql/mysql-instance/tmp/mysql.sock --port=3306
USERNAME=zabbix PASSWORD=zabbix@2014
zabbix_get -s 192.168.0.1 -p 10050 -k "epmmm.mysql.check[zabbixmysql,192.168.0.1,3306,check,mysql-instance,zabbix_server]"
/usr/local/bin/python3 epmmm_get_mysql_stats.py --servicename ${SERVICENAME} --serviceip ${SERVICEIP} --serviceport ${SERVICEPORT} --username ${USERNAME} --password ${PASSWORD} --zabbix_type ${ZABBIXTYPE}
The default monitor mysql port is 3306, if you need to monitor other port, you need to add the Inherited and host macros:{$MYSQL_PORT}=xxxx on the monitor Host
Enjoy it!
use like MySQL