查看原文
其他

比 ping 强百倍的工具!结果一目了然

The following article is from 民工哥技术之路 Author 点击关注👉

朋友们好,我是鱼皮,大家一般都怎么检测网络连通性呢?

想必 90% 以上的同学会回答:ping 命令。比如前段时间我网站被攻击的时候,就有很多同学指挥我说:“你 ping 一下试试。”

ping 命令的确可以满足大多数的需求了,但他毕竟是通过文本的形式显示的,可读性没有那么完美。今天给大家推荐一个更强大的命令行工具:gping(https://github.com/orf/gping)。

截止到鱼皮发文时,该项目已经收获了 6k star:


gping 是基于 Rust 编写可视化工具,具有动态图形化界面显示,可以实时查看网络连通情况:

安装

它的安装方式非常简单,到 GitHub 上下载系统所对应的安装包:

以 CentOS7 系统为例,其它系统请参考官方文档:

[root@centos7 ~]# wget https://github.com/orf/gping/releases/download/gping-v1.2.6/gping-Linux-x86_64.tar.gz
[root@centos7 ~]# ll gping-Linux-x86_64.tar.gz 
-rw-r--r-- 1 root root 889865 Dec  7 22:20 gping-Linux-x86_64.tar.gz
[root@centos7 ~]# mkdir /usr/local/gping
[root@centos7 ~]# tar zxf gping-Linux-x86_64.tar.gz -C /usr/local/gping

如果安装完后,运行命令出现下述错误:

./gping: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by ./gping)

解决方案如下:

curl -O http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz
tar zxf glibc-2.18.tar.gz 
cd glibc-2.18/
mkdir build
cd build/
../configure --prefix=/usr
make -j2
make install

使用方法

[root@centos7 gping]# ./gping --help
gping 1.2.6
Ping, but with a graph.

USAGE:
    gping [FLAGS] [OPTIONS] <hosts-or-commands>...

FLAGS:
        --cmd                Graph the execution time for a list of commands rather than pinging hosts
    -h, --help               Prints help information
    -4                       Resolve ping targets to IPv4 address
    -6                       Resolve ping targets to IPv6 address
    -s, --simple-graphics    Uses dot characters instead of braille
    -V, --version            Prints version information

OPTIONS:
    -b, --buffer <buffer>                    Determines the number of seconds to display in the graph. [default: 30]
    -n, --watch-interval <watch-interval>    Watch interval seconds (provide partial seconds like '0.5'). Default for
                                             ping is 0.2, default for cmd is 0.5.

ARGS:
    <hosts-or-commands>...    Hosts or IPs to ping, or commands to run if --cmd is provided.

它还可以同时对多个目标地址进行操作,可用于对比网速:


我也在 MAC 上装了一个,用一行 brew 命令就可以了。现在只要我的网站挂了,第一时间就能发现:



以上就是对该工具的介绍了,感兴趣的同学可以去试一下,这种让你秒变 “运维专家” 的神器的确不错。


最后,欢迎大家加入鱼皮的 编程学习圈子 ,和 5500 多名小伙伴一起交流学习,向鱼皮和大厂朋友们 1 对 1 提问、跟着鱼皮直播学编程做项目(往期直播都可回看)。冲冲冲!


往期推荐

5000 人,炸了!

全栈初中生,牛皮!

给大学的弟妹们做了一场讲座

几个免费的富文本编辑器,这不完胜付费?

偷偷盘点一下各大公司的实习薪资

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存