goping

package module
v0.0.0-...-d96257b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2019 License: MIT Imports: 15 Imported by: 0

README

go simple ping

go APM GitHub release GitHub All Releases

简介

  1. 提供可视化的网络实时状况展示
  2. gui界面提供灵活的软件配置
    • 可通过json配置测试主机列表
    • 可通过json配置各项参数
  3. 提供一大堆go实现高效ping(支持多个ping并发)

预览

安装

  • 需要调用ping接口或改造gui

    使用go get工具进行安装源码

    go get github.com/intmian/goping
    
  • 只需gui工具的话,下载gui可执行文件go gui

issue

请提出宝贵意见 issue

使用

依赖

gui依赖于Gonum Plot

使用go get工具进行安装源码

go get gonum.org/v1/plot/...
引入
import "github.com/intmian/goping"
接口
  • Ping(host string, c chan int, count int, size int, timeout int64, neverStop bool)

    • host 主机号

    • count 一次发送几个包

    • size 包大小

    • timeout 时间

    • neverStop 是否为永久的ping(一直ping,直到ctrl + c终止)

    • done chan bool
      go Ping(host, done, count, timeout, neverStop)
      <-done
      
    • 会输出标准的ping信息(和系统自带的ping一样)

  • SimplePing(host string, c chan int)

    • func SimplePing(host string, c chan int) {
      	Ping(host, c, 4, 32, 1000, false)
      }
      
  • PingInfo

    • type PingInfo struct {
      	Average  float32
      	LostRate float32
      }
      
  • PingInside(host string, c chan PingInfo, count int, size int, timeout int64, neverStop bool)

    • 和之前的ping一样,不过数据以PingInfo形式输出

    • data chan bool
      go Ping_inside(host, data, count, timeout, neverStop)
      temp := <-data
      print(temp.Average)
      print(temp.LostRate)
      
  • PingInsideSimple(host string, c chan PingInfo)

    • func Ping_inside_simple(host string, c chan PingInfo) {
      	Ping_inside(host, c, 4, 32, 1000, false)
      }
      
  • Gui()

    • 以gui形式显示网络状况,从运行目录中读取 setting.jsonhosts.json 中的配置。ctrl + c 结束后保存图片到根目录的 avg.pnglost_rate.png

    • Gui()
      
    • 配置文件样本

      • setting.json

        {
          "sleepTime" : 10,
          "repaintTime" : 0.5,
          "count" : 5
        }
        
      • hosts.json

        [
          "www.baidu.com",
          "www.intmian.com"
        ]
        

Documentation

Overview

Package goping 包含了各种ping及一个动态界面

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gui

func Gui()

Gui 可以再命令行上动态的输出结果

func Ping

func Ping(host string, c chan int, count int, size int, timeout int64, neverStop bool)

Ping 可以根据参数在命令行上输出结果

func PingInside

func PingInside(host string, c chan PingInfo, count int, size int, timeout int64, neverStop bool)

PingInside 是可以通过PingInfo返回结果的Ping 但是不能返回每次的结果

func PingInsideSimple

func PingInsideSimple(host string, c chan PingInfo)

PingInsideSimple 是默认参数版的PingInside

func SimplePing

func SimplePing(host string, c chan int)

SimplePing 是一个默认参数版的Ping

Types

type PingInfo

type PingInfo struct {
	Average  float32
	LostRate float32
}

PingInfo is

type PingInfo struct {
	Average  float32
	LostRate float32
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL