简体   繁体   中英

check Mysql with remote host - Icinga2

I'm using Icinga2 to monitor Mysql server on a remote host.Now, I'm trying to configure a mysql_check .

Here is the file service.conf :

apply Service "mysql8" {  
  import "generic-service"
 check_command = "mysql"

 vars.mysql_mode = "uptime"
 vars.mysql_hostname = "remote-host"
 vars.mysql_port = "3306"
 vars.mysql_username = "username"
 vars.myql_password = "password"
 command_endpoint = host.vars.client_endpoint
 assign where host.vars.mysql == true && host.vars.client_endpoint
}

Here is the file host.conf :

object Host "remote-host" {
import "generic-host"
address = "xxx.xxx.xx.xxx"
vars.os = "linux"
vars.mysql = true
host.vars.client_endpoint="remote-host"

When I try a check_MySQL from Icinga2, I got the following error :

Can't connect to MySQL server on 'remote-host' (111)

What can I do to resolve the check_MySQL with the remote-host.

Thanks.

Nice to find you here.

I think that your mysql server doesn't allow the remote access.

In this case :

  1. Open a command prompt and run the following command to open the SSH tunnel.

    $ ssh user@example.com -L 3307:127.0.0.1:3306 -N NB. Replace user@example.com with your ssh username and your ssh hostname or IP adress.

-N : forwarding port

-L : binds a local port to the remote host port 2. Try to connect with your mysql-client

$ mysql --protocol TCP -h localhost -u YOUR_MYSQL_USER -P 3307 -p

It's work? So, :)

  1. Just replace vars.mysql_port=3307 in your icinga service configuration.

Great! great stuff! no ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM