summaryrefslogtreecommitdiffhomepage
path: root/tools/grpc/nodejs/get_neighbors.js
diff options
context:
space:
mode:
authorShintaro Kojima <goodies@codeout.net>2016-07-20 05:58:16 +0900
committerShintaro Kojima <goodies@codeout.net>2016-07-20 05:58:16 +0900
commitff58dba1908b2db3a9993977dc9f8bfd83d38593 (patch)
treec2e6fc7cafcf1cfc123530c3f51e6f591b730d60 /tools/grpc/nodejs/get_neighbors.js
parentf1baa204dc0f7edabb8e23330271e6fdc26df7e2 (diff)
Fix and get along with gobgpd v1.9
Diffstat (limited to 'tools/grpc/nodejs/get_neighbors.js')
-rw-r--r--tools/grpc/nodejs/get_neighbors.js40
1 files changed, 20 insertions, 20 deletions
diff --git a/tools/grpc/nodejs/get_neighbors.js b/tools/grpc/nodejs/get_neighbors.js
index ba2296fa..6cc6b082 100644
--- a/tools/grpc/nodejs/get_neighbors.js
+++ b/tools/grpc/nodejs/get_neighbors.js
@@ -1,24 +1,24 @@
var grpc = require('grpc');
var api = grpc.load('gobgp.proto').gobgpapi;
-var stub = new api.GobgpApi('localhost:50051', grpc.Credentials.createInsecure());
+var stub = new api.GobgpApi('localhost:50051', grpc.credentials.createInsecure());
-var call = stub.getNeighbors({});
-call.on('data', function(neighbor) {
- console.log('BGP neighbor is', neighbor.conf.remote_ip,
- ', remote AS', neighbor.conf.remote_as);
- console.log("\tBGP version 4, remote route ID", neighbor.conf.id);
- console.log("\tBGP state =", neighbor.info.bgp_state,
- ', up for', neighbor.info.uptime);
- console.log("\tBGP OutQ =", neighbor.info.out_q,
- ', Flops =', neighbor.info.flops);
- console.log("\tHold time is", neighbor.info.negotiated_holdtime,
- ', keepalive interval is', neighbor.info.keepalive_interval, 'seconds');
- console.log("\tConfigured hold time is", neighbor.conf.holdtime);
-});
-call.on('end', function() {
- // do something when the server has finished sending
-});
-call.on('status', function(status) {
- // do something with the status
-});
+stub.getNeighbor({}, function(err, neighbor) {
+ neighbor.peers.forEach(function(peer) {
+ if(peer.info.bgp_state == 'BGP_FSM_ESTABLISHED') {
+ var date = new Date(Number(peer.timers.state.uptime)*1000);
+ var holdtime = peer.timers.state.negotiated_hold_time;
+ var keepalive = peer.timers.state.keepalive_interval;
+ }
+ console.log('BGP neighbor:', peer.conf.neighbor_address,
+ ', remote AS:', peer.conf.peer_as);
+ console.log("\tBGP version 4, remote router ID:", peer.conf.id);
+ console.log("\tBGP state:", peer.info.bgp_state,
+ ', uptime:', date);
+ console.log("\tBGP OutQ:", peer.info.out_q,
+ ', Flops:', peer.info.flops);
+ console.log("\tHold time:", holdtime,
+ ', keepalive interval:', keepalive, 'seconds');
+ console.log("\tConfigured hold time:", peer.timers.config.hold_time);
+ });
+});