Documentation
¶
Overview ¶
Package haproxy provides a minimal client for communicating with, and issuing commands to, HAproxy over a network or file socket.
Index ¶
- func AddServer(h HAProxy, backend string, server string, addr string, port int) (addServerResponse string, err error)
- func DelServer(h HAProxy, backend string, server string) (delServerResponse string, err error)
- func SetServerState(h HAProxy, backend string, server string, serverState ServerState) (setServerStateResonse string, err error)
- type HAProxy
- type HAProxyClient
- type ServerState
- type ShowBackendResponse
- type ShowInfoResponse
- type ShowServersStateResponse
- type ShowStatResponse
- type SrvAdminState
- type SrvAgentState
- type SrvCheckResult
- type SrvCheckState
- type SrvOpState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetServerState ¶
func SetServerState(h HAProxy, backend string, server string, serverState ServerState) (setServerStateResonse string, err error)
Equivalent to HAProxy "set server <backend>/<server> state [ ready | drain | maint ]" command.
Types ¶
type HAProxyClient ¶
HAProxyClient is the main structure of the library.
func (*HAProxyClient) RunCommand ¶
func (h *HAProxyClient) RunCommand(cmd string) (*bytes.Buffer, error)
RunCommand is the entrypoint to the client. Sends an arbitray command string to HAProxy.
type ShowBackendResponse ¶
type ShowBackendResponse struct {
Name string `csv:"# name"`
}
Response from HAProxy "show backend" command.
func ShowBackend ¶
func ShowBackend(h HAProxy) (showBackendResponses []*ShowBackendResponse, err error)
Equivalent to HAProxy "show backend" command.
type ShowInfoResponse ¶
type ShowInfoResponse struct {
Name string `kv:"Name"`
Version string `kv:"Version"`
ReleaseDate string `kv:"Release_date"`
Nbthread uint64 `kv:"Nbthread"`
Nbproc uint64 `kv:"Nbproc"`
ProcessNum uint64 `kv:"Process_num"`
Pid uint64 `kv:"Pid"`
Uptime string `kv:"Uptime"`
UptimeSec uint64 `kv:"Uptime_sec"`
MemMaxMB uint64 `kv:"Memmax_MB"`
PoolAllocMB uint64 `kv:"PoolAlloc_MB"`
PoolUsedMB uint64 `kv:"PoolUsed_MB"`
PoolFailed uint64 `kv:"PoolFailed"`
UlimitN uint64 `kv:"Ulimit-n"`
Maxsock uint64 `kv:"Maxsock"`
Maxconn uint64 `kv:"Maxconn"`
HardMaxconn uint64 `kv:"Hard_maxconn"`
CurrConns uint64 `kv:"CurrConns"`
CumConns uint64 `kv:"CumConns"`
CumReq uint64 `kv:"CumReq"`
MaxSslConns uint64 `kv:"MaxSslConns"`
CurrSslConns uint64 `kv:"CurrSslConns"`
CumSslConns uint64 `kv:"CumSslConns"`
Maxpipes uint64 `kv:"Maxpipes"`
PipesUsed uint64 `kv:"PipesUsed"`
PipesFree uint64 `kv:"PipesFree"`
ConnRate uint64 `kv:"ConnRate"`
ConnRateLimit uint64 `kv:"ConnRateLimit"`
MaxConnRate uint64 `kv:"MaxConnRate"`
SessRate uint64 `kv:"SessRate"`
SessRateLimit uint64 `kv:"SessRateLimit"`
MaxSessRate uint64 `kv:"MaxSessRate"`
SslRate uint64 `kv:"SslRate"`
SslRateLimit uint64 `kv:"SslRateLimit"`
MaxSslRate uint64 `kv:"MaxSslRate"`
SslFrontendKeyRate uint64 `kv:"SslFrontendKeyRate"`
SslFrontendMaxKeyRate uint64 `kv:"SslFrontendMaxKeyRate"`
SslFrontendSessionReusePct uint64 `kv:"SslFrontendSessionReuse_pct"`
SslBackendKeyRate uint64 `kv:"SslBackendKeyRate"`
SslBackendMaxKeyRate uint64 `kv:"SslBackendMaxKeyRate"`
SslCacheLookups uint64 `kv:"SslCacheLookups"`
SslCacheMisses uint64 `kv:"SslCacheMisses"`
CompressBpsIn uint64 `kv:"CompressBpsIn"`
CompressBpsOut uint64 `kv:"CompressBpsOut"`
CompressBpsRateLim uint64 `kv:"CompressBpsRateLim"`
//ZlibMemUsage uint64 `kv:"ZlibMemUsage"`
//MaxZlibMemUsage uint64 `kv:"MaxZlibMemUsage"`
Tasks uint64 `kv:"Tasks"`
RunQueue uint64 `kv:"Run_queue"`
IdlePct uint64 `kv:"Idle_pct"`
Node string `kv:"node"`
Stopping uint64 `kv:"Stopping"`
Jobs uint64 `kv:"Jobs"`
UnstoppableJobs uint64 `kv:"Unstoppable Jobs"`
Listeners uint64 `kv:"Listeners"`
ActivePeers uint64 `kv:"ActivePeers"`
ConnectedPeers uint64 `kv:"ConnectedPeers"`
DroppedLogs uint64 `kv:"DroppedLogs"`
BusyPolling uint64 `kv:"BusyPolling"`
FailedResolutions uint64 `kv:"FailedResolutions"`
TotalBytesOut uint64 `kv:"TotalBytesOut"`
BytesOutRate uint64 `kv:"BytesOutRate"`
DebugCommandsIssued uint64 `kv:"DebugCommandsIssued"`
}
Response from HAProxy "show info" command.
func ShowInfo ¶
func ShowInfo(h HAProxy) (*ShowInfoResponse, error)
Equivalent to HAProxy "show info" command.
type ShowServersStateResponse ¶
type ShowServersStateResponse struct {
BeID uint64 `csv:"be_id"`
BeName string `csv:"be_name"`
SrvID uint64 `csv:"srv_id"`
SrvName string `csv:"srv_name"`
SrvAddr string `csv:"srv_addr"`
SrvOpState SrvOpState `csv:"srv_op_state"`
SrvAdminState SrvAdminState `csv:"srv_admin_state"`
SrvUweight uint64 `csv:"srv_uweight"`
SrvIweight uint64 `csv:"srv_iweight"`
SrvTimeSinceLastChange uint64 `csv:"srv_time_since_last_change"`
SrvCheckStatus uint64 `csv:"srv_check_status"`
SrvCheckResult SrvCheckResult `csv:"srv_check_result"`
SrvCheckHealth uint64 `csv:"srv_check_health"`
SrvCheckState SrvCheckState `csv:"srv_check_state"`
SrvAgentState SrvAgentState `csv:"srv_agent_state"`
BkFForcedID uint64 `csv:"bk_f_forced_id"`
SrvFForced_id uint64 `csv:"srv_f_forced_id"`
SrvFQDN string `csv:"srv_fqdn"`
SrvPort uint64 `csv:"srv_port"`
SrvRecord string `csv:"srvrecord"`
SrvUseSSL uint64 `csv:"srv_use_ssl"`
SrvCheckPort uint64 `csv:"srv_check_port"`
SrvCheckAddr string `csv:"srv_check_addr"`
SrvAgentAddr string `csv:"srv_agent_addr"`
SrvAgentPort uint64 `csv:"srv_agent_port"`
}
Response from HAProxy "show servers state" command.
func ShowServersState ¶
func ShowServersState(h HAProxy) (serversState []*ShowServersStateResponse, err error)
Equivalent to HAProxy "show servers state" command.
type ShowStatResponse ¶
type ShowStatResponse struct {
PxName string `csv:"# pxname"`
SvName string `csv:"svname"`
Qcur uint64 `csv:"qcur"`
Qmax uint64 `csv:"qmax"`
Scur uint64 `csv:"scur"`
Smax uint64 `csv:"smax"`
Slim uint64 `csv:"slim"`
Stot uint64 `csv:"stot"`
Bin uint64 `csv:"bin"`
Bout uint64 `csv:"bout"`
Dreq uint64 `csv:"dreq"`
Dresp uint64 `csv:"dresp"`
Ereq uint64 `csv:"ereq"`
Econ uint64 `csv:"econ"`
Eresp uint64 `csv:"eresp"`
Wretr uint64 `csv:"wretr"`
Wredis uint64 `csv:"wredis"`
Status string `csv:"status"`
Weight uint64 `csv:"weight"`
Act uint64 `csv:"act"`
Bck uint64 `csv:"bck"`
ChkFail uint64 `csv:"chkfail"`
ChkDown uint64 `csv:"chkdown"`
Lastchg uint64 `csv:"lastchg"`
Downtime uint64 `csv:"downtime"`
Qlimit uint64 `csv:"qlimit"`
Pid uint64 `csv:"pid"`
Iid uint64 `csv:"iid"`
Sid uint64 `csv:"sid"`
Throttle uint64 `csv:"throttle"`
Lbtot uint64 `csv:"lbtot"`
Tracked uint64 `csv:"tracked"`
Type uint64 `csv:"type"`
Rate uint64 `csv:"rate"`
RateLim uint64 `csv:"rate_lim"`
RateMax uint64 `csv:"rate_max"`
CheckStatus string `csv:"check_status"`
CheckCode uint64 `csv:"check_code"`
CheckDuration uint64 `csv:"check_duration"`
Hrsp1xx uint64 `csv:"hrsp_1xx"`
Hrsp2xx uint64 `csv:"hrsp_2xx"`
Hrsp3xx uint64 `csv:"hrsp_3xx"`
Hrsp4xx uint64 `csv:"hrsp_4xx"`
Hrsp5xx uint64 `csv:"hrsp_5xx"`
HrspOther uint64 `csv:"hrsp_other"`
Hanafail uint64 `csv:"hanafail"`
ReqRate uint64 `csv:"req_rate"`
ReqRateMax uint64 `csv:"req_rate_max"`
ReqTot uint64 `csv:"req_tot"`
CliAbrt uint64 `csv:"cli_abrt"`
SrvAbrt uint64 `csv:"srv_abrt"`
CompIn uint64 `csv:"comp_in"`
CompOut uint64 `csv:"comp_out"`
CompByp uint64 `csv:"comp_byp"`
CompRsp uint64 `csv:"comp_rsp"`
LastSess int64 `csv:"lastsess"`
LastChk string `csv:"last_chk"`
LastAgt uint64 `csv:"last_agt"`
Qtime uint64 `csv:"qtime"`
Ctime uint64 `csv:"ctime"`
Rtime uint64 `csv:"rtime"`
Ttime uint64 `csv:"ttime"`
AgentStatus uint64 `csv:"agent_status"`
AgentCode uint64 `csv:"agent_code"`
AgentDuration uint64 `csv:"agent_duration"`
CheckDesc uint64 `csv:"check_desc"`
AgentDesc uint64 `csv:"agent_desc"`
CheckRise uint64 `csv:"check_rise"`
CheckFall uint64 `csv:"check_fall"`
CheckHealth uint64 `csv:"check_health"`
AgentRise uint64 `csv:"agent_rise"`
AgentFall uint64 `csv:"agent_fall"`
AgentHealth uint64 `csv:"agent_health"`
Addr string `csv:"addr"`
Cookie uint64 `csv:"cookie"`
Mode string `csv:"mode"`
Algo string `csv:"algo"`
ConnRate uint64 `csv:"conn_rate"`
ConnRateMax uint64 `csv:"conn_rate_max"`
ConnTot uint64 `csv:"conn_tot"`
Intercepted uint64 `csv:"intercepted"`
Dcon uint64 `csv:"dcon"`
Dses uint64 `csv:"dses"`
Wrew uint64 `csv:"wrew"`
Connect uint64 `csv:"connect"`
Reuse uint64 `csv:"reuse"`
CacheLookups uint64 `csv:"cache_lookups"`
CacheHits uint64 `csv:"cache_hits"`
SrvIcur uint64 `csv:"srv_icur"`
SrcIlim uint64 `csv:"src_ilim"`
QtimeMax uint64 `csv:"qtime_max"`
CtimeMax uint64 `csv:"ctime_max"`
RtimeMax uint64 `csv:"rtime_max"`
TtimeMax uint64 `csv:"ttime_max"`
Eint uint64 `csv:"eint"`
IdleConnCur uint64 `csv:"idle_conn_cur"`
SafeConnCur uint64 `csv:"safe_conn_cur"`
UsedConnCur uint64 `csv:"used_conn_cur"`
NeedConnEst uint64 `csv:"need_conn_est"`
}
Response from HAProxy "show stat" command.
func ShowStat ¶
func ShowStat(h HAProxy) (stats []*ShowStatResponse, err error)
Equivalent to HAProxy "show stat" command.
type SrvAdminState ¶
type SrvAdminState uint64
const ( SRV_ADMF_FMAINT SrvAdminState = 0x01 SRV_ADMF_IMAINT SrvAdminState = 0x02 SRV_ADMF_CMAINT SrvAdminState = 0x04 SRV_ADMF_FDRAIN SrvAdminState = 0x08 SRV_ADMF_IDRAIN SrvAdminState = 0x10 SRV_ADMF_RMAINT SrvAdminState = 0x20 SRV_ADMF_HMAINT SrvAdminState = 0x40 )
type SrvCheckResult ¶
type SrvCheckResult uint64
const ( CHK_RES_UNKNOWN SrvCheckResult = iota CHK_RES_NEUTRAL CHK_RES_FAILED CHK_RES_PASSED CHK_RES_CONDPASS )
type SrvCheckState ¶
type SrvCheckState uint64
const ( CHK_ST_INPROGRESS SrvCheckState = 0x01 CHK_ST_CONFIGURED SrvCheckState = 0x02 CHK_ST_ENABLED SrvCheckState = 0x04 CHK_ST_PAUSED SrvCheckState = 0x08 )
type SrvOpState ¶
type SrvOpState uint64
const ( SRV_ST_STOPPED SrvOpState = iota SRV_ST_STARTING SRV_ST_RUNNING SRV_ST_STOPPING )