ping

package
v1.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const MinSamplesForVolatility = 20

MinSamplesForVolatility is the minimum number of valid (non-loss) latency readings a window needs before a P50/P99-derived volatility ratio is considered meaningful. Below this, percentiles are dominated by noise (e.g. a P99 of 10 samples is essentially just the 2nd-largest reading).

Variables

This section is empty.

Functions

func AddDefaultOnClientUUID

func AddDefaultOnClientUUID(uuid string) error

AddDefaultOnClientUUID 在新客户端注册后,把该 UUID 追加到所有 default_on=true 的任务的 clients 中(去重)。

func AddPingTask

func AddPingTask(clients []string, defaultOn bool, name string, target, taskType string, interval int) (uint, error)

AddPingTask 创建延迟监测任务。defaultOn 表示新加入的服务器是否自动开启此监测。

func AdminAddTask

func AdminAddTask(_ context.Context, req *rpc.JsonRpcRequest) (any, *rpc.JsonRpcError)

func AdminDeleteTask

func AdminDeleteTask(_ context.Context, req *rpc.JsonRpcRequest) (any, *rpc.JsonRpcError)

func AdminEditTask

func AdminEditTask(_ context.Context, req *rpc.JsonRpcRequest) (any, *rpc.JsonRpcError)

func AdminListTasks

func AdminListTasks(_ context.Context, _ *rpc.JsonRpcRequest) (any, *rpc.JsonRpcError)

func AdminOrderTasks

func AdminOrderTasks(_ context.Context, req *rpc.JsonRpcRequest) (any, *rpc.JsonRpcError)

func AdminSyncClientPingNodes

func AdminSyncClientPingNodes(_ context.Context, req *rpc.JsonRpcRequest) (any, *rpc.JsonRpcError)

AdminSyncClientPingNodes 全量同步"这台服务器要监测哪些节点",供服务器 列表页面的"设置监测节点"弹窗调用:内置节点按省份/运营商代码校验(不信任 前端拼出来的 target 字符串),自建任务按 ID 传入。未出现在这次提交里的 节点,会把这台服务器从对应任务里移除。

func DeleteAllPingRecords

func DeleteAllPingRecords() error

func DeletePingRecords

func DeletePingRecords(id []uint) error

func DeletePingTask

func DeletePingTask(id []uint) error

func EditPingTask

func EditPingTask(tasks []*models.PingTask) error

EditPingTask 批量更新延迟监测任务配置。

func GetAllPingTasks

func GetAllPingTasks() ([]models.PingTask, error)

func GetPingRecords

func GetPingRecords(uuid string, taskId int, start, end time.Time) ([]models.PingRecord, error)

func GetPingTasksByClient

func GetPingTasksByClient(uuid string) []models.PingTask

GetPingTasksByClient 获取指定服务器需要执行的延迟监测任务。

func PercentileLatencies

func PercentileLatencies(sortedValues []int) (p50, p99 int)

PercentileLatencies returns the 50th and 99th percentile of sortedValues using linear interpolation between the two nearest ranks. sortedValues must already be sorted ascending.

func ReloadPingSchedule

func ReloadPingSchedule() error

func SavePingRecord

func SavePingRecord(record models.PingRecord) error

func SyncClientPingNodes

func SyncClientPingNodes(clientUUID string, selectedBuiltin []pingpresets.Node, builtinInterval int, selectedCustomTaskIDs []uint) error

SyncClientPingNodes 全量同步"这台服务器要监测哪些节点":内置节点按 (省份,运营商) 精确匹配 target 判断,自建任务按 ID 判断。选中的要确保这台 服务器在 Clients 里(内置节点不存在对应 PingTask 就新建);没选中但当前 绑着这台服务器的,就把它从 Clients 里移除——不删任务本身,因为可能还 绑着别的服务器。builtinInterval 是这次勾选的内置节点统一使用的间隔, 会覆盖这些任务原有的 interval(哪怕是别的服务器之前设置的)。

func UpdatePingTaskOrder

func UpdatePingTaskOrder(order map[uint]int) error

func Volatility

func Volatility(p50, p99 float64) (ratio float64, ok bool)

Volatility measures how much worse the tail (P99) is than the median (P50): (P99-P50) divided by a base clamped to [10, 50] so a very small P50 doesn't blow the ratio up out of proportion. This is a product-defined "how spiky is this task's latency" indicator (labeled "Volatility"/"波动" in the UI) -- it is not network jitter in the RFC 3550 sense. ok is false when p50/p99 don't support a meaningful ratio (no samples, or p99 < p50).

Types

This section is empty.

Jump to

Keyboard shortcuts

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