自动化运维、大数据、Docker

【转载】ZABBIX监控HaProxy

haproxy配置

下载地址

http://files.cnblogs.com/files/MYSQLZOUQI/HAProxy%E4%BB%8B%E7%BB%8D-by-Godbach.pdf

资料
http://www.cnblogs.com/dkblog/archive/2011/07/06/2098949.html
HAProxy相比LVS的使用要简单很多,功能方面也很丰富。当 前,HAProxy支持两种主要的代理模式:”tcp”也即4层(大多用于邮件服务器、内部协议通信服务器等),和7层(HTTP)。在4层模式 下,HAProxy仅在客户端和服务器之间转发双向流量。7层模式下,HAProxy会分析协议,并且能通过允许、拒绝、交换、增加、修改或者删除请求 (request)或者回应(response)里指定内容来控制协议,这种操作要基于特定规则 因支持强大灵活的7层acl规则,广泛作为HTTP反向代理。
我现在用HAProxy主要在于它有以下优点,这里我总结下:
一、免费开源,稳定性也是非常好,这个可通过我做的一些小项目可以看出来,单Haproxy也跑得不错,稳定性可以与LVS相媲美;
二、根据官方文档,HAProxy可以跑满10Gbps-New benchmark of HAProxy at 10 Gbps using Myricom’s 10GbE NICs (Myri-10G PCI-Express),这个作为软件级负载均衡,也是比较惊人的;
三、HAProxy可以作为MySQL、邮件或其它的非web的负载均衡,我们常用于它作为MySQL(读)负载均衡;
四、自带强大的监控服务器状态的页面,实际环境中我们结合Nagios进行邮件或短信报警,这个也是我非常喜欢它的原因之一;
五、HAProxy支持虚拟主机。
===================================================================================
在做反向代理服务器的负载均衡时,我们通常会使用nginx的均衡配置。其实,haproxy的负载均衡也是属于这一类的。那么关于这方面的配置过程我们现在来进行一下讲解。首先,对haproxy进行一个简单的介绍,之后就是安装和配置环节了。
HAProxy介绍
反向代理服务器,支持双机热备支持虚拟主机,但其配置简单,拥有非常不错的服务器健康检查功能,当其代理的后端服务器出现故障, HAProxy会自动将该服务器摘除,故障恢复后再自动将该服务器加入。新的1.3引入了frontend,backend;frontend根据任意 HTTP请求头内容做规则匹配,然后把请求定向到相关的backend.
http://blog.liuts.com/post/223/ (搭建四层负载均衡器)
http://rfyimcool.blog.51cto.com/1030776/413187 (搭建七层负载均衡器)
http://blog.chinaunix.net/uid-27022856-id-3236257.html

HAProxy的优点:

1、HAProxy是支持虚拟主机的,可以工作在4、7层(支持多网段);
2、能够补充Nginx的一些缺点比如Session的保持,Cookie的引导等工作;
3、支持url检测后端的服务器;
4、它跟LVS一样,本身仅仅就只是一款负载均衡软件;单纯从效率上来讲HAProxy更会比Nginx有更出色的负载均衡速度,在并发处理上也是优于Nginx的;
5、HAProxy可以对Mysql读进行负载均衡,对后端的MySQL节点进行检测和负载均衡,不过在后端的MySQL slaves数量超过10台时性能不如LVS;
6、HAProxy的算法较多,达到8种;

http://blog.chinaunix.net/uid/10167808/list/1.html?cid=178438
haproxy相关名词
listeners
session
task
ACL
rule
连接处理:_do_poll() ->listener_accept ->session_accept ->fronend_accept()
相关函数
signal_process_queue – 处理信号队列
wake_expired_tasks – 唤醒超时任务
process_runnable_tasks – 处理可运行的任务
jobs == 0 – 无任务可执行,结束循环
cur_poller.poll() – 执行 poll 处理 fd 的 IO 事件
处理可能仍有 IO 事件的 fd
一个请求完全完全有可能因为一些异常原因,或者 请求长度本身就比较大而被拆分到不同的 IP 报文中,一次 read 系统调用可能只读取到其 中的一部分内容。因此,该函数会同时分析已经接收到的数据,并确认是否已经接收到了 完整的 HTTP 请求。只有接收到了完整的 HTTP 请求,该函数处理完,才会交给下一个 analyser 处理,否则只能结束请求的处理,等待接收更多的数据,解析出一个完整的 HTTP 请求才行。
HAProxy 支持多种异步机制,有 select,poll,epoll,kqueue 等。
epoll 的代码在源文件 ev_epoll.c 中。epoll 的关键处理逻辑集中在函数 _do_poll() 中

复制代码

haproxy.cfg
global

    log         127.0.0.1 local2   #定义全局syslog服务,127.0.0.1表示将日志发送到本地保存

    chroot      /var/lib/haproxy       
    pidfile     /var/run/haproxy.pid      
    maxconn     4000              #最大连接数                      
    user        haproxy           #用户名
    group       haproxy           #组
    daemon                        #以守护进程方式运行

    
    stats socket /var/lib/haproxy/stats     # turn on stats unix socket


defaults            #为frontend和backend提供默认参数
    mode                    tcp                 #模式
    log                     global               #日志            
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3                  #重试次数
    timeout http-request    10s                #请求超时时间
    timeout queue           1m
    timeout connect         10s                #连接超时时间 
    timeout client          1m                  #客户端空闲超时
    timeout server          1m                  #服务器端空闲超时
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000                #最大连接数量
    stats uri                /haproxy_status     #监控页面地址


