刘荣星的博客

  • 留言
  • About
一个关注Linux/BSD运维等相关知识的博客
  1. 首页
  2. Linux
  3. Haproxy
  4. 正文

haprox external-check 健康检测

2018-02-02 30399点热度 0人点赞 2条评论

haprox external-check 健康检测可以自定义脚本来检测后端服务,这非常有利于那些经常出现假死,无法通过常规判断端口来检测后台是否正常的问题。
比如,RabbitMQ,业务程序自定义检查等。

HAProxy可以使用二进制或脚本运行外部命令来执行运行状况检查。 当这样做的时候,它需要将自己fork一个新进程。
如果您使用chroot,请确保该命令及其所有依赖项在chroot中可用。
以下指令可用:

In the global section:
external-check: Allows the use of the external check feature. It is disabled by default for security purposes.

In the defaults, backend, or listen section:

option external-check: Enables the use of an external command to perform health check
external-check command : Name of the command to run.
下面的参数被传递给命令:

写了一个bash脚本测试,发现在backend那里传了4个参数,如下,只有后面两个可用
Quoted Values: NOT_USED NOT_USED 172.20.2.71 5672
Total Number of Parameters : 4

where:

and are set only when this directive is configured in a listen section.
只有在侦听部分配置了此伪指令时,才会设置和。
Their values are derived from the first listener (bind) that is either IPv4, IPv6 or a UNIX socket.
它们的值来源于IPv4,IPv6或UNIX套接字的第一个侦听器(绑定)。
In the case of a UNIX socket listener, the is the path of the socket, and the is set to NOT_USED.
In a back end section where there is no bind, both are set to NOT_USED.
and are set to the server address and port dedicated to health checking
Other information is provided through the environment variable which you can use to run a more accurate health check sequence:

HAPROXY_PROXY_ADDR: first bind address, available when used in a listen section
HAPROXY_PROXY_ID: back end UUID
HAPROXY_PROXY_NAME: back end name
HAPROXY_PROXY_PORT: first bind port, available when used in a listen section
HAPROXY_SERVER_ADDR: server address
HAPROXY_SERVER_CURCONN: current active connections on the server
HAPROXY_SERVER_ID: server UUID
HAPROXY_SERVER_MAXCONN: server’s maxconn
HAPROXY_SERVER_NAME: server name
HAPROXY_SERVER_PORT: server port (empty for a UNIX socket)
PATH: PATH environment variable set by external-check path

The exit code is used to determine the server’s operational status:
0: check is considered as positive
any other value is considered as a failure

退出代码用于确定服务器的运行状态:
0:检查被认为是正面的
任何其他值被视为失败

In the external-check path : set the PATH environment variable of to . Default path is “”.
在外部检查路径中:将的PATH环境变量设置为。 默认路径是“”。
比如python的路径

Example
Run a bash script that needs simple commands like ping to perform health checking:

global
	# chroot /var/empty  # disable chroot
	external-check
	[...]
	backend b_myapp
	option external-check
	external-check path "/usr/bin: /bin:/usr/bin/"
	external-check command /etc/hapee-1.5/scripts/check.sh"
标签: Haproxy Linux RabbitMQ
最后更新:2018-02-02

JavasBoy

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

  • Haowu Ge

    哇,大神还在更新

    2018-03-15
    回复
  • godaddy

    朋友 交换链接吗

    2018-03-24
    回复
  • razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
    回复 godaddy 取消回复

    最新 热点 随机
    最新 热点 随机
    CentOS7 python2 安装 elasticsearch 模块 在VMWare Workstation虚拟机里使用 yubikey Gentoo Gnome 登陆界面开启触摸板轻击 python3去除emoji表情符号 记录几个内网广播包 Linux Mint 20 gnome-terminal 使用等距更纱黑体 SC字体
    让我又爱又恨的关键帧的插值法 第一次成功安装Archlinux Gnome3 Gentoo Gnome 登陆界面开启触摸板轻击 在 debian-7.7.0 编译 Realtek RTL8188CUS USB 无线网卡驱动 Krakatoa1.5.1.38002 今天到家了
    分类
    • After Effects / 20篇
    • Apple / 5篇
    • Archlinux / 4篇
    • Bash / 2篇
    • Cinema 4D / 1篇
    • Docker / 1篇
    • eMule / 2篇
    • FreeBSD / 9篇
    • Gentoo / 1篇
    • Go / 2篇
    • gpg / 1篇
    • Graphics / 15篇
    • Haproxy / 1篇
    • ingress / 1篇
    • IntelliJ_IDEA / 1篇
    • java / 2篇
    • kafka / 1篇
    • Linux / 24篇
    • MySQL / 3篇
    • network / 3篇
    • Network / 4篇
    • Nginx / 5篇
    • Perl / 4篇
    • Python / 9篇
    • Python 操作符 / 1篇
    • Python 正则 / 2篇
    • rose / 1篇
    • Script / 4篇
    • Tornado / 1篇
    • Vim / 5篇
    • 学习 / 24篇
    • 电脑 / 29篇
    • 那不勒斯 / 1篇
    • 随笔 / 45篇
    标签聚合
    FreeBSD python After Effects Graphics MAC Linux 双系统 AE

    COPYRIGHT © 2025 刘荣星的博客. ALL RIGHTS RESERVED.

    Theme Kratos Made By Seaton Jiang