Checks for MySQL.
check-mysql connection --host=127.0.0.1 --port=3306 --user=USER --password=PASSWORD --tls --tls-root-cert=ca.pem --tls-skip-verify --warning=250 --critical=280
First, build this program.
go get github.com/mackerelio/go-check-plugins
cd $(go env GOPATH)/src/github.com/mackerelio/go-check-plugins/check-mysql
go install
Or you can use this program by installing the official Mackerel package. See Using the official check plugin pack for check monitoring - Mackerel Docs.
Next, you can execute this program :-)
check-mysql connection --host=127.0.0.1 --port=3306 --user=USER --password=PASSWORD --warning=250 --critical=280
check-mysql replication --host=127.0.0.1 --port=3306 --user=USER --password=PASSWORD --warning=5 --critical=10
If there are no problems in the execution result, add a setting in mackerel-agent.conf .
[plugin.checks.check-mysql-sample]
command = ["check-mysql", "connection", "--host", "127.0.0.1", "--port", "3306", "--user", "USER", "--password", "PASSWORD", "--warning", "250", "--critical", "280"]
uptime
readonly
replication
connection
Checks the MySQL server uptime.
-H, --host= Hostname (default: localhost)
-p, --port= Port (default: 3306)
-S, --socket= Path to unix socket
-u, --user= Username (default: root)
-P, --password= Password [$MYSQL_PASSWORD]
--tls Enables TLS connection
--tls-root-cert= The root certificate used for TLS certificate verification
--tls-skip-verify Disable TLS certificate verification
-c, --critical= critical if the uptime less than (default: 0)
-w, --warning= warning if the uptime less than (default: 0)
Checks the MySQL server is readonly or not.
-H, --host= Hostname (default: localhost)
-p, --port= Port (default: 3306)
-S, --socket= Path to unix socket
-u, --user= Username (default: root)
-P, --password= Password [$MYSQL_PASSWORD]
--tls Enable TLS connection
--tls-root-cert= The root certificate used for TLS certificate verification
--tls-skip-verify Disable TLS certificate verification
Checks MySQL replication status and its second behind master.
-H, --host= Hostname (default: localhost)
-p, --port= Port (default: 3306)
-S, --socket= Path to unix socket
-u, --user= Username (default: root)
-P, --password= Password [$MYSQL_PASSWORD]
--tls Enable TLS connection
--tls-root-cert= The root certificate used for TLS certificate verification
--tls-skip-verify Disable TLS certificate verification
-c, --critical= critical if the seconds behind master is over (default: 250)
-w, --warning= warning if the seconds behind master is over (default: 200)
Checks the number of MySQL connections.
-H, --host= Hostname (default: localhost)
-p, --port= Port (default: 3306)
-S, --socket= Path to unix socket
-u, --user= Username (default: root)
-P, --password= Password [$MYSQL_PASSWORD]
--tls Enable TLS connection
--tls-root-cert= The root certificate used for TLS certificate verification
--tls-skip-verify Disable TLS certificate verification
-c, --critical= critical if the number of connection is over (default: 250)
-w, --warning= warning if the number of connection is over (default: 200)
Please execute check-mysql -h
and you can get command line options.
You can perform basic tests under test_8
(MySQL 8.0.23) and test_57
(MySQL 5.7.8) directory.
- docker and docker-compose
- check-mysql is available in
PATH
(cd ..; make build)
./test_8/test.sh # MySQL 8.0.23
./test_57/test.sh # MySQL 5.7.8