GitXplorerGitXplorer
d

mysql_maxdiskusage

public
15 stars
1 forks
1 issues

Commits

List of commits on branch master.
Unverified
eadca0621c49e807944fe75b804d5e60d349b9f3

Release 0.9

ddveeden committed 6 years ago
Verified
3dcf0fe2de60fe3c0aaeffe3f6113913338f534c

Merge pull request #3 from dveeden/add_note

ddveeden committed 6 years ago
Unverified
cde8aa8262026e79f58e505a225614381e384b4e

Add setting to add an message to the warning message

ddveeden committed 6 years ago
Unverified
c7c99e5542d34a48c02ec8172a04cb712787a90f

Guard against overriding TRUE/FALSE

ddveeden committed 6 years ago
Unverified
d3a6b6972ebf06a970beaa5307959d5beb9b7ef1

Make the plugin compatible with MySQL 8.0

ddveeden committed 6 years ago
Unverified
3ece0d33ab8832dfe5fb1cdb4880b061694aabc9

Extend README

ddveeden committed 7 years ago

README

The README file for this repository.

Usage

mysql> INSTALL PLUGIN maxdiskusage SONAME 'maxdiskusage.so';
mysql> SET GLOBAL maxdiskusage_minfree=1000;
mysql> SET GLOBAL maxdiskusage_monitor_fs='/var/lib/mysql';
mysql> SET GLOBAL maxdiskusage_action='WARN';

With WARN:

mysql> INSERT INTO t1() VALUES();
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> SHOW WARNINGS;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1642 | Writing to a server with high disk usage |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)

With BLOCK:

mysql> INSERT INTO t1() VALUES();
ERROR 3164 (HY000): Aborted by Audit API ('MYSQL_AUDIT_TABLE_ACCESS_INSERT';1).

This message is also written to the error log:

2018-02-21T08:55:10.490978Z 12 [ERROR] Plugin maxdiskusage reported: 'BLOCKING QUERY: Free filesystem space on /home (7682 MB) is less than 10000 MB: INSERT INTO t1() VALUES()'

Settings

Setting Default Description
maxdiskusage_action WARN WARN, BLOCK or WARN_AND_BLOCK
maxdiskusage_note '' Note to add to the warning message
maxdiskusage_minfree 0 Act if less than x MB of free space is available
maxdiskusage_monitor_fs /var/lib/mysql Directory to monitor, usally @@datadir
maxdiskusage_pct 100 Execute the action if over this percentage of usage
maxdiskusage_block_pct 100 Block if over this percentage of usage if action is WARN_AND_BLOCK
maxdiskusage_warn_skip_count 1000 Skip every x events, reduces warning rate

These can be set with SET GLOBAL, but you probably want to put those in your my.cnf

Building

This is tested against MySQL 5.7 and MySQL 8.0. Pull requests for other MySQL and MariaDB versions are welcome.

Copy the mysql_maxdiskusage directory to the plugin directory of the MySQL source code. Build the code as usual or just run make maxdiskusag. Either use the resulting build or copy maxdiskusage.so to the plugin_dir.

https://dev.mysql.com/doc/refman/5.7/en/compiling-plugin-libraries.html

Might contain some code from https://github.com/gkodinov/audit_tripwire

Contributing

Please open issues and send pull requests on GitHub.

Please format your code with clang-format.

Related links