Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added pba_per_ip return for ippool to differentiate between ippool types #267

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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