@@ -65,6 +65,11 @@ func probeFirewallLoadBalance(c fortigatehttpclient.FortiHTTP, meta *TargetMetad
6565 "Number of bytes processed by this real server" ,
6666 []string {"vdom" , "virtual_server" , "id" }, nil ,
6767 )
68+ realServerMaxConnections = prometheus .NewDesc (
69+ "fortigate_lb_real_server_max_connections" ,
70+ "Configured maximum concurrent connections for this real server (0 = unlimited)" ,
71+ []string {"vdom" , "virtual_server" , "id" }, nil ,
72+ )
6873 )
6974
7075 type RealServer struct {
@@ -106,6 +111,40 @@ func probeFirewallLoadBalance(c fortigatehttpclient.FortiHTTP, meta *TargetMetad
106111 return nil , false
107112 }
108113
114+ type vipRealServer struct {
115+ ID int `json:"id"`
116+ MaxConnections int `json:"max-connections"`
117+ }
118+ type vipConfig struct {
119+ Name string `json:"name"`
120+ RealServers []vipRealServer `json:"realservers"`
121+ }
122+ type vipResponse struct {
123+ Results []vipConfig
124+ VDOM string
125+ }
126+
127+ var vips []vipResponse
128+ if err := c .Get ("api/v2/cmdb/firewall/vip" , "vdom=*" , & vips ); err != nil {
129+ log .Printf ("Error: %v" , err )
130+ return nil , false
131+ }
132+
133+ maxConnections := map [string ]map [int ]int {}
134+ for _ , v := range vips {
135+ for _ , vc := range v .Results {
136+ key := v .VDOM + "\x00 " + vc .Name
137+ rsMap , ok := maxConnections [key ]
138+ if ! ok {
139+ rsMap = map [int ]int {}
140+ maxConnections [key ] = rsMap
141+ }
142+ for _ , rs := range vc .RealServers {
143+ rsMap [rs .ID ] = rs .MaxConnections
144+ }
145+ }
146+ }
147+
109148 m := []prometheus.Metric {}
110149
111150 for _ , r := range rs {
@@ -157,6 +196,7 @@ func probeFirewallLoadBalance(c fortigatehttpclient.FortiHTTP, meta *TargetMetad
157196 m = append (m , prometheus .MustNewConstMetric (realServerSessions , prometheus .GaugeValue , realServer .ActiveSessions , r .VDOM , virtualServer .Name , strconv .Itoa (realServer .ID )))
158197 m = append (m , prometheus .MustNewConstMetric (realServerRTT , prometheus .GaugeValue , realServerRTTValue , r .VDOM , virtualServer .Name , strconv .Itoa (realServer .ID )))
159198 m = append (m , prometheus .MustNewConstMetric (realServerBytesProcessed , prometheus .CounterValue , realServer .BytesProcessed , r .VDOM , virtualServer .Name , strconv .Itoa (realServer .ID )))
199+ m = append (m , prometheus .MustNewConstMetric (realServerMaxConnections , prometheus .GaugeValue , float64 (maxConnections [r .VDOM + "\x00 " + virtualServer .Name ][realServer .ID ]), r .VDOM , virtualServer .Name , strconv .Itoa (realServer .ID )))
160200 }
161201 }
162202 }
0 commit comments