Skip to content

Commit e592924

Browse files
Add parent-tunnel byte counters (NPU-offload-accurate)
Signed-off-by: Maksim Samonov <maksim.samonov@humbility.io>
1 parent b3a54c2 commit e592924

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

pkg/probe/vpn_ipsec.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ func probeVPNIPSec(c fortigatehttpclient.FortiHTTP, _ *TargetMetadata) ([]promet
3939
"Total number of bytes received over the IPsec tunnel",
4040
[]string{"vdom", "name", "p2serial", "parent"}, nil,
4141
)
42+
parentTransmitted = prometheus.NewDesc(
43+
"fortigate_ipsec_tunnel_parent_transmit_bytes_total",
44+
"Total bytes transmitted over the IPsec tunnel (parent counter, accurate under NPU offload)",
45+
[]string{"vdom", "name"}, nil,
46+
)
47+
parentReceived = prometheus.NewDesc(
48+
"fortigate_ipsec_tunnel_parent_receive_bytes_total",
49+
"Total bytes received over the IPsec tunnel (parent counter, accurate under NPU offload)",
50+
[]string{"vdom", "name"}, nil,
51+
)
4252
)
4353

4454
type proxyid struct {
@@ -49,10 +59,12 @@ func probeVPNIPSec(c fortigatehttpclient.FortiHTTP, _ *TargetMetadata) ([]promet
4959
Outgoing float64 `json:"outgoing_bytes"`
5060
}
5161
type tunnel struct {
52-
Name string `json:"name"`
53-
Type string `json:"type"`
54-
ProxyID []proxyid `json:"proxyid"`
55-
Connection int `json:"connection_count"`
62+
Name string `json:"name"`
63+
Type string `json:"type"`
64+
ProxyID []proxyid `json:"proxyid"`
65+
Connection int `json:"connection_count"`
66+
IncomingBytes float64 `json:"incoming_bytes"`
67+
OutgoingBytes float64 `json:"outgoing_bytes"`
5668
}
5769
type ipsecResult struct {
5870
Results []tunnel `json:"results"`
@@ -74,6 +86,12 @@ func probeVPNIPSec(c fortigatehttpclient.FortiHTTP, _ *TargetMetadata) ([]promet
7486
if i.Type == "dialup" {
7587
continue
7688
}
89+
m = append(m, prometheus.MustNewConstMetric(
90+
parentTransmitted, prometheus.CounterValue,
91+
i.OutgoingBytes, v.VDOM, i.Name))
92+
m = append(m, prometheus.MustNewConstMetric(
93+
parentReceived, prometheus.CounterValue,
94+
i.IncomingBytes, v.VDOM, i.Name))
7795
for _, t := range i.ProxyID {
7896
s := 0.0
7997
if t.Status == "up" {

0 commit comments

Comments
 (0)