我从Heroku应用程序连接到外部托管的MongoDB服务器。我需要在Heroku应用和 MongoDB服务器之间测试延迟。我跑了 Heroku bash ,但那里没有“ ping ”命令。我唯一的目的是测试Heroku和MongoDB服务器之间的延迟。
答案 0 :(得分:1)
试试这个(需要node.js):https://www.npmjs.com/package/tcp-ping
$ heroku run bash
Running `bash` attached to terminal... up, run.9040
~ $ npm install tcp-ping
tcp-ping@0.1.1 node_modules/tcp-ping
~ $ node
> var tcpp = require('tcp-ping');
undefined
> tcpp.ping({ address: 'www.heroku.com', port: 80 }, function(err, data) {
... console.log(data);
... });
undefined
> { address: 'www.heroku.com',
port: 80,
attempts: 10,
avg: 10.4436728,
max: 31.421943,
min: 4.133464,
results:
[ { seq: 0, time: 31.421943 },
{ seq: 1, time: 7.204108 },
{ seq: 2, time: 10.878877 },
{ seq: 3, time: 13.744017 },
{ seq: 4, time: 4.133464 },
{ seq: 5, time: 7.970543 },
{ seq: 6, time: 9.550277 },
{ seq: 7, time: 7.120228 },
{ seq: 8, time: 6.797261 },
{ seq: 9, time: 5.61601 } ] }
undefined
所以,首先安装tcp-ping:
~ $ npm install tcp-ping
然后,将这些复制粘贴到Node REPL客户端:
var tcpp = require('tcp-ping');
tcpp.ping({ address: 'www.heroku.com', port: 80 }, function(err, data) {
console.log(data);
});