summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-17 00:11:08 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-17 00:11:08 +0900
commitfe3a7e226622a58d746a199b96cc938c39f9445b (patch)
treeca27c8fd9dacbba28d4e677db0f772cc39826e8c /server
parent1ee4e65bc9ed53887c9c835dfbb22d3b7817d71c (diff)
cli: update show neighbors output
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/peer.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/server/peer.go b/server/peer.go
index 437ea38c..9fa6961c 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -78,6 +78,7 @@ func NewPeer(g config.GlobalType, peer config.NeighborType, serverMsgCh chan *se
}
p.fsm = NewFSM(&g, &peer, p.acceptedConnCh, p.incoming, p.outgoing)
peer.BgpNeighborCommonState.State = uint32(bgp.BGP_FSM_IDLE)
+ peer.BgpNeighborCommonState.Downtime = time.Now()
if peer.NeighborAddress.To4() != nil {
p.rf = bgp.RF_IPv4_UC
} else {
@@ -281,7 +282,7 @@ func (peer *Peer) loop() error {
peer.fsm.peerConfig.BgpNeighborCommonState.EstablishedCount++
}
if oldState == bgp.BGP_FSM_ESTABLISHED {
- peer.fsm.peerConfig.BgpNeighborCommonState.Uptime = time.Time{}
+ peer.fsm.peerConfig.BgpNeighborCommonState.Downtime = time.Now()
peer.adjRib.DropAllIn(peer.rf)
pm := &peerMsg{
msgType: PEER_MSG_PEER_DOWN,
@@ -356,6 +357,11 @@ func (peer *Peer) MarshalJSON() ([]byte, error) {
if !s.Uptime.IsZero() {
uptime = time.Now().Sub(s.Uptime).Seconds()
}
+ downtime := float64(0)
+ if !s.Downtime.IsZero() {
+ downtime = time.Now().Sub(s.Downtime).Seconds()
+ }
+
p["info"] = struct {
BgpState string `json:"bgp_state"`
FsmEstablishedTransitions uint32 `json:"fsm_established_transitions"`
@@ -372,7 +378,11 @@ func (peer *Peer) MarshalJSON() ([]byte, error) {
RefreshMessageOut uint32 `json:"refresh_message_out"`
RefreshMessageIn uint32 `json:"refresh_message_in"`
Uptime float64 `json:"uptime"`
+ Downtime float64 `json:"downtime"`
LastError string `json:"last_error"`
+ Received uint32
+ Accepted uint32
+ Advertized uint32
}{
BgpState: f.state.String(),
@@ -390,6 +400,10 @@ func (peer *Peer) MarshalJSON() ([]byte, error) {
RefreshMessageOut: s.RefreshOut,
RefreshMessageIn: s.RefreshIn,
Uptime: uptime,
+ Downtime: downtime,
+ Received: uint32(peer.adjRib.GetInCount(peer.rf)),
+ Accepted: uint32(peer.adjRib.GetInCount(peer.rf)),
+ Advertized: uint32(peer.adjRib.GetOutCount(peer.rf)),
}
return json.Marshal(p)