1

Is there some plugin to monitoring database size in nagios? Of course i can write some bash script with query like:

SELECT table_schema \"DB Name\", sum( data_length + index_length ) / 1024 / 1024 \"DB Size in MB\" FROM information_schema.TABLES GROUP BY table_schema

But maybe there is some.

Thank you for help.

Rafał Kamiński
  • 187
  • 2
  • 5
  • 15

1 Answers1

3

Have a look at the check_mysql_query plugin:

check_mysql_query -H myserver -u mylogin -p mypassword -q "SELECT sum( data_length + index_length ) / 1024 / 1024 \"DB Size in MB\" FROM information_schema.TABLES GROUP BY table_schema" -w 200 -c 300

The SQL query (-q) can only return a single value and it must be numeric.

Kev
  • 7,777
  • 17
  • 78
  • 108
  • The same approach could be used to monitor individual table sizes with a `-q` like `SELECT round(((data_length + index_length) / 1024 / 1024), 2) as \"DB Size in MB\" FROM information_schema.TABLES WHERE table_schema = 'databaseName' AND table_name = 'tableName'`. – Jaime Hablutzel Oct 02 '21 at 03:01