Ping — Network Connectivity Tool
A thorough network connectivity diagnostic tool that checks host availability, traces routes, sweeps subnets, monitors uptime, and analyzes latency patterns. All results are stored locally in JSONL format for historical analysis and reporting.
Prerequisites
- -
ping command (pre-installed on most systems) - INLINECODE1 or
tracepath (for route tracing) - INLINECODE3 (for data processing and reporting)
- INLINECODE4 4.0+
Data Storage
All ping results and configuration are stored in ~/.ping/:
- -
~/.ping/data.jsonl — historical ping results (JSONL format) - INLINECODE7 — user configuration (default count, timeout, etc.)
Commands
check
Check connectivity to a target host. Sends ICMP echo requests and records results.
CODEBLOCK0
trace
Trace the network route to a target host, showing each hop and latency.
CODEBLOCK1
sweep
Sweep a subnet to discover responsive hosts. Scans a CIDR range.
CODEBLOCK2
monitor
Continuously monitor a host and log results. Runs a configurable number of pings over time.
CODEBLOCK3
report
Generate a summary report from stored ping history for a specific target or all targets.
CODEBLOCK4
latency
Analyze latency statistics (min, max, avg, jitter, percentiles) for a target.
CODEBLOCK5
compare
Compare connectivity and latency between multiple hosts side by side.
CODEBLOCK6
history
View stored ping history with optional filtering by target, date range, or status.
CODEBLOCK7
export
Export ping history to CSV or JSON format.
CODEBLOCK8
config
View or update ping configuration (default count, timeout, interval).
CODEBLOCK9
help
Show usage information and available commands.
CODEBLOCK10
version
Display the current version of the ping skill.
CODEBLOCK11
Environment Variables
| Variable | Description | Default |
|---|
| INLINECODE20 | Target host or IP address | — |
| INLINECODE21 |
Comma-separated list of targets (for compare) | — |
|
PING_COUNT | Number of ping packets to send |
4 |
|
PING_TIMEOUT | Timeout in seconds per packet |
5 |
|
PING_INTERVAL | Seconds between pings (monitor mode) |
5 |
|
PING_DURATION | Total monitoring duration in seconds |
60 |
|
PING_SUBNET | CIDR notation subnet for sweep | — |
|
PING_LIMIT | Max records to display in history |
50 |
|
PING_FORMAT | Export format:
csv or
json |
json |
|
PING_OUTPUT | Output file path for export | stdout |
|
PING_KEY | Config key to set | — |
|
PING_VALUE | Config value to set | — |
Examples
CODEBLOCK12
Powered by BytesAgain | bytesagain.com | hello@bytesagain.com
Ping — 网络连接工具
一款全面的网络连接诊断工具,可检查主机可用性、追踪路由、扫描子网、监控在线时长并分析延迟模式。所有结果均以JSONL格式本地存储,用于历史分析和报告生成。
前置条件
- - ping 命令(大多数系统已预装)
- traceroute 或 tracepath(用于路由追踪)
- python3(用于数据处理和报告生成)
- bash 4.0+
数据存储
所有ping结果和配置均存储在 ~/.ping/ 目录下:
- - ~/.ping/data.jsonl — 历史ping结果(JSONL格式)
- ~/.ping/config.json — 用户配置(默认计数、超时等)
命令
check
检查与目标主机的连接状态。发送ICMP回显请求并记录结果。
bash
PING
TARGET=8.8.8.8 PINGCOUNT=4 bash scripts/script.sh check
trace
追踪到目标主机的网络路由,显示每一跳和延迟。
bash
PING_TARGET=google.com bash scripts/script.sh trace
sweep
扫描子网以发现响应主机。扫描CIDR范围。
bash
PING_SUBNET=192.168.1.0/24 bash scripts/script.sh sweep
monitor
持续监控主机并记录结果。按配置的时间间隔运行指定次数的ping。
bash
PING
TARGET=8.8.8.8 PINGINTERVAL=5 PING_DURATION=60 bash scripts/script.sh monitor
report
根据存储的ping历史生成摘要报告,可针对特定目标或所有目标。
bash
PING_TARGET=8.8.8.8 bash scripts/script.sh report
latency
分析目标的延迟统计数据(最小值、最大值、平均值、抖动、百分位数)。
bash
PING_TARGET=8.8.8.8 bash scripts/script.sh latency
compare
并排比较多个主机的连接状态和延迟。
bash
PING_TARGETS=8.8.8.8,1.1.1.1,208.67.222.222 bash scripts/script.sh compare
history
查看存储的ping历史记录,可按目标、日期范围或状态进行筛选。
bash
PING
TARGET=8.8.8.8 PINGLIMIT=20 bash scripts/script.sh history
export
将ping历史导出为CSV或JSON格式。
bash
PING
FORMAT=csv PINGOUTPUT=ping_report.csv bash scripts/script.sh export
config
查看或更新ping配置(默认计数、超时、间隔)。
bash
PING
KEY=count PINGVALUE=10 bash scripts/script.sh config
help
显示使用说明和可用命令。
bash
bash scripts/script.sh help
version
显示ping技能的当前版本。
bash
bash scripts/script.sh version
环境变量
| 变量 | 描述 | 默认值 |
|---|
| PINGTARGET | 目标主机或IP地址 | — |
| PINGTARGETS |
逗号分隔的目标列表(用于比较) | — |
| PING_COUNT | 发送的ping数据包数量 | 4 |
| PING_TIMEOUT | 每个数据包的超时时间(秒) | 5 |
| PING_INTERVAL | ping之间的间隔时间(秒,监控模式) | 5 |
| PING_DURATION | 总监控时长(秒) | 60 |
| PING_SUBNET | 用于扫描的CIDR子网 | — |
| PING_LIMIT | 历史记录中显示的最大记录数 | 50 |
| PING_FORMAT | 导出格式:csv 或 json | json |
| PING_OUTPUT | 导出的输出文件路径 | 标准输出 |
| PING_KEY | 要设置的配置键 | — |
| PING_VALUE | 要设置的配置值 | — |
示例
bash
快速连接检查
PING_TARGET=google.com bash scripts/script.sh check
监控DNS服务器5分钟
PING
TARGET=8.8.8.8 PINGINTERVAL=10 PING_DURATION=300 bash scripts/script.sh monitor
比较DNS提供商
PING_TARGETS=8.8.8.8,1.1.1.1,9.9.9.9 bash scripts/script.sh compare
将上周数据导出为CSV
PING_FORMAT=csv bash scripts/script.sh export
由 BytesAgain 提供 | bytesagain.com | hello@bytesagain.com