使用 sshping 检测服务器延迟
2019-02-05
编译 Building
- 安装 libssh-dev 或 libssh-devel 软件包 v0.6 及更高版本
# Ubuntu
sudo apt-get install libssh-dev
# CentOS
sudo yum install libssh-devel
- 克隆项目到本地
git clone https://github.com/spook/sshping.git
- 从项目主目录(README.md 文件所在的位置)运行
make
cd sshping
make
- 编译所生成的二进制文件,将位于项目里
bin/
目录中,可以将其复制到系统 bin 位置,例如:
sudo cp bin/sshping /usr/local/bin/
sudo chown root.root /usr/local/bin/sshping
sudo chmod 555 /usr/local/bin/sshping
报错处理
- 如果 CentOS 编译时 make 提示 g++ 命令未找到:
yum install -y gcc-c++
- 如果克隆项目时提示未安装git:
yum install -y git
用法 Usage
Usage: sshping [options] [user@]addr[:port]
Options:
-b --bindaddr IP Bind to this source address
-c --count NCHARS Number of characters to echo, default 1000
-d --delimited Use delimiters in big numbers, eg 1,234,567
-e --echocmd CMD Use CMD for echo command; default: cat > /dev/null
-h --help Print usage and exit
-i --identity FILE Identity file, ie ssh private keyfile
-p --password PWD Use password PWD (can be seen, use with care)
-r --runtests e|s Run tests e=echo s=speed; default es=both
-s --size MB For speed test, send/recv MB megabytes; default=8 MB
-t --time SECS Time limit for echo test
-T --connect-time S Time limit for ssh connection; default 10 sec
-v --verbose Show more output, use twice for lots: -vv
-z --remote FILE Remote file for up/download tests;
default=/tmp/sshping-PID.tmp