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 14
14
)
15
15
16
16
func 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\.]+)$` )
18
18
}
19
19
20
20
type bfdContext struct {
@@ -45,14 +45,19 @@ func parseBFDSessionLine(c *bfdContext) {
45
45
if m == nil {
46
46
return
47
47
}
48
+ var since_epoch int64
49
+ if m [5 ] != "" {
50
+ since_epoch = parseInt (m [5 ])
51
+ }
48
52
49
53
sess := protocol.BFDSession {
50
54
ProtocolName : c .protocol ,
51
55
IP : m [1 ],
52
56
Interface : m [2 ],
53
57
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 ]),
56
61
}
57
62
58
63
if m [3 ] == "Up" {
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ func TestParseBFDSessions(t *testing.T) {
16
16
data := `BIRD 2.0.7 ready.
17
17
bfd1:
18
18
IP 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
20
20
192.168.64.10 enp0s2 Down 2022-01-27 08:00:00 0.300 0.000
21
21
192.168.64.12 enp0s2 Init 2022-01-27 08:00:00 0.300 5.000`
22
22
@@ -30,6 +30,7 @@ IP address Interface State Since Interval Timeout
30
30
Interface : "enp0s2" ,
31
31
Up : true ,
32
32
Since : 3600 ,
33
+ SinceEpoch : 1697620076 ,
33
34
Interval : 0.1 ,
34
35
Timeout : 1 ,
35
36
}
@@ -39,6 +40,7 @@ IP address Interface State Since Interval Timeout
39
40
Interface : "enp0s2" ,
40
41
Up : false ,
41
42
Since : 7200 ,
43
+ SinceEpoch : 0 ,
42
44
Interval : 0.3 ,
43
45
Timeout : 0 ,
44
46
}
@@ -48,6 +50,7 @@ IP address Interface State Since Interval Timeout
48
50
Interface : "enp0s2" ,
49
51
Up : false ,
50
52
Since : 7200 ,
53
+ SinceEpoch : 0 ,
51
54
Interval : 0.3 ,
52
55
Timeout : 5 ,
53
56
}
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ type BFDSession struct {
6
6
Interface string
7
7
Up bool
8
8
Since int
9
+ SinceEpoch int64
9
10
Interval float64
10
11
Timeout float64
11
12
}
You can’t perform that action at this time.
0 commit comments