frontend  main *:80   #main为frontend的名称,可以随便起一个名称,监听端口
   # acl url_static       path_beg       -i /static /images /javascript /stylesheets
   # acl url_static       path_end       -i .jpg .gif .png .css .js

   # use_backend static          if url_static
   # default_backend             app
   acl is_zabbix    path_beg /zabbix              #如果请求是以/zabbix结尾则使用zabbix_app这个应用,实现反向代理
   use_backend          zabbix_app  if is_zabbix
   default_backend       tomcat_app





backend zabbix_app                           #配置后台应用 zabbix_app
    balance roundrobin
    server  app1 127.0.0.1:8083 check




backend tomcat_app                          #配置后台应用 tomcat_app
    balance roundrobin    #负载均衡方式,使用随机
    server app1 127.0.0.1:8081 check     #服务器1
    server app2 127.0.0.1:8082 check     #服务器2

  

backend app
    balance     roundrobin
    server  app1 127.0.0.1:8081 check
    server  app2 127.0.0.1:8082 check
    server  app3 127.0.0.1:8083 check

复制代码


马哥教育
配置文件的配置段有5个
global:两类参数 1进程管理和安全相关参数   2性能调整相关参数  只能出现一次
defaults   只能出现一次   为其他段提供默认参数
listen       可以出现多次  通过关联前端和后端定义了一个完整的代理,通常只对TCP流量有用,如果有listen可以不用frontend和backend
frontend   可以出现多次  定义一系列监听套接字,这些套接字可接受客户端请求并与之建立连接,可以添加ACL
backend    可以出现多次  定义一系列后端服务器,代理将对应客户端的请求转发到这些服务器
可以只用global,defaults,frontend,backend
可以只用global,defaults,listen
简单例子

global
    daemon
    maxconn 4000
defaults
    mode http
    timeout connect 5000ms
    timeout client  50000ms
    timeout server  50000ms
fronend httpin
    bind *:80      #绑定在所有网卡接口的80端口
    default_backend servers   #默认后端是servers
backend servers
    server  server1 127.0.0.1:8080  maxconn 40

global

日志配置:
日志的level: local0~local7 16~23保留为本地使用
emerg 0 系统不可用
alert 1 必须马上采取行动的事件
crit 2 关键的事件
err 3 错误事件
warning 4 警告事件
notice 5 普通但重要的事件
info 6 有用的信息
debug 7 调试信息
spread-checks <0..50 in percent>  后端realserver太多,比如200台,将检测后端是否宕机的检测报文分成xx段发送以免造成haproxy和realserver之间的链路堵塞
spread-checks  25  将检测报文分成4份发送,减轻链路堵塞

 

关键字

balance <算法> <参数>

balance     roundrobin

balance关键字只能出现在defaults、backend、listen段中

roundrobin:在运行时可以调整权重

static-rr(static-roundrobin):跟roundrobin一样,只是在运行时不可以调整权重

leastconn:在运行时可以调整权重,特别适合sql、ldap等长链接

source:类似nginx的ip_hash,但是增加后端服务器或某个服务器宕机会导致转发到别的机器,可以用hash-type调整权重

uri:对uri进行hash,但是增加后端服务器或某个服务器宕机会导致转发到别的机器,仅使用于http协议

url_param

hdr(header)

rdp-cookie:rdp协议进行转发

关键字

bind<address> :<port_range> <interface>

listen test1

bind *:12345

bind关键字只能出现在fronend、listen段中

<address>:可以为主机名,ipv4地址,ipv6地址,省略不写则为0.0.0.0,监听所有ipv4地址

<port_range>:可以是一个端口也可以是端口范围(5000-5009),<address> :<port_range>每组端口在同一个实例上只能使用一次,小于1024的端口需要把haproxy使用root用户运行才能使用

<interface>:只能使用物理接口名称

关键字

mode{tcp|http|health}

设定实例的运行模式或协议,当实现内容交换时,前端和后端必须工作于同一种模式,否则无法启动实例

tcp:不会对7层报文做任何检查,默认为tcp模式,适用于ssl,ssh,smtp

http:对报文进行深度分析

health:对入站请求仅回应OK并关闭连接,这个模式已经废弃

关键字

hash-type

hash-type <method>

定义用于将hash码映射到后端服务器的方法,不用用于fronend段

方法有map-based和consistent,推荐使用默认的map-base

map-based:改权重需要重启服务器,简单取模

consistent:改权重不需要重启服务器,一致性哈希

关键字

log

log <address> <facility> <level>

启用事件和流量日志,可用于所有段,每个实例最多可以定义两个log参数,最好在global段指定

<address>格式为<ipv4_address:port>,port为udp端口514,也可以用unix socket文件路径,注意chroot和读写权限

关键字

maxconn

不用用在backend段中,默认值为2000

最大值不能超过global段中的定义,最好只在global段中定义

关键字

default_backend <backend>

不能使用在backend段

没有指定use_backend时,使用default_backend

使用案例,动静分离:
use_backend    dynamic    if  url_dyn
use_backend     static     if  url_css   url_img   extension_img
default_backend      dynamic  

关键字

server

server  <name>  <address>:[port]  [param]

后端声明server,不能用在defaults和frontend段

name:为此服务器定义内部名称,出现在日志和警告信息中

address:ipv4地址,也可以用主机名,但是最好用ip地址

port:发往此服务器的目标端口,省略时使用客户端请求时的同一端口

param:参数非常多,包括默认服务器参数和服务器参数

参数列表

backup:备用服务器,在负载均衡中其他服务器均不可用时启用此服务器

