From 81ffbdf484622065ffc9dae9e28dc1ab83545fc2 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 24 Feb 2015 18:30:56 +0900 Subject: cli: pretty up State printing Explicitly show adminstate idle. fujita@ubuntu:~/git/gobgp$ ./cli/gobgpcli show neighbors Peer AS Up/Down State |#Advertised Received Accepted 10.0.255.1 65001 never Idle(Admin) | 0 0 0 Signed-off-by: FUJITA Tomonori --- cli/gobgpcli | 5 ++++- server/peer.go | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/gobgpcli b/cli/gobgpcli index 29dcecdd..cdf5b56e 100755 --- a/cli/gobgpcli +++ b/cli/gobgpcli @@ -179,7 +179,7 @@ class Show(object): maxtimelen = len(str(t)) n["info"]["time"] = t - h = "{:%ds} {:>%ds} {:%ds} {:8s} |" % (maxaddrlen, maxaslen, maxtimelen) + h = "{:%ds} {:>%ds} {:%ds} {:11s} |" % (maxaddrlen, maxaslen, maxtimelen) f1 = h + "#{:8s} {:8s} {:8s}" print(f1.format("Peer", "AS", "Up/Down", "State", "Advertised", "Received", "Accepted")) for n in sorted_neighbors: @@ -197,6 +197,9 @@ class Show(object): elif s == "BGP_FSM_ESTABLISHED": state = "Establ" + if n["info"]["AdminState"] == "ADMIN_STATE_DOWN": + state = "Idle(Admin)" + f2 = h + " {:>8d} {:>8d} {:>8d}" print f2.format(n["conf"]["remote_ip"], str(n["conf"]["remote_as"]), n["info"]["time"], state, n["info"]["Advertized"], n["info"]["Received"], n["info"]["Accepted"]) return 0 diff --git a/server/peer.go b/server/peer.go index c635b2b1..3c274344 100644 --- a/server/peer.go +++ b/server/peer.go @@ -472,6 +472,7 @@ func (peer *Peer) MarshalJSON() ([]byte, error) { p["info"] = struct { BgpState string `json:"bgp_state"` + AdminState string FsmEstablishedTransitions uint32 `json:"fsm_established_transitions"` TotalMessageOut uint32 `json:"total_message_out"` TotalMessageIn uint32 `json:"total_message_in"` @@ -498,6 +499,7 @@ func (peer *Peer) MarshalJSON() ([]byte, error) { }{ BgpState: f.state.String(), + AdminState: f.adminState.String(), FsmEstablishedTransitions: s.EstablishedCount, TotalMessageOut: s.TotalOut, TotalMessageIn: s.TotalIn, -- cgit v1.2.3