使用远程主机检查Mysql-Icinga2

时间:2019-03-15 03:40:28

标签: mysql remote-access remote-server icinga2

我正在使用Icinga2监视远程主机上的Mysql服务器。现在,我正在尝试配置mysql_check

这是文件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
}

这是文件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"

当我尝试使用Icinga2中的check_MySQL时,出现以下错误:

  

无法连接到“远程主机”(111)上的MySQL服务器

我该怎么办才能与远程主机解析check_MySQL

谢谢。

1 个答案:

答案 0 :(得分:0)

很高兴在这里找到你。

我认为您的mysql服务器不允许远程访问。

在这种情况下:

  1. 打开命令提示符,然后运行以下命令以打开SSH隧道。

    $ ssh user@example.com -L 3307:127.0.0.1:3306 -N 注意将user@example.com替换为您的ssh用户名和ssh主机名或IP地址。

-N:转发端口

-L:将本地端口绑定到远程主机端口 2.尝试连接您的mysql-client

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

工作吗?所以,:)

  1. 只需在您的icinga服务配置中替换vars.mysql_port=3307

太好了!好东西!不?

相关问题