Check mysql-open-files

Overview

Checks the open file usage in MySQL/MariaDB. Logic is taken from MySQLTuner script:mysql_stats(), v1.9.8.

Hints:

  • On RHEL 7+, one way to install the Python MySQL Connector is via pip install pymysql

  • Compared to check_mysql / MySQLTuner this check currently:

    • supports only simple login with username/password (not via SSL/TLS)

    • does not support a connection via socket

Fact Sheet

Check Plugin Download

https://github.com/Linuxfabrik/monitoring-plugins/tree/main/check-plugins/mysql-open-files

Check Interval Recommendation

Every 5 minutes

Can be called without parameters

Yes

Available for

Python 3, Windows

Requirements

Python module pymysql; User with no privileges, locked down to 127.0.0.1 - for example monitoring@127.0.0.1. Usernames in MySQL/MariaDB are limited to 16 chars in specific versions.

Help

usage: mysql-open-files [-h] [-V] [--always-ok] [-H HOSTNAME] [-p PASSWORD]
                        [--port PORT] [-u USERNAME]

Checks the open file usage in MySQL/MariaDB.

options:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  --always-ok           Always returns OK.
  -H HOSTNAME, --hostname HOSTNAME
                        MySQL/MariaDB hostname. Default: 127.0.0.1
  -p PASSWORD, --password PASSWORD
                        Use the indicated password to authenticate the
                        connection. Default:
  --port PORT           MySQL/MariaDB port. Default: 3306
  -u USERNAME, --username USERNAME
                        MySQL/MariaDB username. Default: root

Usage Examples

./mysql-open-files --hostname localhost --username root --password mypassword

Output:

0.2% of open_files_limit used (80.0/32.8K).

States

  • WARN if amount of open files is > 85%.

Perfdata / Metrics

Name

Type

Description

mysql_open_files

Number

Number of regular files currently opened by the server. Does not include sockets or pipes, or storage engines using internal functions.

mysql_open_files_limit

Number

The number of file descriptors available to MariaDB. If you are getting the Too many open files error, then you should increase this limit.

mysql_pct_files_open

Percentage

Open_files / open_files_limit * 100

Credits, License