diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-02-24 18:30:56 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-02-24 18:30:56 +0900 |
commit | 81ffbdf484622065ffc9dae9e28dc1ab83545fc2 (patch) | |
tree | 5c8d87750f217baaba0e152da60881c5c1c29502 | |
parent | 924765a0cb6f32f52d0802fab778b70b5abe75f8 (diff) |
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 <fujita.tomonori@lab.ntt.co.jp>
-rwxr-xr-x | cli/gobgpcli | 5 | ||||
-rw-r--r-- | server/peer.go | 2 |
2 files changed, 6 insertions, 1 deletions
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, |