ping命令,我相信大家都不会陌生。但是能够把ping命令完成这样的,估计又是少数了。今天浩道跟大家分享最近github上看到的一个非常牛逼的gping工具。截止目前,该项目已经收获10.5K Star,一起看看大牛运维是如何将ping命令玩得如此高大上。

 对应github地址:https://github.com/orf/gping/releases

gping是一款基于Rust编程语言开发的网络诊断与监控工具。它不仅继承了传统ping命令的功能,还通过实时图形显示的方式,提供了一种全新的网络性能追踪和可视化手段。以下是关于gping的详细介绍:

a45a31246459f3d99d9ec9b2c77e9264.png

一、功能特点

1、实时图形化显示:gping使用ASCII字符绘制的图表实时更新,能够直观地展示每秒的网络延迟变化,使网络性能的变化一目了然。

2、多主机支持:该工具支持同时监测多个主机的延迟情况,每个主机的数据都有独立的颜色区分,便于用户进行比较和分析。

3、自定义颜色配置:用户可以为各个主机或命令分配特定颜色,使图表更加易读和个性化。

4、命令执行时间监控:除了ping之外,gping还可以监控自定义命令的执行时间,这在性能调优和故障排查中非常有用。

5、跨平台兼容性:gping支持Windows、MacOS和Linux等操作系统,确保了广泛的适用性。

6、灵活设置:用户可以自定义刷新间隔、图表缓冲区大小、颜色和图形模式等参数,以满足不同的监控需求。

二、安装与使用

以下我是基于欧拉系统22.03版本环境进行安装演示,大家可以自行参考。

(一)获取下载链接

051a77f340b479167127899e3e970284.png

(二)wget命令下载

wget https://github.com/orf/gping/releases/download/gping-v1.17.3/gping-Linux-x86_64.tar.gz

(三)解压运行

tar -xzvf gping-Linux-x86_64.tar.gz -C /opt/
[root@localhost ~]# cd /opt/
[root@localhost opt]# ./gping --help
Ping, but with a graph.


Usage: gping [OPTIONS] [HOSTS_OR_COMMANDS]...


Arguments:
  [HOSTS_OR_COMMANDS]...  Hosts or IPs to ping, or commands to run if --cmd is provided. Can use cloud shorthands like aws:eu-west-1.


Options:
      --cmd
          Graph the execution time for a list of commands rather than pinging hosts
  -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.
  -b, --buffer <BUFFER>
          Determines the number of seconds to display in the graph. [default: 30]
  -4
          Resolve ping targets to IPv4 address
  -6
          Resolve ping targets to IPv6 address
  -i, --interface <INTERFACE>
          Interface to use when pinging
  -s, --simple-graphics
          Uses dot characters instead of braille
      --vertical-margin <VERTICAL_MARGIN>
          Vertical margin around the graph (top and bottom) [default: 1]
      --horizontal-margin <HORIZONTAL_MARGIN>
          Horizontal margin around the graph (left and right) [default: 0]
  -c, --color <color>
          Assign color to a graph entry.


          This option can be defined more than once as a comma separated string, and the
          order which the colors are provided will be matched against the hosts or
          commands passed to gping.


          Hexadecimal RGB color codes are accepted in the form of '#RRGGBB' or the
          following color names: 'black', 'red', 'green', 'yellow', 'blue', 'magenta',
          'cyan', 'gray', 'dark-gray', 'light-red', 'light-green', 'light-yellow',
          'light-blue', 'light-magenta', 'light-cyan', and 'white'
      --clear
          Clear the graph from the terminal after closing the program
  -h, --help
          Print help
  -V, --version
          Print version
[root@localhost opt]#

运行gping命令后,看到如上打印信息,说明可以正常运行。

(四)使用过程举例

1、不指定协议栈的情况下,默认ping的是IPv4地址

./gping www.taobao.com

8f95f5d1973dfd953b300c11edbfe415.png

2、通过指定-6参数,ping向IPv6的地址

./gping -6 fe80::5669:fe4b:fe25:6d6a

1b1bcde747b66b8d7e66a7cbc98893c4.png

3、通过指定-c参数,以指定颜色显示ping状态

./gping www.taobao.com -c 'red'

0f968476031fc3f15136a3962c294881.png

4、可以同时ping几个目标地址

./gping www.taobao.com -c 'red' www.baidu.com -c 'blue'

fc2235f1962a9e93f49c1fcf71b92b74.png

(五)总结

实际工作中,各种运维小工具还是挺多的。大家都可以去试一试,看看是不是逼格更高点。或者大家也可以自己开发一些属于自己的小工具。

更多精彩

关注公众号DevOps和k8s全栈技术

DevOps和k8s全栈技术,专注于Linux、docker、k8s、python、go网络通信网络安全、云原生、云计算知识以及涵盖IT行业相关技能的学习,理论与实战结合,真正让你在学习工作中真正去用到所学。同时也会分享一些面试经验,助你找到高薪offer,让我们一起去学习,一起去进步,一起去涨薪!期待您的加入~~~关注回复“资料”可免费获取学习资料(含有电子书籍、视频等)。

喜欢的话,记得点“赞”“在看”b3bc06d5cb4eca41812b9a4b2e8020f9.gif

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