Page MenuHomeVyOS Platform

Add op-mode for load-balancing reverse-proxy
Closed, ResolvedPublicFEATURE REQUEST

Description

We can get valuable data for op-mode via socket
Use echo help to get all available options

https://www.haproxy.com/documentation/hapee/latest/api/runtime-api/show-stat/
https://cbonte.github.io/haproxy-dconv/2.6/management.html#9.1

vyos@r14# echo "show " | sudo socat stdio unix-connect:/var/run/haproxy/admin.sock
Unknown command, but maybe one of the following ones is a better match:
  show acl [@<ver>] <acl>]                : report available acls or dump an acl's contents
  show activity                           : show per-thread activity stats (for support/developers)
  show backend                            : list backends in the current running config
  show cache                              : show cache status
  show cli level                          : display the level of the current CLI session
  show cli sockets                        : dump list of cli sockets
  show env [var]                          : dump environment variables known to the process
  show errors [<px>] [request|response]   : report last request and/or response errors for each proxy
  show events [<sink>] [-w] [-n]          : show event sink state
  show fd [num]                           : dump list of file descriptors in use or a specific one
  show info [desc|json|typed|float]*      : report information about the running process
  show libs                               : show loaded object files and libraries
  show map [@ver] [map]                   : report available maps or dump a map's contents
  show peers [dict|-] [section]           : dump some information about all the peers or this peers section
  show pools                              : report information about the memory pools usage
  show profiling [<what>|<#lines>|byaddr]*: show profiling state (all,status,tasks,memory)
  show resolvers [id]                     : dumps counters from all resolvers section and associated name servers
  show schema json                        : report schema used for stats
  show servers conn [<backend>]           : dump server connections status (all or for a single backend)
  show servers state [<backend>]          : dump volatile server information (all or for a single backend)
  show sess [id]                          : report the list of current sessions or dump this exact session
  show ssl ca-file [<cafile>[:<index>]]   : display the SSL CA files used in memory, or the details of a <cafile>, or a single certificate of index <index> of a CA file <cafile>
  show ssl cert [<certfile>]              : display the SSL certificates used in memory, or the details of a file
  show ssl crl-file [<crlfile[:<index>>]] : display the SSL CRL files used in memory, or the details of a <crlfile>, or a single CRL of index <index> of CRL file <crlfile>
  show ssl crt-list [-n] [<list>]         : show the list of crt-lists or the content of a crt-list file <list>
  show ssl ocsp-response [id]             : display the IDs of the OCSP responses used in memory, or the details of a single OCSP response
  show ssl providers                      : show loaded SSL providers
  show startup-logs                       : report logs emitted during HAProxy startup
  show stat [desc|json|no-maint|typed|up]*: report counters for each proxy and server
  show table <table> [<filter>]*          : report table usage stats or dump this table's contents (filter: data/key)
  show tasks                              : show running tasks
  show threads                            : show some threads debugging information
  show tls-keys [id|*]                    : show tls keys references or dump tls ticket keys when id specified
  show trace [<module>]                   : show live tracing state
  show version                            : show version of the current process
  help [<command>]                        : list matching or all commands
  prompt                                  : toggle interactive mode with prompt
  quit                                    : disconnect

An example:

root@r14:/home/vyos# echo "show stat" | sudo socat stdio unix-connect:/var/run/haproxy/admin.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,agent_status,agent_code,agent_duration,check_desc,agent_desc,check_rise,check_fall,check_health,agent_rise,agent_fall,agent_health,addr,cookie,mode,algo,conn_rate,conn_rate_max,conn_tot,intercepted,dcon,dses,wrew,connect,reuse,cache_lookups,cache_hits,srv_icur,src_ilim,qtime_max,ctime_max,rtime_max,ttime_max,eint,idle_conn_cur,safe_conn_cur,used_conn_cur,need_conn_est,uweight,agg_server_status,agg_server_check_status,agg_check_status,-,ssl_sess,ssl_reused_sess,ssl_failed_handshake,h2_headers_rcvd,h2_data_rcvd,h2_settings_rcvd,h2_rst_stream_rcvd,h2_goaway_rcvd,h2_detected_conn_protocol_errors,h2_detected_strm_protocol_errors,h2_rst_stream_resp,h2_goaway_resp,h2_open_connections,h2_backend_open_streams,h2_total_connections,h2_backend_total_streams,h1_open_connections,h1_open_streams,h1_total_connections,h1_total_streams,h1_bytes_in,h1_bytes_out,h1_spliced_bytes_in,h1_spliced_bytes_out,
http,FRONTEND,,,0,2,262120,1,310,109,0,0,0,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,1,,,,0,0,1,0,0,0,,0,1,1,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,http,,0,1,1,1,0,0,0,,,0,0,,,,,,,0,,,,,,,,,-,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,343,106,0,0,
https,FRONTEND,,,0,5,262120,2,5342,3218,0,0,0,,,,,OPEN,,,,,,,,,1,3,0,,,,0,0,0,1,,,,,,,,,,,0,3,14,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,tcp,,0,1,3,,0,0,0,,,,,,,,,,,0,,,,,,,,,-,2,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,14,6020,3568,0,0,
bk-01,serv-01,0,0,0,1,,14,5342,3218,,0,,0,0,0,0,no check,1,1,0,,,2204,,,1,4,1,,14,,2,0,,3,,,,0,12,0,2,0,0,,,,14,0,0,,,,,2149,,,0,1,2,1249,,,,,,,,,,,,192.168.122.11:5000,,http,,,,,,,,0,14,0,,,0,,0,1,2,6915,0,0,0,0,1,1,,,,-,0,0,0,,,,,,,,,,,,,,,,,,,,,,
bk-01,BACKEND,0,0,0,1,26212,14,5342,3218,0,0,,0,0,0,0,UP,1,1,0,,0,2204,0,,1,4,0,,14,,1,0,,3,,,,0,12,0,2,0,0,,,,14,0,0,0,0,0,0,2149,,,0,1,2,1249,,,,,,,,,,,,,,http,roundrobin,,,,,,,0,14,0,0,0,,,0,1,2,6915,0,,,,,1,0,0,0,-,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,14,3232,6916,0,0,

root@r14:/home/vyos#

Stat example:

vyos@r14# echo "show stat " | sudo socat stdio unix-connect:/var/run/haproxy/admin.sock | cut -d "," -f 1-2,16,18,43,44,47,61 | column -s, -t
# pxname  svname    wretr  status    hrsp_4xx  hrsp_5xx  req_rate  rtime
http      FRONTEND         OPEN      0         0         0         
https     FRONTEND         OPEN      0         0         0         
bk-01     serv-01   0      no check  0         0                   2
bk-01     BACKEND   0      UP        0         0                   2
[edit]
vyos@r14#

The JSON format supported show stat json

Details

Version
1.4
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Unspecified (please specify)

Event Timeline

Viacheslav renamed this task from Add op-mode for load-belancing reverse-proxy to Add op-mode for load-balancing reverse-proxy.
Viacheslav changed Version from - to 1.4.
Viacheslav updated the task description. (Show Details)

PR https://github.com/vyos/vyos-1x/pull/2015

vyos@r14# run show reverse-proxy 
Proxy name    Role      Status    Req rate    Resp time    Last change
------------  --------  --------  ----------  -----------  -------------
http          FRONTEND  OPEN      0
https         FRONTEND  OPEN      16
stats         FRONTEND  OPEN      0
bk-01         BACKEND   UP                    1 ms         1h34m45s
default-bk    BACKEND   UP                    0 ms         1h34m45s
bk-01         serv-01   UP                    1 ms         1h34m45s
bk-01         serv-02   DOWN                  0 ms         1h34m44s
default-bk    serv-03   no check              0 ms         1h34m45s
[edit]
vyos@r14#
Viacheslav changed the task status from Open to In progress.May 25 2023, 8:36 AM
Viacheslav claimed this task.
Viacheslav moved this task from Open to Finished on the VyOS 1.4 Sagitta board.