check:健康检查,如果要更多的检查功能,需要使用option

  inter<delay> 健康检查时间间隔,单位毫秒,默认为2000毫秒,也可以使用fastinter和downinter来根据服务器状态优化此时间延迟

  rise<count>健康检查中,某离线服务器从离线状态转换到正常状态需要成功检查的次数

  fall<count>确认服务器从正常状态转换为不可用状态需要检查的次数

cookie:指定server设定cookie值,指定的值将在请求入站时被检查,第一次为此值挑选的server将在后续请求中被选中,目的在于实现持久连接功能,http协议才有用
maxqueue:设定请求队列的最大长度
observe<mode>:通过观察服务器通信状况来判定其健康状态,默认为禁用,其支持类型有layer4和layer7
redir<prefix>:启用重定向功能,将发往此服务器的get和head请求以302状态码返回,注意http死循环
weight<weight>:权重,默认为1,最大值为256,0表示不参与负载均衡
检查方法
option httpchk <method> <uri> <version> 不能用于frontend段
backend https_relay
mode tcp
option httpchk options  * http/1.1\r\nhost:\www
server apache1 192.168.1.1:443  check port 80

关键字

stats enable
不能用于frontend段,默认配置如下
stats uri :/haproxy?stats
stats realm:”HAProxy Statistics”
stats auth:no authentication
stats scope:  no restriction

配置案例

backend public_www
    server websrv 192.168.16.100:80
    stats enable
    stats hide-version
    stats scope  .
    stats uri   /haproxyadmin?stats
    stats realm  HAProxy\ Statistics
    stats auth   admin:admin#访问统计信息就使用admin用户和密码admin

另一个案例

listen admin_stats 
        bind 0.0.0.0:8888 #监听端口 
        option httplog #采用http日志格式 
        stats refresh 30s #统计页面自动刷新时间 
        stats uri /stats #统计页面url 
        stats realm Haproxy Manager #统计页面密码框上提示文本 
        stats auth admin:admin #统计页面用户名和密码设置

 

关键字

stats admin
启用统计报告页面的管理功能,通过web接口启用或禁用服务器,不过基于安全考虑,统计报告也应该尽可能为只读,如果haproxy使用了多进程模式,此功能将有可能导致异常
案例一 限制了仅能在本机打开报告页面并启用管理功能
backend stats localhost
    stats enable
    stats admin if LOCALHOST
案例二 仅允许通过认证的用户使用管理功能
backend stats localhost
    stats enable
    stats auth  admin:admin
    stats admin if TRUE

关键字

option forwardfor [except <network>] [header name] [if-none]
发往real server首部插入X-forwardfor首部
haproxy工作在反向代理模式,跟nginx一样,发往real server都是haproxy所在机器地址
haproxy工作在隧道模式,仅检查每一个连接的第一个请求,因此仅第一个请求报文被附加首部
例子
frontend www
    mode http
    option forwardfor except 127.0.0.1

haproxy上面的套接字两个,缓存区四个


监控haproxy

HAProxy监控提供
HTTP页面状态
Unix Socket可以显示HAProxy的状态信息
CSV格式导出

http://10.70.10.209:2080/haproxyadminstats;csv

# pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime,
stats,FRONTEND,,,1,3,6000,29,6190,220600,0,0,13,,,,,OPEN,,,,,,,,,1,2,0,,,,0,1,0,2,,,,0,13,0,15,0,0,,1,2,29,,,0,0,0,0,,,,,,,,
stats,BACKEND,0,0,0,0,600,0,6190,220600,0,0,,0,0,0,0,UP,0,0,0,,0,735,0,,1,2,0,,0,,1,0,,0,,,,0,0,0,0,0,0,,,,,0,0,0,0,0,0,0,,,0,0,0,1,
mssql,FRONTEND,,,19,30,6000,157,626890,2314758,0,0,0,,,,,OPEN,,,,,,,,,1,3,0,,,,0,0,0,3,,,,,,,,,,,0,0,0,,,0,0,0,0,,,,,,,,
mssql,mssqldb1,0,0,16,27,6000,134,509849,2007919,,0,,0,0,0,0,UP,10,1,0,0,0,735,0,,1,3,1,,134,,2,0,,2,L4OK,,0,,,,,,,0,,,,117,0,,,,,19,,,0,0,0,15048,
mssql,mssqldb2,0,0,3,3,6000,23,117041,306839,,0,,0,0,0,0,UP,1,1,0,0,0,735,0,,1,3,2,,23,,2,0,,2,L4OK,,0,,,,,,,0,,,,20,0,,,,,28,,,0,0,0,2625,
mssql,BACKEND,0,0,19,30,600,157,626890,2314758,0,0,,0,0,0,0,UP,11,2,0,,0,735,0,,1,3,0,,157,,1,0,,3,,,,,,,,,,,,,,137,0,0,0,0,0,19,,,0,0,0,936,

zabbix监控haproxy

http://blog.csdn.net/skykingf/article/details/41010263
http://fengwan.blog.51cto.com/508652/1713806/
http://john88wang.blog.51cto.com/2165294/1568541/

http://blog.csdn.net/cybertan/article/details/8114683

https://ywwd.net/read-876
https://ywwd.net/read-877
https://ywwd.net/read-879

2. 查找global 关键字,并添加以下内容.
复制代码
#haproxy stat socket
stats socket /var/run/haproxy.sock mode 666 level admin
stats timeout 2m
level后面可以跟级别user,operator,admin
user是最低权限级别,只能看到一些非敏感信息
operator可以看到全部信息,但是只能修改一些非敏感信息
admin可以看到并且操作所有信息,需要慎用


