Monitor managed MySQL Server from Icinga

878 Views Asked by At

I am using an Azure managed MySQL server to host my DBs.

I want to monitor using a test connection to one of the DB whether server is up or not. How can I add this check to my Icinga2 service?

PS - I am aware of check_mysql command but how to use it? Any working example will be very helpful. Thanks

1

There are 1 best solutions below

2
cflinspach On

The bare minimum you'll need is:

check_mysql [-d database][-H host][-P port][-u user][-p password]

The text for that in Icinga2 is:

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$"
}

So on your Host definition you'll need to have:

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]

If your using Icinga2 Director it's alot easier. You can just make a clone of the command and create your own fields.