X

Monitor mysql Service In My Zabbix Server

Now I have to show how to check my zabbix mysql service. Another tutorial how to monitoring mysql service via zabbix. Zabbix is  very important tools for database monitoring system. So I will configure step by step zabbix own server mysql monitor.

Install Zabbix server on ubuntu 16.04
How To Add Windows Host In Zabbix Server

Step #01: Open zabbix agent configure  /etc/zabbix/zabbix_agentd.conf  file.

root@zabbix-server:~# vim /etc/zabbix/zabbix_agentd.conf

Check user parameter file name as like below.

Step #02: Add zabbix user parameter for mysql server monitoring. Create userparameter_mysql.conf file into /etc/zabbix/zabbix_agent.d/ location. Open vim /etc/zabbix/zabbix_agent.d/userparameter_mysql.conf. Then insert below all lines.

# For all the following commands HOME should be set to the directory that has .my.cnf file with password information.

# Flexible parameter to grab global variables. On the frontend side, use keys like mysql.status[Com_insert].
# Key syntax is mysql.status[variable].
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -N | awk '{print $$2}'

# Flexible parameter to determine database or table size. On the frontend side, use keys like mysql.size[zabbix,history,data].
# Key syntax is mysql.size[, ,].
# Database may be a database name or "all". Default is "all".
# Table may be a table name or "all". Default is "all".
# Type may be "data", "index", "free" or "both". Both is a sum of data and index. Default is "both".
# Database is mandatory if a table is specified. Type may be specified always.
# Returns value in bytes.
# 'sum' on data_length or index_length alone needed when we are getting this information for whole database instead of a single table
UserParameter=mysql.size[*],bash -c 'echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema=\"$1\"")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name=\"$2\"");" | HOME=/var/lib/zabbix mysql -N'

UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping | grep -c alive
UserParameter=mysql.version,mysql -V

Step #03: Type mysql -uroot -ppassw0rd for create database, drop database, create user, create table, drop user, drop table etc.

root@zabbix-server:~#  mysql -uroot -ppassw0rd

See as like below.

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 21406
Server version: 5.5.55-0ubuntu0.14.04.1-log (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

Now create user for send data from mysql databases server with password.

mysql> create user ‘zabbix_user’@’localhost’ identified by ‘passw0rd’;

mysql> grant all privileges on *.* to ‘zabbix_user’@’localhost’;

mysql> flush privileges;

mysql> exit;
Step #04: Check userparameter_mysql.conf file  on /var/lib/zabbix is blank. Now created .my.cnf file on the /var/lib/zabbix/ location.

Open .my.cnf  file as below command.

root@zabbix-server:~#  vim /var/lib/zabbix/.my.cnf

Then insert previously created mysql user and password on .my.cnf file.

[mysql]
user=zabbix_user
password=passw0rd
host=localhost

[mysqladmin]
user=zabbix_user
password=passw0rd
host=localhost

Then zabbix agent restart and mysql service restart.

root@zabbix-server:~#  service zabbix-agent restart
root@zabbix-server:~#  service mysql restart

Step #05: Now goto your zabbix server and check latest data see all data as like below image.

Click Monitoring/Latest data then select Hosts “zabix server name” again click apply.

Thank You Very much.

 

5 1 vote
Article Rating
Admin: I am system administrator as Windows and Linux platform. I have 4 years skilled from the professional period. I have to configure Linux based system such as an Asterisk VOIP system, Network monitoring tools (ZABBIX), Virtualization (XEN Server), Cloud computing (Apache CloudStack) etc. Now share my professional skill each interested person. Thanks to all.

View Comments (1)

  • Hi, I have done everything you described except for the fact that i use /etc/zabbix a &HOME and changed home dir accordingly but in Zabbix server i get for every item: 0/27/2018 08:16:57 PM
    /usr/bin/mysql: unknown variable 'login-path=monitoring'
    executing zabbix_agentd -t "mysql.version" on prompt give proper repsonse: [t|mysql Ver 15.1 Distrib 10.3.10-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2]

Leave a Comment