TCP_CHECK tcp端口检测
HTTP_GET http接口检测
MISC_CHECK 自定义脚本检测
tcp端口检测
TCP_CHECK {
connect_port 80
connect_timeout 6
nb_get_retry 3
delay_before_retry 3
}
http接口检测
HTTP_GET {
url {
path /index.html
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
自定义Shell脚本监控,返回0代表检测成功,返回1代表检测失败
MISC_CHECK {
misc_path "/tmp/shijiange.sh 192.168.237.50"
misc_timeout 30
}
keepalived检测脚本内容/tmp/shijiange.sh,返回0代表检查正常,返回1代表检查异常
#!/bin/sh
serverip=$1
if [ "$serverip" == "192.168.237.50" ];then
exit 1
fi
exit 0
实际可用的脚本
#!/bin/sh
serverip=$1
curl -s -m 2 http://$serverip
if [ $? -eq 0 ];then
exit 0
else
exit 1
fi