@@ -2,7 +2,7 @@ package probe
22
33import (
44 "log"
5-
5+ "strconv"
66 "github.com/bluecmd/fortigate_exporter/pkg/http"
77 "github.com/prometheus/client_golang/prometheus"
88)
@@ -12,42 +12,42 @@ func probeSystemInterface(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.
1212 mLink = prometheus .NewDesc (
1313 "fortigate_interface_link_up" ,
1414 "Whether the link is up or not (not taking into account admin status)" ,
15- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
15+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
1616 )
1717 mSpeed = prometheus .NewDesc (
1818 "fortigate_interface_speed_bps" ,
1919 "Speed negotiated on the port in bits/s" ,
20- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
20+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
2121 )
2222 mTxPkts = prometheus .NewDesc (
2323 "fortigate_interface_transmit_packets_total" ,
2424 "Number of packets transmitted on the interface" ,
25- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
25+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
2626 )
2727 mRxPkts = prometheus .NewDesc (
2828 "fortigate_interface_receive_packets_total" ,
2929 "Number of packets received on the interface" ,
30- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
30+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
3131 )
3232 mTxB = prometheus .NewDesc (
3333 "fortigate_interface_transmit_bytes_total" ,
3434 "Number of bytes transmitted on the interface" ,
35- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
35+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
3636 )
3737 mRxB = prometheus .NewDesc (
3838 "fortigate_interface_receive_bytes_total" ,
3939 "Number of bytes received on the interface" ,
40- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
40+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
4141 )
4242 mTxErr = prometheus .NewDesc (
4343 "fortigate_interface_transmit_errors_total" ,
4444 "Number of transmission errors detected on the interface" ,
45- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
45+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
4646 )
4747 mRxErr = prometheus .NewDesc (
4848 "fortigate_interface_receive_errors_total" ,
4949 "Number of reception errors detected on the interface" ,
50- []string {"vdom" , "name" , "alias" , "parent" }, nil ,
50+ []string {"vdom" , "name" , "vlanid" , " alias" , "parent" }, nil ,
5151 )
5252 )
5353
@@ -64,6 +64,7 @@ func probeSystemInterface(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.
6464 RxBytes float64 `json:"rx_bytes"`
6565 TxErrors float64 `json:"tx_errors"`
6666 RxErrors float64 `json:"rx_errors"`
67+ VlanID int `json:"vlanid"`
6768 Interface string
6869 }
6970 type ifResponse struct {
@@ -83,14 +84,15 @@ func probeSystemInterface(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.
8384 if ir .Link {
8485 linkf = 1.0
8586 }
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 ))
87+ vlan_string := strconv .Itoa (ir .VlanID )
88+ m = append (m , prometheus .MustNewConstMetric (mLink , prometheus .GaugeValue , linkf , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
89+ m = append (m , prometheus .MustNewConstMetric (mSpeed , prometheus .GaugeValue , ir .Speed * 1000 * 1000 , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
90+ m = append (m , prometheus .MustNewConstMetric (mTxPkts , prometheus .CounterValue , ir .TxPackets , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
91+ m = append (m , prometheus .MustNewConstMetric (mRxPkts , prometheus .CounterValue , ir .RxPackets , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
92+ m = append (m , prometheus .MustNewConstMetric (mTxB , prometheus .CounterValue , ir .TxBytes , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
93+ m = append (m , prometheus .MustNewConstMetric (mRxB , prometheus .CounterValue , ir .RxBytes , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
94+ m = append (m , prometheus .MustNewConstMetric (mTxErr , prometheus .CounterValue , ir .TxErrors , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
95+ m = append (m , prometheus .MustNewConstMetric (mRxErr , prometheus .CounterValue , ir .RxErrors , v .VDOM , ir .Name , vlan_string , ir .Alias , ir .Interface ))
9496 }
9597 }
9698 return m , true
0 commit comments