haproxy安装配置

#yum安装,版本是1.5

yum install -y haproxy.x86_64

#编辑rsyslog 文件,修改为-c 2 -r

vi /etc/sysconfig/rsyslog

SYSLOGD_OPTIONS="-c 2 -m 0 -r -x"

#编辑rsyslog.conf 文件添加一行local2.*

vi /etc/rsyslog.conf

local7.* /var/log/boot.log

local3.* /var/log/haproxy.log

local0.* /var/log/haproxy.log

#重启rsyslog服务

service rsyslog restart

# 编辑haproxy配置文件 下面以mysql从库负载均衡为例

vi /etc/haproxy/haproxy.cfg

global

log 127.0.0.1 local2

chroot /var/lib/haproxy

pidfile /var/run/haproxy.pid

maxconn 6000

user haproxy

group haproxy

daemon

#stats socket /var/lib/haproxy/stats

stats socket /var/run/haproxy.sock mode 666 level admin

stats timeout 2m

defaults

mode http

log 127.0.0.1:514 local3

option dontlognull

#option http-server-close

#option forwardfor except 127.0.0.0/8

option redispatch

retries 3

timeout http-request 10s

timeout queue 1m

timeout connect 10s

timeout client 1m

timeout server 1m

timeout http-keep-alive 10s

timeout check 10s

maxconn 6000

listen stats #定义后台管理页面

mode http

bind *:2080

stats enable

stats refresh 30s

stats uri /haproxyadminstats

stats realm HAProxy\ Statistics

stats auth admin:admin

stats admin if TRUE

frontend mysql

bind *:3306

mode tcp

default_backend mysqlservers

backend mysqlservers

balance roundrobin

server dbsrv1 192.168.1.101:3306 weight 1 maxconn 6000 check port 3306 inter 2000 rise 2 fall 2

server dbsrv2 192.168.1.102:3306 weight 1 maxconn 6000 backup check port 3306 inter 2000 rise 2 fall 2

#检查配置文件是否有语法错误

haproxy -f /etc/haproxy/haproxy.cfg -c

Configuration file is valid

#启动haproxy

/etc/init.d/haproxy start

#检查haproxy是否在监听

netstat -lntp

#打开后台管理界面

http://10.11.30.47:2080/haproxyadminstats

#查看haproxy的日志

cat /var/log/haproxy.log


统计值问题

stats你是访问haproxy状态页面(也就是你截图中的这个)的次数,一共访问了25次

mssql那里才是应用程序访问你的haproxy程序的统计次数,一共访问了1028次

下面mssql那里的total值是累计值(总的session数)而不是实时峰值

session rate是实时峰值


监控使用unix socket监控步骤

1.安装socat工具
yum install -y epel-release
yum install -y socat
说明:
socat是一个netcat(nc)的替代产品,可以称得上是nc++,名字来由是” Socket CAT”,
socat的特点就是在两个流之间建立一个双向通道,socat支持的类型很多,有ip,tcp,udp,ipv6,pipe,exec,system,open,proxy,openssl等
c:\>socat – tcp:192.168.1.18:80
这个命令等同于nc 192.168.1.18 80。socat里面,必须有两个流,所以第一个参数- 代表标准输入输出,第二个流连接到192.168.1.18的80端口
在一个NAT环境,如何从外部连接到内部的一个端口呢?只要能够在内部运行socat就可以了
外部:
c:\>socat tcp-listen:1234 tcp-listen:3389
内部:
c:\>socat tcp:outerhost:1234 tcp:192.168.12.34:3389
这样,外部机器上的3389就映射在内网的192.168.12.34的3389端口上
2.配置haproxy.cfg文件,加入设置状态
配置haproxy的socket,查找global 关键字,并添加以下内容.
vim /etc/haproxy/haproxy.cfg
global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     6000
    user        haproxy
    group       haproxy
    daemon
    #注释掉stats socket /var/lib/haproxy/stats
    #stats socket /var/lib/haproxy/stats    
    stats socket /var/run/haproxy.sock mode 666 level admin
    stats timeout 2m
#验证配置文件
haproxy -c -f /etc/haproxy/haproxy.cfg
重启haproxy
/etc/init.d/haproxy restart
sock 文件
ll /var/run/haproxy.sock
srw-rw-rw- 1 root root 0 Sep 27 14:29 /var/run/haproxy.sock
3.校验
# echo “show help”|socat stdio unix-connect://var/run/haproxy.sock
Unknown command. Please enter one of the following commands only :
  clear counters : clear max statistics counters (add ‘all’ for all counters)
  clear table    : remove an entry from a table
  help           : this message
  prompt         : toggle interactive mode with prompt
  quit           : disconnect
  show info      : report information about the running process
  show pools     : report information about the memory pools usage
  show stat      : report counters for each proxy and server
  show errors    : report last request and response errors for each proxy
  show sess [id] : report the list of current sessions or dump this session
  show table [id]: report table usage stats or dump this table’s contents
  get weight     : report a server’s current weight
  set weight     : change a server’s weight
  set server     : change a server’s state or weight
  set table [id] : update or create a table entry’s data
  set timeout    : change a timeout setting
  set maxconn    : change a maxconn setting
  set rate-limit : change a rate limiting value
  disable        : put a server or frontend in maintenance mode
  enable         : re-enable a server or frontend which is in maintenance mode
  shutdown       : kill a session or a frontend (eg:to release listening ports)
  show acl [id]  : report avalaible acls or dump an acl’s contents
  get acl        : reports the patterns matching a sample for an ACL
  add acl        : add acl entry
  del acl        : delete acl entry
  clear acl <id> : clear the content of this acl
  show map [id]  : report avalaible maps or dump a map’s contents
  get map        : reports the keys and values matching a sample for a map
  set map        : modify map entry
  add map        : add map entry
  del map        : delete map entry
  clear map <id> : clear the content of this map
  set ssl <stmt> : set statement for ssl
