Most of available mysql monitoring template uses one user parameter per item. To collect values for 10 items, they will run 10 mysql command (or same command 10 times and get extract desired information from result). These monitoring templates instead get complete result in one item as json content and then uses dependent items to create multiple items on zabbix server
Github links:
Installation
- Zabbix client (mysql slave server) host must have jq installed. If not, please install using
- Add following line in zabbix client configuration. Mysql credentials are stored in /etc/zabbix/.my.cnf for me. Make sure zabbix user has read access to mysql password file
- Myql Template
- Mysql Slave Template
- Import template into zabbix
- Apply "Mysql Slave" template to any mysql slave
sudo apt install jq
UserParameter=Mysql.Server-Status, mysql --defaults-file=/etc/zabbix/.my.cnf --defaults-group-suffix=_monitoring -N -e "show global status" | jq -c '. | split("\n")[:-1] | map (split("\t") | {(.[0]) : .[1]} ) | add ' -R -s
UserParameter=Mysql.Slave-Status, mysql --defaults-file=/etc/zabbix/.my.cnf --defaults-group-suffix=_monitoring -e "show slave status \G" | sed -e "s/^\s*//g" | sed -e "s/:\s*/:/g" | jq -c '. | split("\n")[1:-1] | map (split(":") | {(.[0]) : .[1]} ) | add ' -R -s
Template Contents
Mysql Template: Items |
Mysql Template Triggers |
Mysql Tempalte Graph |
Mysql Slave Template Items |
Mysql Slave Tempalte Triggers |
Mysql Slave Template Graph |