11package probe
22
33import (
4- "log"
5-
6- "github.com/bluecmd/fortigate_exporter/pkg/http"
7- "github.com/prometheus/client_golang/prometheus"
4+ "log"
5+ "strconv"
6+ "github.com/bluecmd/fortigate_exporter/pkg/http"
7+ "github.com/prometheus/client_golang/prometheus"
8+ "github.com/prometheus-community/fortigate_exporter/pkg/fortigatehttpclient"
89)
910
1011func probeSystemInterface (c http.FortiHTTP , meta * TargetMetadata ) ([]prometheus.Metric , bool ) {
1112 var (
1213 mLink = prometheus .NewDesc (
1314 "fortigate_interface_link_up" ,
1415 "Whether the link is up or not (not taking into account admin status)" ,
15- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
16+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
1617 )
1718 mSpeed = prometheus .NewDesc (
1819 "fortigate_interface_speed_bps" ,
1920 "Speed negotiated on the port in bits/s" ,
20- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
21+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
2122 )
2223 mTxPkts = prometheus .NewDesc (
2324 "fortigate_interface_transmit_packets_total" ,
2425 "Number of packets transmitted on the interface" ,
25- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
26+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
2627 )
2728 mRxPkts = prometheus .NewDesc (
2829 "fortigate_interface_receive_packets_total" ,
2930 "Number of packets received on the interface" ,
30- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
31+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
3132 )
3233 mTxB = prometheus .NewDesc (
3334 "fortigate_interface_transmit_bytes_total" ,
3435 "Number of bytes transmitted on the interface" ,
35- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
36+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
3637 )
3738 mRxB = prometheus .NewDesc (
3839 "fortigate_interface_receive_bytes_total" ,
3940 "Number of bytes received on the interface" ,
40- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
41+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
4142 )
4243 mTxErr = prometheus .NewDesc (
4344 "fortigate_interface_transmit_errors_total" ,
4445 "Number of transmission errors detected on the interface" ,
45- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
46+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
4647 )
4748 mRxErr = prometheus .NewDesc (
4849 "fortigate_interface_receive_errors_total" ,
4950 "Number of reception errors detected on the interface" ,
50- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
51+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
5152 )
5253 )
5354
@@ -64,6 +65,7 @@ func probeSystemInterface(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.
6465 RxBytes float64 `json:"rx_bytes"`
6566 TxErrors float64 `json:"tx_errors"`
6667 RxErrors float64 `json:"rx_errors"`
68+ VlanID int `json:"vlanid"`
6769 Interface string
6870 }
6971 type ifResponse struct {
@@ -83,14 +85,15 @@ func probeSystemInterface(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.
8385 if ir .Link {
8486 linkf = 1.0
8587 }
86- m = append (m , prometheus .MustNewConstMetric (mLink , prometheus .GaugeValue , linkf , v .VDOM , ir .Name , ir .Alias , ir .Interface ))
87- m = append (m , prometheus .MustNewConstMetric (mSpeed , prometheus .GaugeValue , ir .Speed * 1000 * 1000 , v .VDOM , ir .Name , ir .Alias , ir .Interface ))
88- m = append (m , prometheus .MustNewConstMetric (mTxPkts , prometheus .CounterValue , ir .TxPackets , v .VDOM , ir .Name , ir .Alias , ir .Interface ))
89- m = append (m , prometheus .MustNewConstMetric (mRxPkts , prometheus .CounterValue , ir .RxPackets , v .VDOM , ir .Name , ir .Alias , ir .Interface ))
90- m = append (m , prometheus .MustNewConstMetric (mTxB , prometheus .CounterValue , ir .TxBytes , v .VDOM , ir .Name , ir .Alias , ir .Interface ))
91- m = append (m , prometheus .MustNewConstMetric (mRxB , prometheus .CounterValue , ir .RxBytes , v .VDOM , ir .Name , ir .Alias , ir .Interface ))
92- m = append (m , prometheus .MustNewConstMetric (mTxErr , prometheus .CounterValue , ir .TxErrors , v .VDOM , ir .Name , ir .Alias , ir .Interface ))
93- m = append (m , prometheus .MustNewConstMetric (mRxErr , prometheus .CounterValue , ir .RxErrors , v .VDOM , ir .Name , ir .Alias , ir .Interface ))
88+ vlan_string := strconv .Itoa (ir .VlanID )
89+ m = append (m , prometheus .MustNewConstMetric (mLink , prometheus .GaugeValue , linkf , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
90+ m = append (m , prometheus .MustNewConstMetric (mSpeed , prometheus .GaugeValue , ir .Speed * 1000 * 1000 , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
91+ m = append (m , prometheus .MustNewConstMetric (mTxPkts , prometheus .CounterValue , ir .TxPackets , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
92+ m = append (m , prometheus .MustNewConstMetric (mRxPkts , prometheus .CounterValue , ir .RxPackets , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
93+ m = append (m , prometheus .MustNewConstMetric (mTxB , prometheus .CounterValue , ir .TxBytes , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
94+ m = append (m , prometheus .MustNewConstMetric (mRxB , prometheus .CounterValue , ir .RxBytes , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
95+ m = append (m , prometheus .MustNewConstMetric (mTxErr , prometheus .CounterValue , ir .TxErrors , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
96+ m = append (m , prometheus .MustNewConstMetric (mRxErr , prometheus .CounterValue , ir .RxErrors , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
9497 }
9598 }
9699 return m , true
0 commit comments