summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2015-08-21 21:14:54 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-08-21 21:14:54 +0900
commit4e26e427d0d1a70d6935ba3cecbbbf451665c096 (patch)
treed3577dc3f9d9b0111ffa6ee48478b90fd03bcc75 /tools
parenta5b7a77d0b07c8b20da8d920aa7d9c6a84dd6d29 (diff)
doc: add how to manage gobgp with your favorite laguage
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'tools')
-rw-r--r--tools/grpc/python/get_neighbor.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/grpc/python/get_neighbor.py b/tools/grpc/python/get_neighbor.py
new file mode 100644
index 00000000..6ce2aabe
--- /dev/null
+++ b/tools/grpc/python/get_neighbor.py
@@ -0,0 +1,22 @@
+import gobgp_pb2
+import sys
+
+_TIMEOUT_SECONDS = 10
+
+
+def run(gobgpd_addr, neighbor_addr):
+ with gobgp_pb2.early_adopter_create_Grpc_stub(gobgpd_addr, 8080) as stub:
+ peer = stub.GetNeighbor(gobgp_pb2.Arguments(rf=4, name=neighbor_addr), _TIMEOUT_SECONDS)
+ print("BGP neighbor is %s, remote AS %d" % (peer.conf.remote_ip, peer.conf.remote_as))
+ print(" BGP version 4, remote router ID %s" % ( peer.conf.id))
+ print(" BGP state = %s, up for %s" % ( peer.info.bgp_state, peer.info.uptime))
+ print(" BGP OutQ = %d, Flops = %d" % (peer.info.out_q, peer.info.flops))
+ print(" Hold time is %d, keepalive interval is %d seconds" % ( peer.info.negotiated_holdtime, peer.info.keepalive_interval))
+ print(" Configured hold time is %d, keepalive interval is %d seconds" % ( peer.conf.holdtime, peer.conf.keepalive_interval))
+
+
+if __name__ == '__main__':
+ gobgp = sys.argv[1]
+ neighbor = sys.argv[2]
+ run(gobgp, neighbor)
+