Skip to content

Commit

Permalink
feat: Added pba_per_ip return for ippool to differentiate between ipp…
Browse files Browse the repository at this point in the history
…ool types (#267)

* feat: Added pba_per_ip return for ippool to differentiate between types of ippools
* docs: Updated readme

---------

Co-authored-by: Gianni Stubbe <[email protected]>
  • Loading branch information
33Fraise33 and Gianni Stubbe authored Jan 4, 2024
1 parent 99e11c0 commit 492984d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Per-VDOM:
* `fortigate_ippool_clients`
* `fortigate_ippool_used_items`
* `fortigate_ippool_total_items`
* `fortigate_ippool_pba_per_ip`
* _System/Fortimanager/Status_
* `fortigate_fortimanager_connection_status`
* `fortigate_fortimanager_registration_status`
Expand Down
10 changes: 10 additions & 0 deletions pkg/probe/firewall_ippool.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type IpPool struct {
Available float64 `json:"available"`
Used int `json:"used"`
Total int `json:"total"`
PbaPerIp int `json:"pba_per_ip"`
}

type IpPoolResponse struct {
Expand Down Expand Up @@ -67,6 +68,14 @@ func probeFirewallIpPool(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.M
)
)

var (
mPbaPerIp = prometheus.NewDesc(
"fortigate_ippool_pba_per_ip",
"Amount of available port block allocations per ip",
[]string{"vdom", "name"}, nil,
)
)

var rs []IpPoolResponse

if err := c.Get("api/v2/monitor/firewall/ippool", "vdom=*", &rs); err != nil {
Expand All @@ -84,6 +93,7 @@ func probeFirewallIpPool(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.M
m = append(m, prometheus.MustNewConstMetric(mClients, prometheus.GaugeValue, float64(ippool.Clients), r.VDOM, ippool.Name))
m = append(m, prometheus.MustNewConstMetric(mUsed, prometheus.GaugeValue, float64(ippool.Used), r.VDOM, ippool.Name))
m = append(m, prometheus.MustNewConstMetric(mTotal, prometheus.GaugeValue, float64(ippool.Total), r.VDOM, ippool.Name))
m = append(m, prometheus.MustNewConstMetric(mPbaPerIp, prometheus.GaugeValue, float64(ippool.PbaPerIp), r.VDOM, ippool.Name))
}
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/probe/firewall_ippool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func TestFirewallIpPool(t *testing.T) {
# HELP fortigate_ippool_used_items Amount of items used in ippool
# TYPE fortigate_ippool_used_items gauge
fortigate_ippool_used_items{name="ippool_name",vdom="FG-traffic"} 0
# HELP fortigate_ippool_pba_per_ip Amount of available port block allocations per ip
# TYPE fortigate_ippool_pba_per_ip gauge
fortigate_ippool_pba_per_ip{name="ippool_name",vdom="FG-traffic"} 472
`
if err := testutil.GatherAndCompare(r, strings.NewReader(em)); err != nil {
t.Fatalf("metric compare: err %v", err)
Expand Down

0 comments on commit 492984d

Please sign in to comment.