Mysql

MySQL is an open-source relational database management system. Its name is a combination of "My", the name of co-founder Michael Widenius`s daughter, and "SQL", the abbreviation for Structured Query Language.

Available solutions

Zabbix version 8.0 7.4 7.2 7.0 6.4 6.2 6.0 5.4 5.0
Download

MySQL by Zabbix agent

Overview

This template is designed for the effortless deployment of MySQL monitoring by Zabbix via Zabbix agent and doesn't require any external scripts.

Requirements

Zabbix version: 8.0 and higher.

Tested versions

This template has been tested on:

  • MySQL 5.7, 8.0, 8.4.7, 9.4

Configuration

Zabbix should be configured according to the instructions in the Templates out of the box section.

Setup

  1. Install Zabbix agent and MySQL client. If necessary, add the path to the mysql and mysqladmin utilities to the global environment variable PATH.
  2. Copy the template_db_mysql.conf file with user parameters into folder with Zabbix agent configuration (/etc/zabbix/zabbix_agentd.d/ by default). Don't forget to restart Zabbix agent.
  3. Create the MySQL user that will be used for monitoring (<password> at your discretion). For example:
CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
GRANT REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';

For more information, please see MySQL documentation.

  1. Create .my.cnf configuration file in the home directory of Zabbix agent for Linux distributions (/var/lib/zabbix by default) or my.cnf in c:\ for Windows. For example:
[client]
protocol=tcp
user='zbx_monitor'
password='<password>'

For more information, please see MySQL documentation.

NOTE: Linux distributions that use SELinux may require additional steps for access configuration.

For example, the following rule could be added to the SELinux policy:

# cat <<EOF > zabbix_home.te
module zabbix_home 1.0;

require {
        type zabbix_agent_t;
        type zabbix_var_lib_t;
        type mysqld_etc_t;
        type mysqld_port_t;
        type mysqld_var_run_t;
        class file { open read };
        class tcp_socket name_connect;
        class sock_file write;
}

#============= zabbix_agent_t ==============

allow zabbix_agent_t zabbix_var_lib_t:file read;
allow zabbix_agent_t zabbix_var_lib_t:file open;
allow zabbix_agent_t mysqld_etc_t:file read;
allow zabbix_agent_t mysqld_port_t:tcp_socket name_connect;
allow zabbix_agent_t mysqld_var_run_t:sock_file write;
EOF
# checkmodule -M -m -o zabbix_home.mod zabbix_home.te
# semodule_package -o zabbix_home.pp -m zabbix_home.mod
# semodule -i zabbix_home.pp
# restorecon -R /var/lib/zabbix

Optionally, it is possible to customize the template:

  • The discovery of tables is disabled by default. To enable table discovery, change the value of the macro {$MYSQL.TABLE.NAMES.MATCHES} to the name of a single table, or use a regex string to include multiple tables.
  • You can also add an additional context macro {$MYSQL.TABLE.NAMES.MATCHES:<dbname>} for specific databases to precisely control which tables should be discovered.
  • To exclude certain tables from discovery, change the value of the macro {$MYSQL.TABLE.NAMES.NOT_MATCHES} to the name of a single table, or use a regex string to exclude multiple tables.
  • You can also add an additional context macro {$MYSQL.TABLE.NAMES.NOT_MATCHES:<dbname>} for specific databases to precisely control which tables should be excluded.

Macros used

Name Description Default
{$MYSQL.HOST}

Hostname or IP of MySQL host or container.

127.0.0.1
{$MYSQL.PORT}

MySQL service port.

3306
{$MYSQL.ABORTED_CONN.MAX.WARN}

Number of failed attempts to connect to the MySQL server for trigger expressions.

3
{$MYSQL.REPL_LAG.MAX.WARN}

Amount of time the replica is behind the source for trigger expressions.

30m
{$MYSQL.SLOW_QUERIES.MAX.WARN}

Number of slow queries for trigger expressions.

3
{$MYSQL.FULLSCAN.RATIO.WARN}

Warning threshold for full table scan ratio.

0.1
{$MYSQL.FULLSCAN.SELECT_RATE.MIN.WARN}

The minimum SELECT statement rate (per second) for trigger expressions.

5
{$MYSQL.BUFF_UTIL.MIN.WARN}

The minimum buffer pool utilization in percent for trigger expressions.

50
{$MYSQL.CREATED_TMP_TABLES.MAX.WARN}

The maximum number of temporary tables created in memory per second for trigger expressions.

30
{$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN}

The maximum number of temporary tables created on a disk per second for trigger expressions.

10
{$MYSQL.CREATED_TMP_FILES.MAX.WARN}

The maximum number of temporary files created on a disk per second for trigger expressions.

10
{$MYSQL.INNODB_LOG_FILES}

Number of physical files in the InnoDB redo log for calculating innodb_log_file_size.

2
{$MYSQL.DBNAME.MATCHES}

Filter of discoverable databases.

.+
{$MYSQL.DBNAME.NOT_MATCHES}

Filter to exclude discovered databases.

information_schema|performance_schema|mysql|sys
{$MYSQL.TABLE.NAMES.MATCHES}

Filter of discoverable tables. Use a context to change the filter of discoverable tables for a specific database.

CHANGE_IF_NEEDED
{$MYSQL.TABLE.NAMES.NOT_MATCHES}

Filter to exclude discovered tables. Use a context to change the filter to exclude discovered tables for a specific database.

CHANGE_IF_NEEDED
{$MYSQL.TOTALSIZE.GROWTH.MAX.WARN}

The warning threshold of the total table size growth for trigger expressions.

300M
{$MYSQL.TOTALSIZE.GROWTH.MAX.CRIT}

The critical threshold of the total table size growth for trigger expressions.

1G
{$MYSQL.FRAGMENTATION.WARN}

The free ratio threshold for warning fragmentation trigger expressions.

0.3
{$MYSQL.FRAGMENTATION.CRIT}

The free ratio threshold for critical fragmentation trigger expressions.

0.6
{$MYSQL.DATA_FREE.MIN.WARN}

The minimum Data_free value for warning fragmentation trigger expressions.

1G
{$MYSQL.DATA_FREE.MIN.CRIT}

The minimum Data_free value for critical fragmentation trigger expressions.

5G
{$MYSQL.TABLE_SIZE.MIN.WARN}

The minimum table size for warning fragmentation trigger expressions.

3G
{$MYSQL.TABLE_SIZE.MIN.CRIT}

The minimum table size for critical fragmentation trigger expressions.

10G

Items

Name Description Type Key and additional info
Get status variables

Gets server global status information.

Zabbix agent mysql.get_status_variables["{$MYSQL.HOST}","{$MYSQL.PORT}"]
Status

MySQL server status.

Zabbix agent mysql.ping["{$MYSQL.HOST}","{$MYSQL.PORT}"]

Preprocessing

  • JavaScript: return value.indexOf('is alive') !== -1 ? 1 : 0;

  • Discard unchanged with heartbeat: 10m

Version

MySQL server version.

Zabbix agent mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"]

Preprocessing

  • Regular expression: (Server version)\s+(.+) \2

  • Discard unchanged with heartbeat: 1d

Uptime

Number of seconds that the server has been up.

Dependent item mysql.uptime

Preprocessing

  • XML XPath: The text is too long. Please see the template.

Aborted clients per second

Number of connections that were aborted because the client died without closing the connection properly.

Dependent item mysql.aborted_clients.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Aborted connections per second

Number of failed attempts to connect to the MySQL server.

Dependent item mysql.aborted_connects.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Connection errors accept per second

Number of errors that occurred during calls to accept() on the listening port.

Dependent item mysql.connection_errors_accept.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Connection errors internal per second

Number of refused connections due to internal server errors, for example, out of memory errors, or failed thread starts.

Dependent item mysql.connection_errors_internal.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Connection errors max connections per second

Number of refused connections due to the max_connections limit being reached.

Dependent item mysql.connection_errors_max_connections.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Connection errors peer address per second

Number of errors while searching for the connecting client's IP address.

Dependent item mysql.connection_errors_peer_address.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Connection errors select per second

Number of errors during calls to select() or poll() on the listening port. The client would not necessarily have been rejected in these cases.

Dependent item mysql.connection_errors_select.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Connection errors tcpwrap per second

Number of connections the libwrap library has refused.

Dependent item mysql.connection_errors_tcpwrap.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Connections per second

Number of connection attempts (successful or not) to the MySQL server.

Dependent item mysql.connections.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Max used connections

The maximum number of connections that have been in use simultaneously since the server start.

Dependent item mysql.max_used_connections

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 1h

Threads cached

Number of threads in the thread cache.

Dependent item mysql.threads_cached

Preprocessing

  • XML XPath: The text is too long. Please see the template.

Threads connected

Number of currently open connections.

Dependent item mysql.threads_connected

Preprocessing

  • XML XPath: The text is too long. Please see the template.

Threads created per second

Number of threads created to handle connections. If the value of Threads_created is large, you may want to increase the thread_cache_size value. The cache miss rate can be calculated as Threads_created/Connections.

Dependent item mysql.threads_created.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Threads running

Number of threads that are not sleeping.

Dependent item mysql.threads_running

Preprocessing

  • XML XPath: The text is too long. Please see the template.

Buffer pool efficiency

Shows how effectively the buffer pool is serving reads.

Calculated mysql.buffer_pool_efficiency
Buffer pool utilization

Ratio of used to total pages in the buffer pool.

Calculated mysql.buffer_pool_utilization
Created tmp files on disk per second

How many temporary files mysqld has created.

Dependent item mysql.created_tmp_files.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Created tmp tables on disk per second

Number of internal on-disk temporary tables created by the server while executing statements.

Dependent item mysql.created_tmp_disk_tables.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Created tmp tables in memory per second

Number of internal temporary tables created by the server while executing statements.

Dependent item mysql.created_tmp_tables.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
InnoDB buffer pool pages free

The number of free pages in the InnoDB buffer pool.

Dependent item mysql.innodb_buffer_pool_pages_free

Preprocessing

  • XML XPath: The text is too long. Please see the template.

InnoDB buffer pool pages total

The total size of the InnoDB buffer pool, in pages.

Dependent item mysql.innodb_buffer_pool_pages_total

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 1h

InnoDB buffer pool read requests

Number of logical read requests.

Dependent item mysql.innodb_buffer_pool_read_requests

Preprocessing

  • XML XPath: The text is too long. Please see the template.

InnoDB buffer pool read requests per second

Number of logical read requests per second.

Dependent item mysql.innodb_buffer_pool_read_requests.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
InnoDB buffer pool reads

Number of logical reads that InnoDB could not satisfy from the buffer pool and had to read directly from the disk.

Dependent item mysql.innodb_buffer_pool_reads

Preprocessing

  • XML XPath: The text is too long. Please see the template.

InnoDB buffer pool reads per second

Number of logical reads per second that InnoDB could not satisfy from the buffer pool and had to read directly from the disk.

Dependent item mysql.innodb_buffer_pool_reads.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
InnoDB log waits per second

Number of InnoDB log waits per second. An increase in this per-second value

indicates that threads are increasingly waiting for redo log writes, which typically

points to disk subsystem performance issues or an innodb_log_file_size that is too small.

Dependent item mysql.innodb_log_waits.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
  • Discard unchanged with heartbeat: 1h

InnoDB row lock time

The total time spent in acquiring row locks for InnoDB tables.

Dependent item mysql.innodb_row_lock_time

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Custom multiplier: 0.001

  • Discard unchanged with heartbeat: 1h

InnoDB row lock wait time avg

Average time spent waiting for row locks in InnoDB.

Dependent item mysql.innodb_row_lock_time_avg

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Custom multiplier: 0.001

  • Discard unchanged with heartbeat: 1h

InnoDB row lock time max

The maximum time to acquire a row lock for InnoDB tables.

Dependent item mysql.innodb_row_lock_time_max

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Custom multiplier: 0.001

  • Discard unchanged with heartbeat: 1h

InnoDB row lock waits

Number of times operations on InnoDB tables had to wait for a row lock.

Dependent item mysql.innodb_row_lock_waits

Preprocessing

  • XML XPath: The text is too long. Please see the template.

InnoDB row lock current waits

Current number of active row lock waits in InnoDB.

Dependent item mysql.innodb_row_lock_current_waits

Preprocessing

  • XML XPath: The text is too long. Please see the template.

InnoDB rows deleted per second

Number of rows deleted from InnoDB tables per second.

Dependent item mysql.innodb_rows_deleted.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
  • Discard unchanged with heartbeat: 1h

InnoDB rows inserted per second

Number of rows inserted into InnoDB tables per second.

Dependent item mysql.innodb_rows_inserted.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
  • Discard unchanged with heartbeat: 1h

InnoDB rows read per second

Number of rows read from InnoDB tables per second.

Dependent item mysql.innodb_rows_read.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
  • Discard unchanged with heartbeat: 1h

InnoDB rows updated per second

Number of rows updated in InnoDB tables per second.

Dependent item mysql.innodb_rows_updated.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
  • Discard unchanged with heartbeat: 1h

Slow queries per second

Number of queries that have taken more than long_query_time seconds.

Dependent item mysql.slow_queries.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Bytes received

Number of bytes received from all clients.

Dependent item mysql.bytes_received.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Bytes sent

Number of bytes sent to all clients.

Dependent item mysql.bytes_sent.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Command delete per second

The Com_delete counter variable indicates the number of times the DELETE statement has been executed.

Dependent item mysql.com_delete.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Command insert per second

The Com_insert counter variable indicates the number of times the INSERT statement has been executed.

Dependent item mysql.com_insert.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Command select per second

The Com_select counter variable indicates the number of times the SELECT statement has been executed.

Dependent item mysql.com_select.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Command update per second

The Com_update counter variable indicates the number of times the UPDATE statement has been executed.

Dependent item mysql.com_update.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Queries per second

Number of statements executed by the server. This variable includes statements executed within stored programs, unlike the Questions variable.

Dependent item mysql.queries.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Questions per second

Number of statements executed by the server. This includes only statements sent to the server by clients and not statements executed within stored programs, unlike the Queries variable.

Dependent item mysql.questions.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
Binlog cache disk use

Number of transactions that used a temporary disk cache because they could not fit in the regular binary log cache, being larger than binlog_cache_size.

Dependent item mysql.binlog_cache_disk_use

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 6h

Select scan per second

The number of SELECT queries that required a full table scan. A high value indicates a lack of or improper use of indexes.

Dependent item mysql.select_scan.rate

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Change per second
  • Discard unchanged with heartbeat: 1h

Full table scan ratio

The ratio of SELECT statements executed as full table scans to all SELECT statements.

Calculated mysql.full_scans.ratio

Preprocessing

  • Discard unchanged with heartbeat: 1h

InnoDB buffer pool wait free

Number of times InnoDB waited for a free page before reading or creating a page. Normally, writes to the InnoDB buffer pool happen in the background. When no clean pages are available, dirty pages are flushed first in order to free some up. This counts the number of waits for this operation to finish. If this value is not small, consider increasing innodb_buffer_pool_size.

Dependent item mysql.innodb_buffer_pool_wait_free

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 6h

InnoDB number open files

Number of open files held by InnoDB. InnoDB only.

Dependent item mysql.innodb_num_open_files

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 6h

Open table definitions

Number of cached table definitions.

Dependent item mysql.open_table_definitions

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 6h

Open tables

Number of tables that are open.

Dependent item mysql.open_tables

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 6h

InnoDB log written

Number of bytes written to the InnoDB log.

Dependent item mysql.innodb_os_log_written

Preprocessing

  • XML XPath: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 6h

Calculated value of innodb_log_file_size

Innodb_log_file_size is calculated as: (innodb_os_log_written-innodb_os_log_written(time shift -1h))/{$MYSQL.INNODB_LOG_FILES}. Innodb_log_file_size is the size in bytes of each InnoDB redo log file in the log group. The combined size can be no more than 512 GB. Larger values mean less disk I/O due to less flushing checkpoint activity, but also slower recovery from a crash.

Calculated mysql.innodb_log_file_size

Preprocessing

  • Discard unchanged with heartbeat: 6h

Triggers

Name Description Expression Severity Dependencies and additional info
MySQL: Service is unreachable

MySQL is unreachable.

last(/MySQL by Zabbix agent/mysql.ping["{$MYSQL.HOST}","{$MYSQL.PORT}"])=0 High
MySQL: Version has changed

The MySQL version has changed. Acknowledge to close the problem manually.

last(/MySQL by Zabbix agent/mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"],#1)<>last(/MySQL by Zabbix agent/mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"],#2) and length(last(/MySQL by Zabbix agent/mysql.version["{$MYSQL.HOST}","{$MYSQL.PORT}"]))>0 Info Manual close: Yes
MySQL: Service has been restarted

MySQL uptime is less than 10 minutes.

last(/MySQL by Zabbix agent/mysql.uptime)<10m Info
MySQL: Failed to fetch data

Zabbix has not received any data for the last 30 minutes.

nodata(/MySQL by Zabbix agent/mysql.uptime,30m)=1 Info Depends on:
  • MySQL: Service is unreachable
MySQL: Server has aborted connections

The number of failed attempts to connect to the MySQL server has been more than {$MYSQL.ABORTED_CONN.MAX.WARN} in the last 5 minutes.

min(/MySQL by Zabbix agent/mysql.aborted_connects.rate,5m)>{$MYSQL.ABORTED_CONN.MAX.WARN} Average Depends on:
  • MySQL: Refused connections
MySQL: Refused connections

Number of refused connections due to the max_connections limit being reached.

last(/MySQL by Zabbix agent/mysql.connection_errors_max_connections.rate)>0 Average
MySQL: Buffer pool utilization is too low

The buffer pool utilization has been less than {$MYSQL.BUFF_UTIL.MIN.WARN}% in the last 5 minutes with server uptime over 1 hour. This means that there is a lot of unused RAM allocated for the buffer pool, which you can easily reallocate at the moment.

max(/MySQL by Zabbix agent/mysql.buffer_pool_utilization,5m)<{$MYSQL.BUFF_UTIL.MIN.WARN} and last(/MySQL by Zabbix agent/mysql.uptime)>3600 Warning
MySQL: Number of temporary files created per second is high

The application using the database may be in need of query optimization.

min(/MySQL by Zabbix agent/mysql.created_tmp_files.rate,5m)>{$MYSQL.CREATED_TMP_FILES.MAX.WARN} Warning
MySQL: Number of on-disk temporary tables created per second is high

The application using the database may be in need of query optimization.

min(/MySQL by Zabbix agent/mysql.created_tmp_disk_tables.rate,5m)>{$MYSQL.CREATED_TMP_DISK_TABLES.MAX.WARN} Warning
MySQL: Number of internal temporary tables created per second is high

The application using the database may be in need of query optimization.

min(/MySQL by Zabbix agent/mysql.created_tmp_tables.rate,5m)>{$MYSQL.CREATED_TMP_TABLES.MAX.WARN} Warning
MySQL: Server has slow queries

The number of slow queries has been more than {$MYSQL.SLOW_QUERIES.MAX.WARN} in the last 5 minutes.

min(/MySQL by Zabbix agent/mysql.slow_queries.rate,5m)>{$MYSQL.SLOW_QUERIES.MAX.WARN} Warning
MySQL: High rate of full table scans

The rate of SELECT statements exceeds {$MYSQL.FULLSCAN.SELECT_RATE.MIN.WARN} per second and the full table scan ratio has been above {$MYSQL.FULLSCAN.RATIO.WARN} for the last 5 minutes.

avg(/MySQL by Zabbix agent/mysql.full_scans.ratio,5m)>{$MYSQL.FULLSCAN.RATIO.WARN} and avg(/MySQL by Zabbix agent/mysql.com_select.rate,5m)>{$MYSQL.FULLSCAN.SELECT_RATE.MIN.WARN} Warning

LLD rule Database discovery

Name Description Type Key and additional info
Database discovery

Used for the discovery of databases.

Zabbix agent mysql.db.discovery["{$MYSQL.HOST}","{$MYSQL.PORT}"]

Preprocessing

  • JavaScript: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 1d

Item prototypes for Database discovery

Name Description Type Key and additional info
Database [{#DBNAME}]: Size

Database size.

Zabbix agent mysql.dbsize["{$MYSQL.HOST}","{$MYSQL.PORT}","{#DBNAME}"]

Preprocessing

  • Discard unchanged with heartbeat: 1h

LLD rule Database [{#DBNAME}]: Table discovery

Name Description Type Key and additional info
Database [{#DBNAME}]: Table discovery

Used for the discovery of tables of the databases.

Zabbix agent mysql.table.discovery["{$MYSQL.HOST}","{$MYSQL.PORT}","{#DBNAME}"]

Preprocessing

  • JavaScript: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 1d

Item prototypes for Database [{#DBNAME}]: Table discovery

Name Description Type Key and additional info
Table [{#DBNAME}/{#TABLE_NAME}]: Get data

Database table data.

Zabbix agent mysql.tabledata["{$MYSQL.HOST}","{$MYSQL.PORT}","{#DBNAME}","{#TABLE_NAME}"]
Table [{#DBNAME}/{#TABLE_NAME}]: Data length

The size of the data in the table.

Dependent item mysql.table.data_length["{#DBNAME}","{#TABLE_NAME}"]

Preprocessing

  • XML XPath: /resultset/row/field[@name='DATA_LENGTH']/text()

  • Custom multiplier: 1

    ⛔️Custom on fail: Discard value

  • Discard unchanged with heartbeat: 1h

Table [{#DBNAME}/{#TABLE_NAME}]: Index length

The size occupied by the table's indexes.

Dependent item mysql.table.index_length["{#DBNAME}","{#TABLE_NAME}"]

Preprocessing

  • XML XPath: /resultset/row/field[@name='INDEX_LENGTH']/text()

  • Custom multiplier: 1

    ⛔️Custom on fail: Discard value

  • Discard unchanged with heartbeat: 1h

Table [{#DBNAME}/{#TABLE_NAME}]: Total size

The sum of DATA_LENGTH and INDEX_LENGTH represents the total size of the table.

Calculated mysql.table.total_size["{#DBNAME}","{#TABLE_NAME}"]

Preprocessing

  • Check for not supported value: any error

    ⛔️Custom on fail: Discard value

  • Discard unchanged with heartbeat: 1h

Table [{#DBNAME}/{#TABLE_NAME}]: Data free

The amount of unused but allocated space.

Dependent item mysql.table.data_free["{#DBNAME}","{#TABLE_NAME}"]

Preprocessing

  • XML XPath: /resultset/row/field[@name='DATA_FREE']/text()

  • Custom multiplier: 1

    ⛔️Custom on fail: Discard value

  • Discard unchanged with heartbeat: 1h

Table [{#DBNAME}/{#TABLE_NAME}]: Free ratio

The fraction of allocated table space that is currently unused (DATA_FREE / (DATA_LENGTH + INDEX_LENGTH)).

High values indicate potential table fragmentation or inefficient space usage.

Calculated mysql.table.free_ratio["{#DBNAME}","{#TABLE_NAME}"]

Preprocessing

  • Check for not supported value: any error

    ⛔️Custom on fail: Discard value

  • Discard unchanged with heartbeat: 1h

Table [{#DBNAME}/{#TABLE_NAME}]: Rows

The approximate number of rows in the table. For InnoDB, the TABLE_ROWS value is approximate and may differ from the actual count.

Dependent item mysql.table.rows["{#DBNAME}","{#TABLE_NAME}"]

Preprocessing

  • XML XPath: /resultset/row/field[@name='TABLE_ROWS']/text()

  • Check for not supported value: any error

    ⛔️Custom on fail: Discard value

  • Discard unchanged with heartbeat: 1h

Trigger prototypes for Database [{#DBNAME}]: Table discovery

Name Description Expression Severity Dependencies and additional info
MySQL: Table [{#DBNAME}/{#TABLE_NAME}]: Total size growth is too high

Total table size growth is too high.

(last(/MySQL by Zabbix agent/mysql.table.total_size["{#DBNAME}","{#TABLE_NAME}"])-min(/MySQL by Zabbix agent/mysql.table.total_size["{#DBNAME}","{#TABLE_NAME}"],5m))>{$MYSQL.TOTALSIZE.GROWTH.MAX.CRIT} High
MySQL: Table [{#DBNAME}/{#TABLE_NAME}]: Total size growth is high

Total table size growth is high.

(last(/MySQL by Zabbix agent/mysql.table.total_size["{#DBNAME}","{#TABLE_NAME}"])-min(/MySQL by Zabbix agent/mysql.table.total_size["{#DBNAME}","{#TABLE_NAME}"],5m))>{$MYSQL.TOTALSIZE.GROWTH.MAX.WARN} Warning Depends on:
  • MySQL: Table [{#DBNAME}/{#TABLE_NAME}]: Total size growth is too high
MySQL: Table [{#DBNAME}/{#TABLE_NAME}]: Free space very high

Free table space is very high (fragmentation critical).

last(/MySQL by Zabbix agent/mysql.table.free_ratio["{#DBNAME}","{#TABLE_NAME}"]) > {$MYSQL.FRAGMENTATION.CRIT} and last(/MySQL by Zabbix agent/mysql.table.data_free["{#DBNAME}","{#TABLE_NAME}"]) > {$MYSQL.DATA_FREE.MIN.CRIT} and last(/MySQL by Zabbix agent/mysql.table.total_size["{#DBNAME}","{#TABLE_NAME}"]) > {$MYSQL.TABLE_SIZE.MIN.CRIT} High
MySQL: Table [{#DBNAME}/{#TABLE_NAME}]: Free space high

Free table space is high (fragmentation warning).

last(/MySQL by Zabbix agent/mysql.table.free_ratio["{#DBNAME}","{#TABLE_NAME}"]) > {$MYSQL.FRAGMENTATION.WARN} and last(/MySQL by Zabbix agent/mysql.table.data_free["{#DBNAME}","{#TABLE_NAME}"]) > {$MYSQL.DATA_FREE.MIN.WARN} and last(/MySQL by Zabbix agent/mysql.table.total_size["{#DBNAME}","{#TABLE_NAME}"]) > {$MYSQL.TABLE_SIZE.MIN.WARN} Warning Depends on:
  • MySQL: Table [{#DBNAME}/{#TABLE_NAME}]: Free space very high

LLD rule Replication discovery

Name Description Type Key and additional info
Replication discovery

Discovery of the replication.

Zabbix agent mysql.replication.discovery["{$MYSQL.HOST}","{$MYSQL.PORT}"]

Preprocessing

  • JavaScript: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 1d

Item prototypes for Replication discovery

Name Description Type Key and additional info
Replication: Replica status {#MASTER_HOST}

Gets status information on the essential parameters of the replica threads.

Zabbix agent mysql.slave_status["{$MYSQL.HOST}","{$MYSQL.PORT}","{#SQL_STATEMENT}"]

Preprocessing

  • JavaScript: The text is too long. Please see the template.

Replication: Replica SQL running state {#MASTER_HOST}

Shows the state of the SQL thread.

Dependent item mysql.slave_sql_running_state["{#MASTER_HOST}"]

Preprocessing

  • XML XPath: /resultset/row/field[@name='Slave_SQL_Running_State']/text()

  • Discard unchanged with heartbeat: 6h

Replication: Seconds behind source {#MASTER_HOST}

The number of seconds the replica SQL thread has been behind processing the source binary log.

A high number (or an increasing one) can indicate that the replica is unable to handle events

from the source in a timely fashion.

Dependent item mysql.seconds_behind_master["{#MASTER_HOST}"]

Preprocessing

  • XML XPath: /resultset/row/field[@name='Seconds_Behind_Master']/text()

  • Discard unchanged with heartbeat: 1h

  • Matches regular expression: \d+

    ⛔️Custom on fail: Set error to: Replication is not performed.

Replication: Replica IO running {#MASTER_HOST}

Indicates whether the I/O thread for reading the source's binary log is running.

Normally, you want this to be Yes unless you have not yet started a replication or have

explicitly stopped it with STOP REPLICA.

Dependent item mysql.slave_io_running["{#MASTER_HOST}"]

Preprocessing

  • XML XPath: /resultset/row/field[@name='Slave_IO_Running']/text()

  • JavaScript: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 1h

Replication: Replica SQL running {#MASTER_HOST}

Indicates whether the SQL thread for executing events in the relay log is running.

As with the I/O thread, this should normally be Yes.

Dependent item mysql.slave_sql_running["{#MASTER_HOST}"]

Preprocessing

  • XML XPath: /resultset/row/field[@name='Slave_SQL_Running']/text()

  • JavaScript: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 1h

Replication: Last IO error {#MASTER_HOST}

Describes the last I/O error message reported by the replica I/O thread that caused replication to stop or behave incorrectly.

Dependent item mysql.slave_io_error["{#MASTER_HOST}"]

Preprocessing

  • XML XPath: /resultset/row/field[@name='Last_IO_Error']/text()

  • Discard unchanged with heartbeat: 6h

Replication: Last SQL error {#MASTER_HOST}

Describes the last SQL error message reported by the replica SQL thread that caused replication to stop or behave incorrectly.

Dependent item mysql.slave_sql_error["{#MASTER_HOST}"]

Preprocessing

  • XML XPath: /resultset/row/field[@name='Last_SQL_Error']/text()

  • Discard unchanged with heartbeat: 6h

Trigger prototypes for Replication discovery

Name Description Expression Severity Dependencies and additional info
MySQL: Replication lag is too high

Replication delay is too long.

min(/MySQL by Zabbix agent/mysql.seconds_behind_master["{#MASTER_HOST}"],5m)>{$MYSQL.REPL_LAG.MAX.WARN} Warning
MySQL: The replica I/O thread is not running

Indicates whether the I/O thread for reading the source's binary log is running.

last(/MySQL by Zabbix agent/mysql.slave_io_running["{#MASTER_HOST}"])=2 Average
MySQL: The replica I/O thread is not connected to a replication source

Indicates whether the replica I/O thread is connected to the source.

last(/MySQL by Zabbix agent/mysql.slave_io_running["{#MASTER_HOST}"])<>1 Warning Depends on:
  • MySQL: The replica I/O thread is not running
MySQL: The SQL thread is not running

Indicates whether the SQL thread for executing events in the relay log is running.

last(/MySQL by Zabbix agent/mysql.slave_sql_running["{#MASTER_HOST}"])=2 Warning Depends on:
  • MySQL: The replica I/O thread is not running

Feedback

Please report any issues with the template at https://support.zabbix.com

You can also provide feedback, discuss the template, or ask for help at ZABBIX forums

Vous n’avez pas trouvé ce que vous cherchiez ?