我正在使用Azure托管的MySQL服务器托管我的数据库。
我想监视使用与其中一个数据库的测试连接,无论服务器是否已启动。如何将此检查添加到Icinga2服务中?
PS - 我知道check_mysql命令但是如何使用它?任何工作示例都会非常有用。感谢
答案 0 :(得分:0)
您需要的最低限度是:
check_mysql [-d database][-H host][-P port][-u user][-p password]
Icinga2中的文字是:
object CheckCommand "mysql" {
import "plugin-check-command"
command = [ PluginDir + "/check_mysql" ]
timeout = 1m
arguments += {
"-C" = "$mysql_cacert$"
"-D" = "$mysql_cadir$"
"-H" = "$mysql_hostname$"
"-L" = "$mysql_ciphers$"
"-P" = "$mysql_port$"
"-S" = {
set_if = "$mysql_check_slave$"
}
"-a" = "$mysql_cert$"
"-c" = "$mysql_critical$"
"-d" = "$mysql_database$"
"-f" = "$mysql_file$"
"-g" = "$mysql_group$"
"-k" = "$mysql_key$"
"-l" = {
set_if = "$mysql_ssl$"
}
"-n" = {
set_if = "$mysql_ignore_auth$"
}
"-p" = "$mysql_password$"
"-s" = "$mysql_socket$"
"-u" = "$mysql_username$"
"-w" = "$mysql_warning$"
}
vars.check_address = {
type = "Function"
}
vars.check_ipv4 = false
vars.check_ipv6 = false
vars.mysql_hostname = "$check_address$"
}
因此,在您的主机定义中,您需要:
vars.mysql_port = [port]
vars.mysql_database = [database]
vars.mysql_password = [password]
vars.mysql_username = [user]
vars.mysql_critical = [critical threshold]
vars.mysql_warning = [warning threshold]
如果你使用Icinga2 Director,那就更容易了。您只需复制命令并创建自己的字段。