我正在使用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"
当我尝试使用check_MySQL
from Icinga2时,我收到以下错误:
无法连接到'remote-host'上的MySQL服务器(111)
我该怎么做才能用远程主机解析check_MySQL
。
谢谢。
很高兴在这里找到你。
我认为你的mysql服务器不允许远程访问。
在这种情况下 :
[email protected]
替换为您的ssh用户名和ssh主机名或IP地址。-N:转发端口
-L:将本地端口绑定到远程主机端口2.尝试连接mysql-client
$ mysql --protocol TCP -h localhost -u YOUR_MYSQL_USER -P 3307 -p
这是工作?所以,:)
vars.mysql_port=3307
即可。大!好东西!不?