4.对当前的haproxy进程信息打印报告

# echo "show info"|socat stdio unix-connect://var/run/haproxy.sock
Name: HAProxy
Version: 1.5.4
Release_date: 2014/09/02
Nbproc: 1
Process_num: 1
Pid: 40343
Uptime: 0d 0h00m49s
Uptime_sec: 49
Memmax_MB: 0
Ulimit-n: 12034
Maxsock: 12034
Maxconn: 6000
Hard_maxconn: 6000
CurrConns: 0
CumConns: 2
CumReq: 2
MaxSslConns: 0
CurrSslConns: 0
CumSslConns: 0
Maxpipes: 0
PipesUsed: 0
PipesFree: 0
ConnRate: 0
ConnRateLimit: 0
MaxConnRate: 0
SessRate: 0
SessRateLimit: 0
MaxSessRate: 0
SslRate: 0
SslRateLimit: 0
MaxSslRate: 0
SslFrontendKeyRate: 0
SslFrontendMaxKeyRate: 0
SslFrontendSessionReuse_pct: 0
SslBackendKeyRate: 0
SslBackendMaxKeyRate: 0
SslCacheLookups: 0
SslCacheMisses: 0
CompressBpsIn: 0
CompressBpsOut: 0
CompressBpsRateLim: 0
ZlibMemUsage: 0
MaxZlibMemUsage: 0
Tasks: 7
Run_queue: 1
Idle_pct: 100
node: WHC-Linux02
description:

5.对当前的haproxy各个指标打印报告

# echo "show stat"|socat stdio unix-connect://var/run/haproxy.sock
#pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime,
stats,FRONTEND,,,0,0,6000,0,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,0,,,,0,0,0,0,0,0,,0,0,0,,,0,0,0,0,,,,,,,,
stats,BACKEND,0,0,0,0,600,0,0,0,0,0,,0,0,0,0,UP,0,0,0,,0,145,0,,1,2,0,,0,,1,0,,0,,,,0,0,0,0,0,0,,,,,0,0,0,0,0,0,-1,,,0,0,0,0,
mssql,FRONTEND,,,0,0,6000,0,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,3,0,,,,0,0,0,0,,,,,,,,,,,0,0,0,,,0,0,0,0,,,,,,,,
mssql,mssqldb1,0,0,0,0,6000,0,0,0,,0,,0,0,0,0,UP,10,1,0,0,0,145,0,,1,3,1,,0,,2,0,,0,L4OK,,0,,,,,,,0,,,,0,0,,,,,-1,,,0,0,0,0,
mssql,mssqldb2,0,0,0,0,6000,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,145,0,,1,3,2,,0,,2,0,,0,L4OK,,0,,,,,,,0,,,,0,0,,,,,-1,,,0,0,0,0,
mssql,BACKEND,0,0,0,0,600,0,0,0,0,0,,0,0,0,0,UP,11,2,0,,0,145,0,,1,3,0,,0,,1,0,,0,,,,,,,,,,,,,,0,0,0,0,0,0,-1,,,0,0,0,0,

6.对5节点参数的理解

0. pxname: proxy name                      
  1. svname: service name (FRONTEND for frontend, BACKEND for backend, any name
    for server)
  2. qcur: current queued requests
  3. qmax: max queued requests
  4. scur: current sessions
  5. smax: max sessions
  6. slim: sessions limit
  7. stot: total sessions
  8. bin: bytes in
  9. bout: bytes out
 10. dreq: denied requests
 11. dresp: denied responses
 12. ereq: request errors
 13. econ: connection errors
 14. eresp: response errors (among which srv_abrt)
 15. wretr: retries (warning)
 16. wredis: redispatches (warning)
 17. status: status (UP/DOWN/NOLB/MAINT/MAINT(via)...)
 18. weight: server weight (server), total weight (backend)
 19. act: server is active (server), number of active servers (backend)
 20. bck: server is backup (server), number of backup servers (backend)
 21. chkfail: number of failed checks
 22. chkdown: number of UP->DOWN transitions
 23. lastchg: last status change (in seconds)
 24. downtime: total downtime (in seconds)
 25. qlimit: queue limit
 26. pid: process id (0 for first instance, 1 for second, ...)
 27. iid: unique proxy id
 28. sid: service id (unique inside a proxy)
 29. throttle: warm up status
 30. lbtot: total number of times a server was selected
 31. tracked: id of proxy/server if tracking is enabled
 32. type (0=frontend, 1=backend, 2=server, 3=socket)
 33. rate: number of sessions per second over last elapsed second
 34. rate_lim: limit on new sessions per second
 35. rate_max: max number of new sessions per second
 36. check_status: status of last health check, one of:
        UNK     -> unknown
        INI     -> initializing
        SOCKERR -> socket error
        L4OK    -> check passed on layer 4, no upper layers testing enabled
        L4TMOUT -> layer 1-4 timeout
        L4CON   -> layer 1-4 connection problem, for example
                   "Connection refused" (tcp rst) or "No route to host" (icmp)
        L6OK    -> check passed on layer 6
        L6TOUT  -> layer 6 (SSL) timeout
        L6RSP   -> layer 6 invalid response - protocol error
        L7OK    -> check passed on layer 7
        L7OKC   -> check conditionally passed on layer 7, for example 404 with
                   disable-on-404
        L7TOUT  -> layer 7 (HTTP/SMTP) timeout
        L7RSP   -> layer 7 invalid response - protocol error
        L7STS   -> layer 7 response error, for example HTTP 5xx
 37. check_code: layer5-7 code, if available
 38. check_duration: time in ms took to finish last health check
 39. hrsp_1xx: http responses with 1xx code
 40. hrsp_2xx: http responses with 2xx code
 41. hrsp_3xx: http responses with 3xx code
 42. hrsp_4xx: http responses with 4xx code
 43. hrsp_5xx: http responses with 5xx code
 44. hrsp_other: http responses with other codes (protocol error)
 45. hanafail: failed health checks details
 46. req_rate: HTTP requests per second over last elapsed second
 47. req_rate_max: max number of HTTP requests per second observed
 48. req_tot: total number of HTTP requests received
 49. cli_abrt: number of data transfers aborted by the client
 50. srv_abrt: number of data transfers aborted by the server (inc. in eresp)

