Skip to content

Commit 492984d

Browse files
33Fraise33Gianni Stubbe
and
Gianni Stubbe
authored
feat: Added pba_per_ip return for ippool to differentiate between ippool 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]>
1 parent 99e11c0 commit 492984d

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Per-VDOM:
7070
* `fortigate_ippool_clients`
7171
* `fortigate_ippool_used_items`
7272
* `fortigate_ippool_total_items`
73+
* `fortigate_ippool_pba_per_ip`
7374
* _System/Fortimanager/Status_
7475
* `fortigate_fortimanager_connection_status`
7576
* `fortigate_fortimanager_registration_status`

Diff for: pkg/probe/firewall_ippool.go

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type IpPool struct {
1515
Available float64 `json:"available"`
1616
Used int `json:"used"`
1717
Total int `json:"total"`
18+
PbaPerIp int `json:"pba_per_ip"`
1819
}
1920

2021
type IpPoolResponse struct {
@@ -67,6 +68,14 @@ func probeFirewallIpPool(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.M
6768
)
6869
)
6970

71+
var (
72+
mPbaPerIp = prometheus.NewDesc(
73+
"fortigate_ippool_pba_per_ip",
74+
"Amount of available port block allocations per ip",
75+
[]string{"vdom", "name"}, nil,
76+
)
77+
)
78+
7079
var rs []IpPoolResponse
7180

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

Diff for: pkg/probe/firewall_ippool_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ func TestFirewallIpPool(t *testing.T) {
3535
# HELP fortigate_ippool_used_items Amount of items used in ippool
3636
# TYPE fortigate_ippool_used_items gauge
3737
fortigate_ippool_used_items{name="ippool_name",vdom="FG-traffic"} 0
38+
# HELP fortigate_ippool_pba_per_ip Amount of available port block allocations per ip
39+
# TYPE fortigate_ippool_pba_per_ip gauge
40+
fortigate_ippool_pba_per_ip{name="ippool_name",vdom="FG-traffic"} 472
3841
`
3942
if err := testutil.GatherAndCompare(r, strings.NewReader(em)); err != nil {
4043
t.Fatalf("metric compare: err %v", err)

0 commit comments

Comments
 (0)