r3c*_*cgm 11 linux time port tcp test
我正在编写一个测量网络延迟的 Graphite/Diamond 收集器。具体来说,它应该测量打开与远程服务器上端口的连接所需的时间。它需要通过脚本工作,即键盘上没有人以交互方式运行。
举个例子,给 telnet 提供一个虚构的参数,它可以完全满足我的需要。
time telnet --close-connection-immediately-after-established somehost.somedomain.com 1234
Trying somehost.somedomain.com...
Connected to somehost.somedomain.com.
Escape character is '^]'.
Connection closed automatically after established.
real 0m3.978s
user 0m0.001s
sys 0m0.003s
Run Code Online (Sandbox Code Playgroud)
基本上,在上面的示例中,仅使用内置工具输出 3.978 的命令行方式是什么?
您可以将 telnet 包装在我想的预期脚本中并使其出现问题:
^]
close
Run Code Online (Sandbox Code Playgroud)
……但那看起来相当丑陋。有任何想法吗?
Gil*_*not 27
关于什么 :
time nc -zw30 <host> <port>
Run Code Online (Sandbox Code Playgroud)