7.监控脚本编写
haproxy_info.sh                 
    用于收集HAProxy的基本信息
haproxy_pool_discovery.py       
    用于zabbix通过LLD功能发现各个pool对,如login_pool:BACKEND,login_pool:web1_80等,通过低级发现可以动态的根据配置文件中配置的后端主机监控各个后端主机的状态
haproxy_stat.sh               
    通过向stat socket发送show stat命令收集各个状态的值,脚本中会根据,进行判断第二个字段的值,因为有些字段是只有FRONTEND或BACKEND才会有,或者除了FRONTEND和BACKEND,其他都有等
8.对应的脚本代码

vi  /data/script/haproxy_info.sh
#!/bin/bash
#This script is used for getting haproxy info such as version ,uptime and number of processes etc
metric=$1
stats_socket=/var/run/haproxy.sock
info_file=/tmp/haproxy_info.csv
echo "show info"|/usr/bin/socat   unix-connect:$stats_socket  stdio > $info_file
grep $metric $info_file|awk '{print $2}'

####################################################

vi  /data/script/haproxy_pool_discovery.py
#/usr/bin/python
#This script is used to discovery disk on the server
import subprocess
import json
args='''echo "show stat"|/usr/bin/socat stdio unix-connect:/var/run/haproxy.sock|egrep -v '^#|^$'|awk -F',' '{print $1":"$2}' '''
t=subprocess.Popen(args,shell=True,stdout=subprocess.PIPE).communicate()[0]
pools=[]
for pool in t.split('\n'):
    if len(pool) != 0:
       pools.append({'{#POOL_NAME}':pool})
print json.dumps({'data':pools},indent=4,separators=(',',':'))

################################################

vi  /data/script/haproxy_stat.sh
#!/bin/bash
# login_game_pool:FRONTEND
pool_name=$(echo $1|awk -F':' '{print $1}')
server_name=$(echo $1|awk -F':' '{print $2}')
metric=$2
stat_socket=/var/run/haproxy.sock
stat_file=/tmp/haproxy_stat.csv
echo "show stat"|/usr/bin/socat stdio unix-connect:$stat_socket > $stat_file
case $metric in
          qcur)
              #current queued requests
              if [ "$server_name" != "FRONTEND" ];then
                  awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $3}' $stat_file
              else
                  echo 0
              fi
             ;;
          qmax)
              #max queued requests
              if [ "$server_name" != "FRONTEND" ];then
                  awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $4}' $stat_file
              else
                  echo 0
              fi
             ;;
          scur)
              #current sessions
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $5}' $stat_file
             ;;
          smax)
              #max sessions
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $6}' $stat_file
             ;;
          slim)
              #sessions limit
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $7}' $stat_file
             ;;
          stol)
              #total sessions
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $8}' $stat_file
             ;;
           bin)
              #bytes in
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $9}' $stat_file
             ;;
          bout)
              #bytes out
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $10}' $stat_file
             ;;
          dreq)
              #denied requests
              #only FRONTEND and BACKEND has this field
              if [ "$server_name" == "FRONTEND" -o "$server_name" == "BACKEND" ];then
                  awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $11}' $stat_file
              else
                 echo 0
              fi
             ;;
         dresp)
              #denied responses
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $12}' $stat_file
             ;;
          ereq)
              #request errors
              #only FRONTEND has this field
              if [ "$server_name" == "FRONTEND" ];then
                 awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $13}' $stat_file
              else
                 echo 0
              fi
             ;;
          econ)
              #connection errors
              #FRONTEND has not this field
              if [ "$server_name" != "FRONTEND" ];then
                 awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $14}' $stat_file
              else
                 echo 0
              fi
             ;;
         eresp)
              #response errors
              #FRONTEND has not this field
              if [ "$server_name" != "FRONTEND" ];then
                 awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $15}' $stat_file
              else
                 echo 0
              fi
             ;;
        status)
              #status
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $18}' $stat_file
              ;;
       chkfail)
              #number of failed checks
              #FRONTEND and BACKEND has not this field
              if [ "$server_name" == "FRONTEND" -o "$server_name" == "BACKEND" ];then
                 echo 0
              else
                 awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $22}' $stat_file
              fi
              ;;
       chkdown)
              #number of UP->DOWN transitions
              #FRONTEND has not this field will return 0
              if [ "$server_name" != "FRONTEND" ];then
                  awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $23}' $stat_file
              else
                 echo 0
              fi
              ;;
       lastchg)
              #last status change in seconds
              #FRONTEND has not this field will return 0
              if [ "$server_name" != "FRONTEND" ];then
                  awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $24}' $stat_file
              else
                 echo 0
              fi
              ;;
      downtime)
              #total downtime in seconds
              #FRONTEND has not this field will return 0
              if [ "$server_name" != "FRONTEND" ];then
                  awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $25}' $stat_file
              else
                 echo 0
              fi
              ;;
         lbtot)
              #total number of times a server was selected
              #FRONTEND has not this field
              if [ "$server_name" != "FRONTEND" ];then
                  awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $31}' $stat_file
              else
                 echo 0
              fi
              ;;
          rate)
              #number of sessions per second over last elapsed second
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $34}' $stat_file
              ;;
    rate_limit)
              #limit on new sessions per second
              #only FRONTEND has this field
              if [ "$server_name" == "FRONTEND" ];then
                  awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $35}' $stat_file
              else
                  echo 0
              fi
              ;;
      rate_max)
              #max number of new sessions per second
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $36}' $stat_file
              ;;
  check_status)
              #status of last health check  
              if [ "$server_name" == "FRONTEND" -o "$server_name" == "BACKEND" ];then
                 echo "NULL"
              else
                  awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $37}' $stat_file
              fi
              ;;
      hrsp_1xx)
              #http response with 1xx code
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $40}' $stat_file
              ;;
      hrsp_2xx)
              #http response with 2xx code
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $41}' $stat_file
              ;;
      hrsp_3xx)
              #http response with 3xx code
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $42}' $stat_file
              ;;
      hrsp_4xx)
              #http response with 4xx code
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $43}' $stat_file
              ;;
      hrsp_5xx)
              #http response with 5xx code
              awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $44}' $stat_file
              ;;
      req_rate)
              #HTTP requests per second over last elapsed second
              #only FRONTEND has this field,others will return 0
              if [ "$server_name" == "FRONTEND" ];then
                 awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $47}' $stat_file
              else
                 echo 0
              fi
              ;;
  req_rate_max)
              #max number of HTTP requests per second observed
              #only FRONTEND has this field,others will return 0
              if [ "$server_name" == "FRONTEND" ];then
                  awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $48}' $stat_file
              else
                  echo 0
              fi
              ;;
       req_tot)
              #total number of HTTP requests recevied
              #only FRONTEND has this field,others will return 0
              if [ "$server_name" == "FRONTEND" ];then
                  awk -F"," '$1=="'$pool_name'"&&$2=="'$server_name'"{print $49}' $stat_file
              else
                  echo 0
              fi
              ;;
             *)
               echo "please input the correct argument"
              ;;
