我正在使用此庫的修改版本(https://github.com/kamermans/HAProxyAPI)連接到我的所有負載均衡器實例。 但是,要知道所連接的服務器是活動實例還是備份實例,我需要從統計信息中尋找'bck'屬性。 (我無法使用:$ loadbalancer ['haproxy_stats'] - > info-> line-> data-> bck)訪問PHP保護的對象屬性(haproxy)
請注意,此屬性爲:$ loadbalancer ['haproxy_stats'] - > health-> backup。不是我需要的那個,這隻表示備份服務器是否存在於此負載均衡器中。
如何訪問此屬性?示例Haproxy Stats來自:HAProxy_Stats :: get($ exec) - > getServiceStats($ interface,$ server);示例代碼如下:HAProxy_Stats :: get($ exec) - > getServiceStats($ interface,$ server);
結果(的print_r)看起來像這樣:
HAProxy_Stats_Service對象 ( [信息] = > HAProxy_Stats_Info對象 ( [圖:保護] = >陣列 ( [pxname] = > proxy_name [svname] = > service_name [weight] = > weight [pid] = > process_id [iid] = > proxy_id [SID] = >的service_id [跟蹤] = >跟蹤 [型] = >類型 )
[type] => 2
[proxy_name] => core_loadbalancer
[service_name] => Core03
[process_id] => 1
[proxy_id] => 2
[service_id] => 3
[weight] => 1
[tracked] =>
[line:protected] => HAProxy_Stats_Line Object
(
[data:protected] => Array
(
[pxname] => core_loadbalancer
[svname] => Core03
[qcur] => 0
[qmax] => 0
[scur] => 0
[smax] => 0
[slim] => 20000
[stot] => 0
[bin] => 0
[bout] => 0
[dreq] =>
[dresp] => 0
[ereq] =>
[econ] => 0
[eresp] => 0
[wretr] => 0
[wredis] => 0
[status] => UP
[weight] => 1
[act] => 0
[bck] => 1
[chkfail] => 6
[chkdown] => 0
[lastchg] => 523133
[downtime] => 0
[qlimit] =>
[pid] => 1
[iid] => 2
[sid] => 3
[throttle] =>
[lbtot] => 0
[tracked] =>
[type] => 2
[rate] => 0
[rate_lim] =>
[rate_max] => 0
[check_status] => L4OK
[check_code] =>
[check_duration] => 0
[hrsp_1xx] => 0
[hrsp_2xx] => 0
[hrsp_3xx] => 0
[hrsp_4xx] => 0
[hrsp_5xx] => 0
[hrsp_other] => 0
[hanafail] => 0
[req_rate] =>
[req_rate_max] =>
[req_tot] =>
[cli_abrt] => 0
[srv_abrt] => 0
[] =>
)
)
)
目的繼續,但有字符限制...