@@ -39,14 +39,12 @@ var (
3939
4040func init () {
4141 labels := []string {"peer_ip" , "local_asn" , "peer_asn" , "vrf" }
42- upDesc = prometheus .NewDesc (prefix + "up" , "Returns if the session is up" , labels , nil )
4342 stateDesc = prometheus .NewDesc (prefix + "state" , "State of the BGP session (Down = 0, Idle = 1, Connect = 2, Active = 3, OpenSent = 4, OpenConfirm = 5, Established = 6)" , labels , nil )
4443 uptimeDesc = prometheus .NewDesc (prefix + "uptime_second" , "Time since the session was established in seconds" , labels , nil )
4544 updatesReceivedDesc = prometheus .NewDesc (prefix + "update_received_count" , "Number of updates received" , labels , nil )
4645 updatesSentDesc = prometheus .NewDesc (prefix + "update_sent_count" , "Number of updates sent" , labels , nil )
4746
4847 labelsRouter := append (labels , "sys_name" , "agent_address" )
49- upDescRouter = prometheus .NewDesc (prefix + "up" , "Returns if the session is up" , labelsRouter , nil )
5048 stateDescRouter = prometheus .NewDesc (prefix + "state" , "State of the BGP session (Down = 0, Idle = 1, Connect = 2, Active = 3, OpenSent = 4, OpenConfirm = 5, Established = 6)" , labelsRouter , nil )
5149 uptimeDescRouter = prometheus .NewDesc (prefix + "uptime_second" , "Time since the session was established in seconds" , labelsRouter , nil )
5250 updatesReceivedDescRouter = prometheus .NewDesc (prefix + "update_received_count" , "Number of updates received" , labelsRouter , nil )
@@ -79,7 +77,6 @@ type bgpCollector struct {
7977
8078// Describe conforms to the prometheus collector interface
8179func (c * bgpCollector ) Describe (ch chan <- * prometheus.Desc ) {
82- ch <- upDesc
8380 ch <- stateDesc
8481 ch <- uptimeDesc
8582 ch <- updatesReceivedDesc
@@ -92,7 +89,6 @@ func (c *bgpCollector) Describe(ch chan<- *prometheus.Desc) {
9289}
9390
9491func DescribeRouter (ch chan <- * prometheus.Desc ) {
95- ch <- upDescRouter
9692 ch <- stateDescRouter
9793 ch <- uptimeDescRouter
9894 ch <- updatesReceivedDescRouter
@@ -125,13 +121,10 @@ func collectForPeer(ch chan<- prometheus.Metric, peer *metrics.BGPPeerMetrics) {
125121 peer .VRF ,
126122 }
127123
128- var up float64
129124 var uptime float64
130- if peer .Up {
131- up = 1
125+ if peer .State == metrics .StateEstablished {
132126 uptime = float64 (time .Since (peer .Since ) * time .Second )
133127 }
134- ch <- prometheus .MustNewConstMetric (upDesc , prometheus .GaugeValue , up , l ... )
135128 ch <- prometheus .MustNewConstMetric (uptimeDesc , prometheus .GaugeValue , uptime , l ... )
136129 ch <- prometheus .MustNewConstMetric (stateDesc , prometheus .GaugeValue , float64 (peer .State ), l ... )
137130
@@ -153,13 +146,10 @@ func CollectForPeerRouter(ch chan<- prometheus.Metric, sysName string, agentAddr
153146 agentAddress ,
154147 }
155148
156- var up float64
157149 var uptime float64
158- if peer .Up {
159- up = 1
150+ if peer .State == metrics .StateEstablished {
160151 uptime = float64 (time .Since (peer .Since ) * time .Second )
161152 }
162- ch <- prometheus .MustNewConstMetric (upDescRouter , prometheus .GaugeValue , up , l ... )
163153 ch <- prometheus .MustNewConstMetric (uptimeDescRouter , prometheus .GaugeValue , uptime , l ... )
164154 ch <- prometheus .MustNewConstMetric (stateDescRouter , prometheus .GaugeValue , float64 (peer .State ), l ... )
165155
0 commit comments