esac

9.赋予执行权限
# pwd
/data/script
# chmod +x  haproxy_*  ;chown zabbix:zabbix   haproxy_*
[root@WHC-Linux02 script]# ll
总用量 20
-rwxr-xr-x 1 root root  325 9月  28 10:48 haproxy_info.sh
-rwxr-xr-x 1 root root  469 9月  28 10:49 haproxy_pool_discovery.py
-rwxr-xr-x 1 root root 8116 9月  28 10:49 haproxy_stat.sh
-rw-r–r– 1 root root  720 9月   5 12:39 iptables.sh
10.添加到zabbix_agentd.conf中,在客户端

vi /etc/zabbix/zabbix_agentd.conf
UnsafeUserParameters=1
UserParameter=haproxy.info[*],/data/script/haproxy_info.sh $1
UserParameter=haproxy.discovery,/usr/bin/python /data/script/haproxy_pool_discovery.py
UserParameter=haproxy.stat[*],/data/script/haproxy_stat.sh $1 $2

重启服务
/etc/init.d/zabbix-agent restart
11 添加下载的模板-导入
haproxy.xml

<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
    <version>2.0</version>
    <date>2014-11-01T14:03:22Z</date>
    <groups>
        <group>
            <name>Templates</name>
        </group>
    </groups>
    <templates>
        <template>
            <template>Template HAProxy Status</template>
            <name>Template HAProxy Status</name>
            <groups>
                <group>
                    <name>Templates</name>
                </group>
            </groups>
            <applications>
                <application>
                    <name>HAProxy Info</name>
                </application>
                <application>
                    <name>HAProxy Networks</name>
                </application>
                <application>
                    <name>HAProxy Other</name>
                </application>
                <application>
                    <name>HAProxy Requests</name>
                </application>
                <application>
                    <name>HAProxy Responses</name>
                </application>
                <application>
                    <name>HAProxy Sessions</name>
                </application>
                <application>
                    <name>HAProxy Status</name>
                </application>
            </applications>
            <items>
                <item>
                    <name>Current connections</name>
                    <type>7</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>haproxy.info[CurrConns]</key>
                    <delay>60</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>HAProxy Info</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>HAProxy Process Status</name>
                    <type>7</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>proc.num[haproxy]</key>
                    <delay>30</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>HAProxy Status</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>HAProxy Version</name>
                    <type>7</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>haproxy.info[Version]</key>
                    <delay>3600</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>1</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>HAProxy Info</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Node name</name>
                    <type>7</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>haproxy.info[node]</key>
                    <delay>3600</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>1</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>HAProxy Info</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Number of process</name>
                    <type>7</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>haproxy.info[Nbproc]</key>
                    <delay>60</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>HAProxy Info</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Pipes Free</name>
                    <type>7</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>haproxy.info[PipesFree]</key>
                    <delay>60</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>HAProxy Info</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Pipes Used</name>
                    <type>7</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>haproxy.info[PipesUsed]</key>
                    <delay>60</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>HAProxy Info</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Running queue</name>
                    <type>7</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>haproxy.info[Run_queue]</key>
                    <delay>60</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>HAProxy Info</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Tasks numbers</name>
                    <type>7</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>haproxy.info[Tasks]</key>
                    <delay>60</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units/>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>HAProxy Info</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
                <item>
                    <name>Uptime of HAProxy</name>
                    <type>7</type>
                    <snmp_community/>
                    <multiplier>0</multiplier>
                    <snmp_oid/>
                    <key>haproxy.info[Uptime_sec]</key>
                    <delay>60</delay>
                    <history>90</history>
                    <trends>365</trends>
                    <status>0</status>
                    <value_type>3</value_type>
                    <allowed_hosts/>
                    <units>s</units>
                    <delta>0</delta>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <formula>1</formula>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <data_type>0</data_type>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <description/>
                    <inventory_link>0</inventory_link>
                    <applications>
                        <application>
                            <name>HAProxy Info</name>
                        </application>
                    </applications>
                    <valuemap/>
                </item>
            </items>
            <discovery_rules>
                <discovery_rule>
                    <name>HAProxy pool discovery</name>
                    <type>7</type>
                    <snmp_community/>
                    <snmp_oid/>
                    <key>haproxy.discovery</key>
                    <delay>60</delay>
                    <status>0</status>
                    <allowed_hosts/>
                    <snmpv3_contextname/>
                    <snmpv3_securityname/>
                    <snmpv3_securitylevel>0</snmpv3_securitylevel>
                    <snmpv3_authprotocol>0</snmpv3_authprotocol>
                    <snmpv3_authpassphrase/>
                    <snmpv3_privprotocol>0</snmpv3_privprotocol>
                    <snmpv3_privpassphrase/>
                    <delay_flex/>
                    <params/>
                    <ipmi_sensor/>
                    <authtype>0</authtype>
                    <username/>
                    <password/>
                    <publickey/>
                    <privatekey/>
                    <port/>
                    <filter>{#POOL_NAME}:</filter>
                    <lifetime>30</lifetime>
                    <description/>
                    <item_prototypes>
                        <item_prototype>
                            <name>bytes in per second {#POOL_NAME}</name>
                            <type>7</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>haproxy.stat[{#POOL_NAME},bin]</key>
                            <delay>60</delay>
                            <history>90</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units>Bps</units>
                            <delta>1</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>HAProxy Networks</name>
                                </application>
                            </applications>
                            <valuemap/>
                        </item_prototype>
                        <item_prototype>
                            <name>bytes out per second {#POOL_NAME}</name>
                            <type>7</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>haproxy.stat[{#POOL_NAME},bout]</key>
                            <delay>60</delay>
                            <history>90</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units>Bps</units>
                            <delta>1</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>HAProxy Networks</name>
                                </application>
                            </applications>
                            <valuemap/>
                        </item_prototype>
                        <item_prototype>
                            <name>connection errors  {#POOL_NAME}</name>
                            <type>7</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>haproxy.stat[{#POOL_NAME},econ]</key>
                            <delay>60</delay>
                            <history>90</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>HAProxy Other</name>
                                </application>
                            </applications>
                            <valuemap/>
                        </item_prototype>
                        <item_prototype>
                            <name>current queued requests  {#POOL_NAME}</name>
                            <type>7</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>haproxy.stat[{#POOL_NAME},qcur]</key>
                            <delay>60</delay>
                            <history>90</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>HAProxy Requests</name>
                                </application>
                            </applications>
                            <valuemap/>
                        </item_prototype>
                        <item_prototype>
                            <name>current sessions {#POOL_NAME}</name>
                            <type>7</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>haproxy.stat[{#POOL_NAME},scur]</key>
                            <delay>60</delay>
                            <history>90</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>0</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>HAProxy Sessions</name>
                                </application>
                            </applications>
                            <valuemap/>
                        </item_prototype>
                        <item_prototype>
                            <name>denied requests  per second  {#POOL_NAME}</name>
                            <type>7</type>
                            <snmp_community/>
                            <multiplier>0</multiplier>
                            <snmp_oid/>
                            <key>haproxy.stat[{#POOL_NAME},dreq]</key>
                            <delay>60</delay>
                            <history>90</history>
                            <trends>365</trends>
                            <status>0</status>
                            <value_type>3</value_type>
                            <allowed_hosts/>
                            <units/>
                            <delta>1</delta>
                            <snmpv3_contextname/>
                            <snmpv3_securityname/>
                            <snmpv3_securitylevel>0</snmpv3_securitylevel>
                            <snmpv3_authprotocol>0</snmpv3_authprotocol>
                            <snmpv3_authpassphrase/>
                            <snmpv3_privprotocol>0</snmpv3_privprotocol>
                            <snmpv3_privpassphrase/>
                            <formula>1</formula>
                            <delay_flex/>
                            <params/>
                            <ipmi_sensor/>
                            <data_type>0</data_type>
                            <authtype>0</authtype>
                            <username/>
                            <password/>
                            <publickey/>
                            <privatekey/>
                            <port/>
                            <description/>
                            <inventory_link>0</inventory_link>
                            <applications>
                                <application>
                                    <name>HAProxy Requests</name>
                                </application>
                            </applications>
                            <valuemap/>

导入


关联

打开图表

赞(0) 打赏
蜷缩的蜗牛 , 版权所有丨如未注明 , 均为原创丨 转载请注明蜷缩的蜗牛 » 【转载】ZABBIX监控HaProxy
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!

 

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