0

我正在使用 Azure 托管的 MySQL 服务器来托管我的数据库。

我想使用与其中一个数据库的测试连接来监视服务器是否启动。如何将此检查添加到我的 Icinga2 服务?

PS - 我知道 check_mysql 命令但如何使用它?任何工作示例都会非常有帮助。谢谢

4

1 回答 1

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,那就容易多了。您可以克隆命令并创建自己的字段。

于 2017-08-18T15:16:14.867 回答