File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1414)
1515
1616func init () {
17- bfdSessionRegex = regexp .MustCompile (`^([^\s]+)\s+([^\s]+)\s+(Up|Down|Init)\s+(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}|[^\s]+)\s+([0-9\.]+)\s+([0-9\.]+)$` )
17+ bfdSessionRegex = regexp .MustCompile (`^([^\s]+)\s+([^\s]+)\s+(Up|Down|Init)\s+(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}|[^\s]+)\s+(\d{1,})?\s+( [0-9\.]+)\s+([0-9\.]+)$` )
1818}
1919
2020type bfdContext struct {
@@ -45,14 +45,19 @@ func parseBFDSessionLine(c *bfdContext) {
4545 if m == nil {
4646 return
4747 }
48+ var since_epoch int64
49+ if m [5 ] != "" {
50+ since_epoch = parseInt (m [5 ])
51+ }
4852
4953 sess := protocol.BFDSession {
5054 ProtocolName : c .protocol ,
5155 IP : m [1 ],
5256 Interface : m [2 ],
5357 Since : parseUptime (m [4 ]),
54- Interval : parseFloat (m [5 ]),
55- Timeout : parseFloat (m [6 ]),
58+ SinceEpoch : since_epoch ,
59+ Interval : parseFloat (m [6 ]),
60+ Timeout : parseFloat (m [7 ]),
5661 }
5762
5863 if m [3 ] == "Up" {
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ func TestParseBFDSessions(t *testing.T) {
1616 data := `BIRD 2.0.7 ready.
1717bfd1:
1818IP address Interface State Since Interval Timeout
19- 192.168.64.9 enp0s2 Up 2022-01-27 09:00:00 0.100 1.000
19+ 192.168.64.9 enp0s2 Up 2022-01-27 09:00:00 1697620076 0.100 1.000
2020192.168.64.10 enp0s2 Down 2022-01-27 08:00:00 0.300 0.000
2121192.168.64.12 enp0s2 Init 2022-01-27 08:00:00 0.300 5.000`
2222
@@ -30,6 +30,7 @@ IP address Interface State Since Interval Timeout
3030 Interface : "enp0s2" ,
3131 Up : true ,
3232 Since : 3600 ,
33+ SinceEpoch : 1697620076 ,
3334 Interval : 0.1 ,
3435 Timeout : 1 ,
3536 }
@@ -39,6 +40,7 @@ IP address Interface State Since Interval Timeout
3940 Interface : "enp0s2" ,
4041 Up : false ,
4142 Since : 7200 ,
43+ SinceEpoch : 0 ,
4244 Interval : 0.3 ,
4345 Timeout : 0 ,
4446 }
@@ -48,6 +50,7 @@ IP address Interface State Since Interval Timeout
4850 Interface : "enp0s2" ,
4951 Up : false ,
5052 Since : 7200 ,
53+ SinceEpoch : 0 ,
5154 Interval : 0.3 ,
5255 Timeout : 5 ,
5356 }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ type BFDSession struct {
66 Interface string
77 Up bool
88 Since int
9+ SinceEpoch int64
910 Interval float64
1011 Timeout float64
1112}
You can’t perform that action at this time.
0 commit comments