mirror of
https://github.com/osrg/gobgp.git
synced 2024-05-11 05:55:10 +00:00
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 <[email protected]>
This commit is contained in:
+4
-1
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user