sensu-plugins / sensu-plugins-mysql

This plugin provides native MySQL instrumentation for monitoring and metrics collection, including: service health, database connectivity, `InnoDB` locks, replication status, metrics collection, and sending metrics to a MySQL database.
http://sensu-plugins.io
MIT License
18 stars 62 forks source link

Script metrics-mysql-multiple-select-count added #91

Closed nagyt234 closed 5 years ago

nagyt234 commented 5 years ago

Pull Request Checklist

Is this in reference to an existing issue?

No

General

New Plugins

Purpose

The script metrics-mysql-select-count is not efficient enough, if multiple count metrics requested, because the majority of the CPU load is the starting of the script. The new metrics-mysql-multiple-select-count is implemented to solve this problem. Unlimited number of SQL count queries can be defined as a JSON string.

Known Compatibility Issues

Manual test

$ mysql -uroot -p**** test -e 'SELECT COUNT(*) FROM foo;SELECT COUNT(*) FROM bar;'
mysql: [Warning] Using a password on the command line interface can be insecure.
+----------+
| COUNT(*) |
+----------+
|   114059 |
+----------+
+----------+
| COUNT(*) |
+----------+
|    90941 |
+----------+
$ bin/metrics-mysql-multiple-select-count.rb -d test -h localhost -S /var/run/mysqld/mysqld.sock -u root -p**** -q '{"foo_count":"SELECT COUNT(*) FROM foo", "bar_count":"SELECT COUNT(*) FROM bar"}'
mysql.query_count.foo_count 114059 1544534615
mysql.query_count.bar_count 90941 1544534615
majormoses commented 5 years ago

released: https://rubygems.org/gems/sensu-plugins-mysql/versions/3.1.0