IDEAL SERVERS' UPWORK !

ANY SERVERS – RELiABiLiTY, SECURiTY, PERFORMANCE.

Monitor MySQL with zabbix-agentd with the help UserParameters.

without comments

For the use Zabbix’s template with the name Template App MySQL neccessary create the file:

 
localhost:/etc/zabbix/zabbix-agentd.conf.d # ll
-rw-r--r-- 1 root root   418 Oct 31 15:07 userparameter_mysql.conf
localhost:/etc/zabbix/zabbix-agentd.conf.d #

Before any the actions us need create the zabbix’s user for Mysql. This user has not any the privileges.
We will be use his to connection to the Mysql.

GRANT USAGE ON *.* TO 'monitoring'@127.0.0.1' IDENTIFIED BY '123456';
GRANT USAGE ON *.* TO 'monitoring'@'localhost' IDENTIFIED BY '123456';
or
GRANT USAGE ON *.* TO 'monitoring'@'%' IDENTIFIED BY '123456';  

For the change the password:

SET PASSWORD FOR 'monitoring'@'localhost' = PASSWORD('123456');

Next. You should insert to the file the next records:

#Here $1 - the name, $2 - the password, $3 - the name of the field, $4 - the value of the field
UserParameter=mysql.status[*],mysqladmin -u$1 -p$2 extended-status 
   | awk '$$2 ~ /^$3$/ { if($$4 != "|") print $$4 }'
UserParameter=mysql.ping[*],mysqladmin -u$1 -p$2 ping 
   | egrep alive | wc -l
UserParameter=mysql.version,mysqladmin -V
UserParameter=mysql.slave[*],mysql -u$1 -p$2 -e "show slave status\G" 
   | awk '/$3:/ {print $NF}' | sed s/Yes/1/ | sed s/No/0/

Reload the zabbix-agentd

/etc/init.d/zabbix-agentd restart

The key parameters should be username and password for Mysql. For mysql.status the name of the parameter you want to query.
For the example:

mysql.status[monitoring,123456,Uptime]

Next. We should be use macros for a different username/password combination on each host.
So it would be something like:

mysql.status[{$MYSQL_USER},{$MYSQL_PASSWORD},Uptime]

And, of course, you should define these the macros for the host.

Written by spectre

October 31st, 2012 at 2:11 pm

Posted in Zabbix

Leave a Reply

*