0

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

Ani
  • 463
  • 4
  • 20

1 Answers1

0

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.

cflinspach
  • 290
  • 1
  • 4
  • 16
  • I am using a managed service and I only have endpoints but do not have any hosts setup for this! – Ani Aug 21 '17 at 07:14
  • Just add the mysql service as a host and use the check_mysql command for the host check instead of ping or host alive. – cflinspach Aug 21 '17 at 15:50