1
0
Files
DiAL/probe-config.schema.json
lanyuanxiaoyao 550c427814 feat: 新增 ICMP/Ping checker,支持跨平台主机存活检测与延迟监控
实现 type: ping checker,通过 Bun.spawn 调用系统 ping 命令,自行实现跨平台
输出解析器(Linux/macOS/Windows 含中文 locale),支持 alive、丢包率、延迟、
耗时等 expect 断言,复用现有 checker 架构零外部依赖。

包含完整的类型定义、TypeBox schema、语义校验、命令构建、解析、断言、执行、
注册、配置加载测试,以及 probe-config.schema.json 更新和文档更新。

审查修复:提取 buildPingCommand 为独立纯函数并补充跨平台单测,补充
maxDurationMs/maxAvgLatencyMs 类型非法和空字符串 host 边界测试用例。

变更已归档,delta specs 已同步至 main specs。
2026-05-18 10:45:17 +08:00

1278 lines
39 KiB
JSON

{
"additionalProperties": false,
"type": "object",
"required": [
"targets"
],
"properties": {
"defaults": {
"additionalProperties": false,
"type": "object",
"properties": {
"interval": {
"type": "string"
},
"timeout": {
"type": "string"
},
"http": {
"additionalProperties": false,
"type": "object",
"properties": {
"headers": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"maxBodyBytes": {
"anyOf": [
{
"type": "string"
},
{
"minimum": 0,
"type": "integer"
}
]
}
}
},
"cmd": {
"additionalProperties": false,
"type": "object",
"properties": {
"cwd": {
"type": "string"
},
"maxOutputBytes": {
"anyOf": [
{
"type": "string"
},
{
"minimum": 0,
"type": "integer"
}
]
}
}
},
"db": {
"additionalProperties": false,
"type": "object",
"properties": {}
},
"tcp": {
"additionalProperties": false,
"type": "object",
"properties": {
"bannerReadTimeout": {
"minimum": 0,
"type": "number"
},
"maxBannerBytes": {
"anyOf": [
{
"type": "string"
},
{
"minimum": 0,
"type": "integer"
}
]
}
}
},
"ping": {
"additionalProperties": false,
"type": "object",
"properties": {}
}
}
},
"runtime": {
"additionalProperties": false,
"type": "object",
"properties": {
"maxConcurrentChecks": {
"minimum": 1,
"type": "integer"
},
"retention": {
"type": "string"
}
}
},
"server": {
"additionalProperties": false,
"type": "object",
"properties": {
"dataDir": {
"type": "string"
},
"host": {
"type": "string"
},
"port": {
"maximum": 65535,
"minimum": 0,
"type": "integer"
}
}
},
"targets": {
"minItems": 1,
"type": "array",
"items": {
"anyOf": [
{
"additionalProperties": false,
"type": "object",
"required": [
"id",
"type",
"http"
],
"properties": {
"description": {
"anyOf": [
{
"type": "null"
},
{
"maxLength": 500,
"type": "string"
}
]
},
"expect": {
"additionalProperties": false,
"type": "object",
"properties": {
"body": {
"type": "array",
"items": {
"additionalProperties": false,
"type": "object",
"properties": {
"contains": {
"type": "string"
},
"css": {
"additionalProperties": false,
"type": "object",
"required": [
"selector"
],
"properties": {
"attr": {
"type": "string"
},
"selector": {
"minLength": 1,
"type": "string"
},
"contains": {
"type": "string"
},
"empty": {
"type": "boolean"
},
"equals": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"items": {},
"type": "array"
},
{
"additionalProperties": {},
"type": "object"
}
]
},
"exists": {
"type": "boolean"
},
"gt": {
"type": "number"
},
"gte": {
"type": "number"
},
"lt": {
"type": "number"
},
"lte": {
"type": "number"
},
"match": {
"type": "string"
}
}
},
"json": {
"additionalProperties": false,
"type": "object",
"required": [
"path"
],
"properties": {
"path": {
"type": "string"
},
"contains": {
"type": "string"
},
"empty": {
"type": "boolean"
},
"equals": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"items": {},
"type": "array"
},
{
"additionalProperties": {},
"type": "object"
}
]
},
"exists": {
"type": "boolean"
},
"gt": {
"type": "number"
},
"gte": {
"type": "number"
},
"lt": {
"type": "number"
},
"lte": {
"type": "number"
},
"match": {
"type": "string"
}
}
},
"regex": {
"type": "string"
},
"xpath": {
"additionalProperties": false,
"type": "object",
"required": [
"path"
],
"properties": {
"path": {
"minLength": 1,
"type": "string"
},
"contains": {
"type": "string"
},
"empty": {
"type": "boolean"
},
"equals": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"items": {},
"type": "array"
},
{
"additionalProperties": {},
"type": "object"
}
]
},
"exists": {
"type": "boolean"
},
"gt": {
"type": "number"
},
"gte": {
"type": "number"
},
"lt": {
"type": "number"
},
"lte": {
"type": "number"
},
"match": {
"type": "string"
}
}
}
}
}
},
"headers": {
"additionalProperties": {
"anyOf": [
{
"type": "string"
},
{
"additionalProperties": false,
"minProperties": 1,
"type": "object",
"properties": {
"contains": {
"type": "string"
},
"empty": {
"type": "boolean"
},
"equals": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"items": {},
"type": "array"
},
{
"additionalProperties": {},
"type": "object"
}
]
},
"exists": {
"type": "boolean"
},
"gt": {
"type": "number"
},
"gte": {
"type": "number"
},
"lt": {
"type": "number"
},
"lte": {
"type": "number"
},
"match": {
"type": "string"
}
}
}
]
},
"type": "object"
},
"maxDurationMs": {
"minimum": 0,
"type": "number"
},
"status": {
"type": "array",
"items": {
"anyOf": [
{
"maximum": 599,
"minimum": 100,
"type": "integer"
},
{
"pattern": "^[1-5]xx$",
"type": "string"
}
]
}
}
}
},
"group": {
"type": "string"
},
"id": {
"maxLength": 30,
"minLength": 1,
"type": "string"
},
"interval": {
"type": "string"
},
"name": {
"anyOf": [
{
"type": "null"
},
{
"maxLength": 30,
"minLength": 1,
"type": "string"
}
]
},
"timeout": {
"type": "string"
},
"type": {
"const": "http",
"type": "string"
},
"http": {
"additionalProperties": false,
"type": "object",
"required": [
"url"
],
"properties": {
"body": {
"type": "string"
},
"headers": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"ignoreSSL": {
"type": "boolean"
},
"maxBodyBytes": {
"anyOf": [
{
"type": "string"
},
{
"minimum": 0,
"type": "integer"
}
]
},
"maxRedirects": {
"minimum": 0,
"type": "integer"
},
"method": {
"anyOf": [
{
"const": "DELETE",
"type": "string"
},
{
"const": "GET",
"type": "string"
},
{
"const": "HEAD",
"type": "string"
},
{
"const": "OPTIONS",
"type": "string"
},
{
"const": "PATCH",
"type": "string"
},
{
"const": "POST",
"type": "string"
},
{
"const": "PUT",
"type": "string"
}
]
},
"url": {
"minLength": 1,
"type": "string"
}
}
}
}
},
{
"additionalProperties": false,
"type": "object",
"required": [
"id",
"type",
"cmd"
],
"properties": {
"description": {
"anyOf": [
{
"type": "null"
},
{
"maxLength": 500,
"type": "string"
}
]
},
"expect": {
"additionalProperties": false,
"type": "object",
"properties": {
"exitCode": {
"type": "array",
"items": {
"type": "integer"
}
},
"maxDurationMs": {
"minimum": 0,
"type": "number"
},
"stderr": {
"type": "array",
"items": {
"additionalProperties": false,
"minProperties": 1,
"type": "object",
"properties": {
"contains": {
"type": "string"
},
"empty": {
"type": "boolean"
},
"equals": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"items": {},
"type": "array"
},
{
"additionalProperties": {},
"type": "object"
}
]
},
"exists": {
"type": "boolean"
},
"gt": {
"type": "number"
},
"gte": {
"type": "number"
},
"lt": {
"type": "number"
},
"lte": {
"type": "number"
},
"match": {
"type": "string"
}
}
}
},
"stdout": {
"type": "array",
"items": {
"additionalProperties": false,
"minProperties": 1,
"type": "object",
"properties": {
"contains": {
"type": "string"
},
"empty": {
"type": "boolean"
},
"equals": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"items": {},
"type": "array"
},
{
"additionalProperties": {},
"type": "object"
}
]
},
"exists": {
"type": "boolean"
},
"gt": {
"type": "number"
},
"gte": {
"type": "number"
},
"lt": {
"type": "number"
},
"lte": {
"type": "number"
},
"match": {
"type": "string"
}
}
}
}
}
},
"group": {
"type": "string"
},
"id": {
"maxLength": 30,
"minLength": 1,
"type": "string"
},
"interval": {
"type": "string"
},
"name": {
"anyOf": [
{
"type": "null"
},
{
"maxLength": 30,
"minLength": 1,
"type": "string"
}
]
},
"timeout": {
"type": "string"
},
"type": {
"const": "cmd",
"type": "string"
},
"cmd": {
"additionalProperties": false,
"type": "object",
"required": [
"exec"
],
"properties": {
"args": {
"type": "array",
"items": {
"type": "string"
}
},
"cwd": {
"type": "string"
},
"env": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"exec": {
"minLength": 1,
"type": "string"
},
"maxOutputBytes": {
"anyOf": [
{
"type": "string"
},
{
"minimum": 0,
"type": "integer"
}
]
}
}
}
}
},
{
"additionalProperties": false,
"type": "object",
"required": [
"id",
"type",
"db"
],
"properties": {
"description": {
"anyOf": [
{
"type": "null"
},
{
"maxLength": 500,
"type": "string"
}
]
},
"expect": {
"additionalProperties": false,
"type": "object",
"properties": {
"maxDurationMs": {
"minimum": 0,
"type": "number"
},
"rowCount": {
"additionalProperties": false,
"minProperties": 1,
"type": "object",
"properties": {
"contains": {
"type": "string"
},
"empty": {
"type": "boolean"
},
"equals": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"items": {},
"type": "array"
},
{
"additionalProperties": {},
"type": "object"
}
]
},
"exists": {
"type": "boolean"
},
"gt": {
"type": "number"
},
"gte": {
"type": "number"
},
"lt": {
"type": "number"
},
"lte": {
"type": "number"
},
"match": {
"type": "string"
}
}
},
"rows": {
"type": "array",
"items": {
"additionalProperties": false,
"minProperties": 1,
"type": "object",
"patternProperties": {
"^(.*)$": {
"anyOf": [
{
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"items": {},
"type": "array"
},
{
"additionalProperties": {},
"type": "object"
}
]
},
{
"additionalProperties": false,
"minProperties": 1,
"type": "object",
"properties": {
"contains": {
"type": "string"
},
"empty": {
"type": "boolean"
},
"equals": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"items": {},
"type": "array"
},
{
"additionalProperties": {},
"type": "object"
}
]
},
"exists": {
"type": "boolean"
},
"gt": {
"type": "number"
},
"gte": {
"type": "number"
},
"lt": {
"type": "number"
},
"lte": {
"type": "number"
},
"match": {
"type": "string"
}
}
}
]
}
}
}
}
}
},
"group": {
"type": "string"
},
"id": {
"maxLength": 30,
"minLength": 1,
"type": "string"
},
"interval": {
"type": "string"
},
"name": {
"anyOf": [
{
"type": "null"
},
{
"maxLength": 30,
"minLength": 1,
"type": "string"
}
]
},
"timeout": {
"type": "string"
},
"type": {
"const": "db",
"type": "string"
},
"db": {
"additionalProperties": false,
"type": "object",
"required": [
"url"
],
"properties": {
"query": {
"minLength": 1,
"type": "string"
},
"url": {
"minLength": 1,
"type": "string"
}
}
}
}
},
{
"additionalProperties": false,
"type": "object",
"required": [
"id",
"type",
"tcp"
],
"properties": {
"description": {
"anyOf": [
{
"type": "null"
},
{
"maxLength": 500,
"type": "string"
}
]
},
"expect": {
"additionalProperties": false,
"type": "object",
"properties": {
"banner": {
"additionalProperties": false,
"minProperties": 1,
"type": "object",
"properties": {
"contains": {
"type": "string"
},
"empty": {
"type": "boolean"
},
"equals": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
},
{
"items": {},
"type": "array"
},
{
"additionalProperties": {},
"type": "object"
}
]
},
"exists": {
"type": "boolean"
},
"gt": {
"type": "number"
},
"gte": {
"type": "number"
},
"lt": {
"type": "number"
},
"lte": {
"type": "number"
},
"match": {
"type": "string"
}
}
},
"connected": {
"type": "boolean"
},
"maxDurationMs": {
"minimum": 0,
"type": "number"
}
}
},
"group": {
"type": "string"
},
"id": {
"maxLength": 30,
"minLength": 1,
"type": "string"
},
"interval": {
"type": "string"
},
"name": {
"anyOf": [
{
"type": "null"
},
{
"maxLength": 30,
"minLength": 1,
"type": "string"
}
]
},
"timeout": {
"type": "string"
},
"type": {
"const": "tcp",
"type": "string"
},
"tcp": {
"additionalProperties": false,
"type": "object",
"required": [
"host",
"port"
],
"properties": {
"bannerReadTimeout": {
"minimum": 0,
"type": "number"
},
"host": {
"minLength": 1,
"type": "string"
},
"maxBannerBytes": {
"anyOf": [
{
"type": "string"
},
{
"minimum": 0,
"type": "integer"
}
]
},
"port": {
"maximum": 65535,
"minimum": 1,
"type": "integer"
},
"readBanner": {
"type": "boolean"
}
}
}
}
},
{
"additionalProperties": false,
"type": "object",
"required": [
"id",
"type",
"ping"
],
"properties": {
"description": {
"anyOf": [
{
"type": "null"
},
{
"maxLength": 500,
"type": "string"
}
]
},
"expect": {
"additionalProperties": false,
"type": "object",
"properties": {
"alive": {
"type": "boolean"
},
"maxAvgLatencyMs": {
"minimum": 0,
"type": "number"
},
"maxDurationMs": {
"minimum": 0,
"type": "number"
},
"maxMaxLatencyMs": {
"minimum": 0,
"type": "number"
},
"maxPacketLoss": {
"maximum": 100,
"minimum": 0,
"type": "number"
}
}
},
"group": {
"type": "string"
},
"id": {
"maxLength": 30,
"minLength": 1,
"type": "string"
},
"interval": {
"type": "string"
},
"name": {
"anyOf": [
{
"type": "null"
},
{
"maxLength": 30,
"minLength": 1,
"type": "string"
}
]
},
"timeout": {
"type": "string"
},
"type": {
"const": "ping",
"type": "string"
},
"ping": {
"additionalProperties": false,
"type": "object",
"required": [
"host"
],
"properties": {
"count": {
"maximum": 100,
"minimum": 1,
"type": "integer"
},
"host": {
"minLength": 1,
"type": "string"
},
"packetSize": {
"maximum": 65500,
"minimum": 1,
"type": "integer"
}
}
}
}
}
]
}
},
"variables": {
"type": "object",
"patternProperties": {
"^[a-zA-Z_][a-zA-Z0-9_]*$": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
}
]
}
}
}
},
"$id": "https://dial.local/probe-config.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {}
}