Documentation
¶
Index ¶
- Constants
- type BackupReport
- type BasicInfoParams
- type CPUReport
- type ConnectionsReport
- type DiskReport
- type Event
- type EventParams
- type ExecParams
- type FileOperation
- type FileResult
- type GPUDetailReport
- type GPUDeviceInfo
- type IPAddress
- type IPFamily
- type LoadReport
- type MeshMode
- type MeshTraceAccepted
- type MeshTraceJobSnapshot
- type MeshTraceParams
- type Message
- type MessageParams
- type NetworkReport
- type NextTraceParams
- type NextTraceResult
- type NodeEndpoint
- type PingParams
- type PingResultParams
- type PullParams
- type RPCError
- type RamReport
- type RawRequest
- type Report
- type ReportParams
- type Request
- type Response
- type RouteItem
- type TaskResultParams
- type TerminalRequestParams
- type TraceHop
- type TraceProtocol
- type TraceSummary
- type UnlockItem
- type UnlockParams
- type UpdateParams
Constants ¶
const ( Version = "2.0" MethodAgentReport = "agent.report" MethodAgentBasicInfo = "agent.basicInfo" MethodAgentPingResult = "agent.pingResult" MethodAgentTaskResult = "agent.taskResult" MethodAgentExec = "agent.exec" MethodAgentPing = "agent.ping" MethodAgentMessage = "agent.message" MethodAgentEvent = "agent.event" MethodAgentTerminal = "agent.terminal.request" MethodAgentPull = "agent.pull" MethodAgentFile = "agent.file" MethodAgentFileResult = "agent.file.result" MethodAgentUnlock = "agent.unlock" // MethodAgentUpdate 让面板指定一个节点要运行的版本(roadmap H6)。 // // 这份文件与 agent/protocol/v2/jsonrpc.go 是同一协议的两份副本(面板与 agent 是两个模块,无法共享 // 代码),手工保持同步 —— 两侧各有一个测试断言方法名集合一致,否则漂移只会表现为「事件发出去了但 // agent 说 unknown method」。 MethodAgentUpdate = "agent.update" )
const ( MethodNetworkTestNextTrace = "networkTest.nextTrace" MethodNetworkTestIperf3 = "networkTest.iperf3" MethodNetworkTestMeshTrace = "networkTest.meshTrace" MethodNetworkTestGetMeshTraceJob = "networkTest.getMeshTraceJob" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackupReport ¶
type BackupReport struct {
// AgeSeconds 距最后一次【成功】备份的秒数;-1 表示无法确定
//(状态文件缺失或不可解析),此时 Ok 必为 0。
AgeSeconds int64 `json:"age_seconds"`
// Ok 为 1 表示最近一次备份成功,0 表示失败或状态未知。
Ok int `json:"ok"`
// Message 是可选的人类可读说明(例如失败原因),便于排查。
Message string `json:"message,omitempty"`
}
BackupReport 是备份新鲜度上报。
动机:备份「有没有在跑」和「最后一次成功是什么时候」往往没有人看, 直到真需要恢复时才发现已经坏了几个月。把最后成功时间变成可监控的指标, 就能用与主机指标相同的方式设阈值/基线告警。
type BasicInfoParams ¶
type BasicInfoParams struct {
Info map[string]interface{} `json:"info"`
}
type ConnectionsReport ¶
type DiskReport ¶
type EventParams ¶
type ExecParams ¶
type FileOperation ¶
type FileOperation struct {
UUID string `json:"uuid"`
RequestID string `json:"request_id"`
Op string `json:"op"`
Args map[string]any `json:"args,omitempty"`
}
FileOperation is metadata-only. File contents travel through the dedicated HTTP transfer endpoint rather than through JSON-RPC.
type FileResult ¶
type GPUDetailReport ¶
type GPUDetailReport struct {
Count int `json:"count"`
AverageUsage float64 `json:"average_usage"`
DetailedInfo []GPUDeviceInfo `json:"detailed_info"`
}
type GPUDeviceInfo ¶
type LoadReport ¶
type MeshTraceAccepted ¶
type MeshTraceJobSnapshot ¶
type MeshTraceJobSnapshot struct {
JobID string `json:"job_id"`
Status string `json:"status"`
Total int `json:"total"`
Done int `json:"done"`
Failed int `json:"failed"`
Running int `json:"running"`
Results []NextTraceResult `json:"results"`
StartedAt time.Time `json:"started_at"`
UpdatedAt time.Time `json:"updated_at"`
FinishedAt *time.Time `json:"finished_at"`
Error string `json:"error"`
}
type MeshTraceParams ¶
type MeshTraceParams struct {
SourceNodeIDs []string `json:"source_node_ids"`
TargetNodeIDs []string `json:"target_node_ids"`
Mode MeshMode `json:"mode"`
IPFamily IPFamily `json:"ip_family"`
Protocol TraceProtocol `json:"protocol"`
MaxHops int `json:"max_hops"`
TimeoutMs int `json:"timeout_ms"`
MaxConcurrency int `json:"max_concurrency"`
PerAgentLimit int `json:"per_agent_limit"`
}
type MessageParams ¶
type NetworkReport ¶
type NetworkReport struct {
TCPRetransPercent *float64 `json:"tcp_retrans_percent,omitempty"`
Up int64 `json:"up"`
Down int64 `json:"down"`
// TotalUp / TotalDown 是内核自开机以来的累计字节数:单调,可以做差得到"这段时间用了多少"。
TotalUp int64 `json:"totalUp"`
TotalDown int64 `json:"totalDown"`
// CycleUp / CycleDown 是自计费周期重置日以来的累计流量(--month-rotate)。
//
// 它**不是**计数器:跨周期会归零。面板必须按 gauge 存它的最后值,而不是对采样求和
// (求和等于"累计值 × 采样次数"),也不要对它取差值(那会把整个累计当增量)。
CycleUp int64 `json:"cycleUp,omitempty"`
CycleDown int64 `json:"cycleDown,omitempty"`
}
type NextTraceParams ¶
type NextTraceParams struct {
TaskID string `json:"task_id"`
SourceID string `json:"source_id"`
TargetID string `json:"target_id"`
TargetHost string `json:"target_host"`
IPFamily IPFamily `json:"ip_family"`
Protocol TraceProtocol `json:"protocol"`
MaxHops int `json:"max_hops"`
TimeoutMs int `json:"timeout_ms"`
RawOutput bool `json:"raw_output"`
}
type NextTraceResult ¶
type NextTraceResult struct {
TaskID string `json:"task_id"`
SourceID string `json:"source_id"`
TargetID string `json:"target_id"`
TargetHost string `json:"target_host"`
IPFamily IPFamily `json:"ip_family"`
Protocol TraceProtocol `json:"protocol"`
StartedAt time.Time `json:"started_at"`
FinishedAt time.Time `json:"finished_at"`
DurationMs int `json:"duration_ms"`
OK bool `json:"ok"`
Error string `json:"error"`
Summary TraceSummary `json:"summary"`
Hops []TraceHop `json:"hops"`
Raw json.RawMessage `json:"raw"`
RawText string `json:"raw_text"`
ExitCode int `json:"exit_code"`
Truncated bool `json:"truncated"`
}
type NodeEndpoint ¶
type PingParams ¶
type PingResultParams ¶
type PingResultParams struct {
TaskID uint `json:"task_id"`
PingType string `json:"ping_type"`
Value int `json:"value"`
// ValueUS 是同一测量结果的微秒精度值(新 agent 上报的 value_us)。
//
// 旧 agent 不发这个字段,此时为 0,面板回退到 Value(整数毫秒)。落库形态不变:
// 仍然写 ping.latency_ms 这一条序列,只是值从整数毫秒变成小数毫秒
// (420 µs → 0.42 ms)—— 不新增指标、不新增标签、不新增序列。
ValueUS int64 `json:"value_us,omitempty"`
FinishedAt time.Time `json:"finished_at"`
// Role 为空表示主目标;"reference" 表示这是参考点的结果。
Role string `json:"role,omitempty"`
// Family 是本次测量实际使用的地址族("ipv4"/"ipv6")。
// 目标是域名时由各节点自行解析,双栈域名可能落到不同族;面板靠它把
// 「同一任务、不同路径」拆成两条序列。旧 agent 不发该字段,此时为空,
// 行为与改动前完全一致。
Family string `json:"family,omitempty"`
}
type PullParams ¶
type RawRequest ¶ added in v0.1.16
type RawRequest struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
ID any `json:"id,omitempty"`
}
RawRequest is the wire shape of one inbound JSON-RPC request whose params have not been decoded yet.
The panel has to hand the params to a method-specific struct. Decoding them through Request.Params (an untyped `any`) builds a map[string]any for the whole payload — every number, nested object and string — only to marshal it back to JSON and unmarshal it into the typed struct. RawRequest keeps the params as the bytes that arrived, so the payload is decoded exactly once, by the code that knows what it is.
Request itself is unchanged: it is the shape this protocol uses when the panel *builds* a message (web/agent, web/rpc/jsonrpc), where the params are Go values that still have to be marshalled onto the wire.
func (RawRequest) DecodeParams ¶ added in v0.1.16
func (r RawRequest) DecodeParams(target any) error
DecodeParams unmarshals the request params into target.
Params are optional in JSON-RPC, and an omitted or explicitly null value leaves target untouched and reports no error, so method defaults keep applying exactly as they did when the params travelled through an untyped map.
type Report ¶
type Report struct {
UUID string `json:"uuid,omitempty"`
CPU CPUReport `json:"cpu"`
Ram RamReport `json:"ram"`
Swap RamReport `json:"swap"`
Load LoadReport `json:"load"`
Disk DiskReport `json:"disk"`
Network NetworkReport `json:"network"`
Connections ConnectionsReport `json:"connections"`
GPU *GPUDetailReport `json:"gpu,omitempty"`
Uptime int64 `json:"uptime"`
Process int `json:"process"`
// Backup 是可选的备份新鲜度上报。agent 未配置备份状态文件时为 nil,
// 因此不影响未使用该功能的部署,也不会写入任何 point。
Backup *BackupReport `json:"backup,omitempty"`
Message string `json:"message"`
Method string `json:"method,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
SampledAt time.Time `json:"sampled_at,omitempty"`
ReceivedAt time.Time `json:"received_at,omitempty"`
SampleIntervalSeconds float64 `json:"sample_interval_seconds,omitempty"`
CounterEpoch string `json:"counter_epoch,omitempty"`
Quality map[string]string `json:"quality,omitempty"`
}
func (Report) BoundedPayload ¶ added in v0.1.13
BoundedPayload limits retained strings and GPU cardinality before queueing.
type ReportParams ¶
type Response ¶
type TaskResultParams ¶
type TerminalRequestParams ¶
type TerminalRequestParams struct {
RequestID string `json:"request_id"`
}
type TraceProtocol ¶
type TraceProtocol string
const ( TraceProtocolICMP TraceProtocol = "icmp" TraceProtocolTCP TraceProtocol = "tcp" TraceProtocolUDP TraceProtocol = "udp" )
type TraceSummary ¶
type UnlockItem ¶ added in v0.1.9
type UnlockItem struct {
ID string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind"`
Status string `json:"status"`
Region string `json:"region,omitempty"`
Basis string `json:"basis"`
Detail string `json:"detail,omitempty"`
}
UnlockItem 是单个服务的结论。字段与 agent/unlock.Result 一一对应;服务端与探针是 两个独立模块,所以这里重新声明而不是共享类型 —— 线上形状就是这个结构体。
type UnlockParams ¶ added in v0.1.9
type UnlockParams struct {
EgressIP string `json:"egress_ip,omitempty"`
EgressRegion string `json:"egress_region,omitempty"`
ProbedAt time.Time `json:"probed_at"`
Results []UnlockItem `json:"results"`
Routes []RouteItem `json:"routes,omitempty"`
RoutesProbedAt time.Time `json:"routes_probed_at,omitempty"`
}
UnlockParams 是 agent.unlock 的负载:探针从自己的出口测得的解锁结论。
为什么由探针测而不是服务端测:解锁取决于【发起请求的那个 IP】,服务端在别的机房, 只能测到它自己。出口地址随结果一起上来,因为它不总是节点自己的地址 —— 本机群里 有主机是经由另一台节点出网的。
type UpdateParams ¶ added in v0.1.42
type UpdateParams struct {
Target string `json:"target"`
}
UpdateParams 是一次指定版本升级的请求,或一次取消。Target 为空表示取消指定、回到跟随最新发布。