{ "swagger": "2.0", "info": { "description": "jkagent management server.", "title": "agent-server", "contact": { "url": "https://www.jkstack.com" }, "version": "TODO" }, "basePath": "/api", "paths": { "/agents": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "agents" ], "summary": "获取节点列表", "operationId": "/api/agents", "parameters": [ { "enum": [ "example-agent", "container-agent", "metrics-agent", "rpa-agent", "..." ], "type": "string", "description": "节点类型,不指定则为所有", "name": "type", "in": "query" }, { "enum": [ "linux", "windows" ], "type": "string", "description": "节点操作系统,不指定则为所有", "name": "os", "in": "query" }, { "minimum": 1, "type": "integer", "default": 1, "description": "分页编号", "name": "page", "in": "query" }, { "minimum": 10, "type": "integer", "default": 20, "description": "每页数量", "name": "size", "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "type": "array", "items": { "$ref": "#/definitions/agents.info" } } } } ] } } } } }, "/agents/{id}": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "agents" ], "summary": "获取某个节点信息", "operationId": "/api/agents/info", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "$ref": "#/definitions/agents.info" } } } ] } } } } }, "/agents/{id}/log/download": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "agents" ], "summary": "下载某个agent下的日志文件", "operationId": "/api/agents/log/download", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "array", "items": { "type": "string" }, "collectionFormat": "csv", "description": "文件列表", "name": "files", "in": "query", "required": true }, { "minimum": 1, "type": "integer", "default": 600, "description": "超时时间", "name": "timeout", "in": "query" } ], "responses": { "200": { "description": "文件内容", "schema": { "type": "string" } }, "500": { "description": "出错原因", "schema": { "type": "string" } }, "503": { "description": "出错原因", "schema": { "type": "string" } } } } }, "/agents/{id}/logs": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "agents" ], "summary": "获取某个节点下的日志文件列表", "operationId": "/api/agents/logs", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "type": "array", "items": { "$ref": "#/definitions/agents.fileInfo" } } } } ] } } } } }, "/exec/{id}/kill/{pid}": { "delete": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "exec" ], "summary": "结束进程", "operationId": "/api/exec/kill", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "integer", "description": "进程号", "name": "pid", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/api.Success" } } } } }, "/exec/{id}/ps": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "exec" ], "summary": "列出正在运行中的任务", "operationId": "/api/exec/ps", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "type": "array", "items": { "$ref": "#/definitions/exec.info" } } } } ] } } } } }, "/exec/{id}/pty/{pid}": { "get": { "consumes": [ "application/json" ], "produces": [ "text/plain" ], "tags": [ "exec" ], "summary": "获取返回内容", "operationId": "/api/exec/pty", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "integer", "description": "进程号", "name": "pid", "in": "path", "required": true } ], "responses": { "200": { "description": "输出内容", "schema": { "type": "string" } }, "404": { "description": "\\\u003cwhat\\\u003e not found", "schema": { "type": "string" } }, "500": { "description": "出错原因", "schema": { "type": "string" } } } } }, "/exec/{id}/run": { "post": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "exec" ], "summary": "执行命令或脚本", "operationId": "/api/exec/run", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "description": "需启动的任务列表", "name": "args", "in": "body", "required": true, "schema": { "$ref": "#/definitions/exec.runArgs" } } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "$ref": "#/definitions/exec.runPayload" } } } ] } } } } }, "/exec/{id}/status/{pid}": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "exec" ], "summary": "获取运行状态", "operationId": "/api/exec/status", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "integer", "description": "进程号", "name": "pid", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "$ref": "#/definitions/exec.status" } } } ] } } } } }, "/file/{id}/download": { "get": { "consumes": [ "application/json" ], "produces": [ "text/plain" ], "tags": [ "file" ], "summary": "下载文件", "operationId": "/api/file/download", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "string", "description": "文件路径", "name": "dir", "in": "query", "required": true }, { "minimum": 1, "type": "integer", "default": 600, "description": "超时时间", "name": "timeout", "in": "query" } ], "responses": { "200": { "description": "输出内容", "schema": { "type": "string" } }, "404": { "description": "file not found", "schema": { "type": "string" } }, "500": { "description": "出错原因", "schema": { "type": "string" } }, "503": { "description": "出错原因", "schema": { "type": "string" } } } } }, "/file/{id}/ls": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "file" ], "summary": "查询文件列表", "operationId": "/api/file/ls", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "string", "description": "查询路径", "name": "dir", "in": "query", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "type": "array", "items": { "$ref": "#/definitions/file.info" } } } } ] } } } } }, "/file/{id}/upload": { "post": { "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "tags": [ "file" ], "summary": "上传文件", "operationId": "/api/file/upload", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "string", "description": "保存路径", "name": "dir", "in": "formData", "required": true }, { "type": "file", "description": "文件", "name": "file", "in": "formData", "required": true }, { "type": "string", "description": "md5校验码", "name": "md5", "in": "formData" }, { "type": "integer", "default": 644, "description": "文件权限(8进制)", "name": "mod", "in": "formData" }, { "type": "string", "description": "文件所属用户", "name": "own_user", "in": "formData" }, { "type": "string", "description": "文件所属分组", "name": "own_group", "in": "formData" }, { "type": "integer", "default": 60, "description": "超时时间", "name": "timeout", "in": "formData" } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/api.Success" } } } } }, "/foo/{id}": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "foo" ], "summary": "调用example类型的agent", "operationId": "/api/foo", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/api.Success" } } } } }, "/info/server": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "info" ], "summary": "获取当前服务器状态", "operationId": "/api/info/server", "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "$ref": "#/definitions/info.serverInfo" } } } ] } } } } }, "/ipmi/{id}/device": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "ipmi" ], "summary": "获取服务器的设备信息", "operationId": "/api/ipmi/device", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "string", "description": "IPMI地址", "name": "addr", "in": "query", "required": true }, { "type": "string", "description": "IPMI用户名", "name": "user", "in": "query", "required": true }, { "type": "string", "description": "IPMI密码", "name": "pass", "in": "query", "required": true }, { "enum": [ "lan", "lanplus", "auto" ], "type": "string", "default": "auto", "description": "IPMI连接模式", "name": "mode", "in": "query" } ], "responses": { "200": { "description": "服务器IPMI信息", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "$ref": "#/definitions/ipmi.deviceInfo" } } } ] } } } } }, "/ipmi/{id}/sensors": { "get": { "description": "常量定义:https://docs.jkservice.org/dp/others/ipmi/defs/", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "ipmi" ], "summary": "获取服务器的传感器列表", "operationId": "/api/ipmi/sensors", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "string", "description": "IPMI地址", "name": "addr", "in": "query", "required": true }, { "type": "string", "description": "IPMI用户名", "name": "user", "in": "query", "required": true }, { "type": "string", "description": "IPMI密码", "name": "pass", "in": "query", "required": true }, { "enum": [ "lan", "lanplus", "auto" ], "type": "string", "default": "auto", "description": "IPMI连接模式", "name": "mode", "in": "query" } ], "responses": { "200": { "description": "传感器列表", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "type": "array", "items": { "$ref": "#/definitions/ipmi.sensorInfo" } } } } ] } } } } }, "/layout/run": { "post": { "description": "分组示例:\n当ids参数为exec-01,exec-02,exec-03,group参数为1,1,2时,exec-01和exec-02节点为第一分组并发执行,当执行失败时若onerror参数为exit则不会执行后续分组中的exec-03节点任务", "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "tags": [ "layout" ], "summary": "批量执行脚本", "operationId": "/api/layout/run", "parameters": [ { "type": "array", "items": { "type": "string" }, "collectionFormat": "csv", "description": "节点ID列表", "name": "ids", "in": "formData", "required": true }, { "type": "array", "items": { "type": "integer" }, "collectionFormat": "csv", "description": "分组列表", "name": "group", "in": "formData", "required": true }, { "type": "file", "description": "文件", "name": "file", "in": "formData", "required": true }, { "enum": [ "sh", "bash", "python", "python3", "bat", "powershell", "php", "lua" ], "type": "string", "description": "脚本类型", "name": "type", "in": "formData", "required": true }, { "type": "array", "items": { "type": "string" }, "collectionFormat": "csv", "description": "参数", "name": "args", "in": "formData" }, { "type": "string", "description": "md5校验码", "name": "md5", "in": "formData" }, { "enum": [ "", "sudo", "su" ], "type": "string", "description": "提权方式,仅linux有效", "name": "auth", "in": "formData" }, { "type": "string", "description": "运行身份,仅linux有效", "name": "user", "in": "formData" }, { "type": "string", "description": "工作目录", "name": "workdir", "in": "formData" }, { "type": "array", "items": { "type": "string" }, "collectionFormat": "csv", "description": "环境变量", "name": "env", "in": "formData" }, { "type": "integer", "default": 60, "description": "单个节点的超时时间", "name": "timeout", "in": "formData" }, { "enum": [ "exit", "continue" ], "type": "string", "default": "exit", "description": "执行失败时的后续操作", "name": "onerror", "in": "formData" } ], "responses": { "200": { "description": "payload为任务ID", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "type": "string" } } } ] } } } } }, "/layout/{id}": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "layout" ], "summary": "获取批量任务状态", "operationId": "/api/layout/status", "parameters": [ { "type": "string", "description": "任务ID", "name": "id", "in": "query", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "$ref": "#/definitions/layout.status" } } } ] } } } } }, "/metrics/status": { "put": { "produces": [ "application/json" ], "tags": [ "metrics" ], "summary": "批量启动或停止采集", "operationId": "/api/metrics/batch_status_set", "parameters": [ { "description": "需启动的任务列表", "name": "jobs", "in": "body", "required": true, "schema": { "$ref": "#/definitions/metrics.batchSetArgs" } } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "$ref": "#/definitions/metrics.counts" } } } ] } } } } }, "/metrics/{id}/dynamic": { "get": { "description": "1. 当指定top参数时将会获取CPU占用率最高的n个进程数据\n2. 当指定kinds参数时获取的连接类型将会覆盖该agent节点配置文件中的类型设置\n3. 当未指定kinds参数且该agent未配置task.conns.allow类型时默认返回所有类型的连接", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "metrics" ], "summary": "获取节点的所有动态数据", "operationId": "/api/metrics/dynamic", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "integer", "description": "获取进程列表时的数量限制", "name": "top", "in": "query" }, { "type": "array", "items": { "enum": [ "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6", "unix" ], "type": "string" }, "collectionFormat": "csv", "description": "获取连接类型", "name": "kinds", "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "$ref": "#/definitions/metrics.dynamicInfo" } } } ] } } } } }, "/metrics/{id}/dynamic/connections": { "get": { "description": "1. 当指定kinds参数时获取的连接类型将会覆盖该agent节点配置文件中的类型设置\n2. 当未指定kinds参数且该agent未配置task.conns.allow类型时默认返回所有类型的连接", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "metrics" ], "summary": "获取节点的连接列表数据", "operationId": "/api/metrics/dynamic/connections", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "array", "items": { "enum": [ "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6", "unix" ], "type": "string" }, "collectionFormat": "csv", "description": "获取连接类型", "name": "kinds", "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "type": "array", "items": { "$ref": "#/definitions/metrics.connection" } } } } ] } } } } }, "/metrics/{id}/dynamic/process": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "metrics" ], "summary": "获取节点的所有进程列表数据", "operationId": "/api/metrics/dynamic/process", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "integer", "description": "数量限制", "name": "top", "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "type": "array", "items": { "$ref": "#/definitions/metrics.process" } } } } ] } } } } }, "/metrics/{id}/dynamic/temps": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "metrics" ], "summary": "获取节点的传感器温度数据", "operationId": "/api/metrics/dynamic/temps", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "type": "array", "items": { "$ref": "#/definitions/metrics.temp" } } } } ] } } } } }, "/metrics/{id}/dynamic/usage": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "metrics" ], "summary": "获取节点的usage动态数据", "operationId": "/api/metrics/dynamic/usage", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "$ref": "#/definitions/metrics.usage" } } } ] } } } } }, "/metrics/{id}/static": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "metrics" ], "summary": "获取节点的静态数据", "operationId": "/api/metrics/static", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "$ref": "#/definitions/metrics.staticInfo" } } } ] } } } } }, "/metrics/{id}/status": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "metrics" ], "summary": "获取节点自动采集状态", "operationId": "/api/metrics/status_get", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "$ref": "#/definitions/metrics.status" } } } ] } } } }, "put": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "metrics" ], "summary": "设置节点自动采集状态", "operationId": "/api/metrics/status_set", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "description": "需启动的任务列表", "name": "jobs", "in": "body", "required": true, "schema": { "$ref": "#/definitions/metrics.setArgs" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/api.Success" } } } } }, "/rpa/{id}/in_selector": { "post": { "description": "1. 当RPAAgent返回元素拾取结果时进行回调,即用户选择了某一个界面元素\n2. 使用`POST`方法进行回调\n3. 回调过程中将在请求体中包含以下内容\n\n ```json\n {\n \"id\": \"rpa-01\", // agent id\n \"ts\": 1689576608, // 时间戳\n \"cost\": 10, // 耗时(秒)\n \"code\": 1, // 状态码,1为成功,非1为失败\n \"msg\": \"abc\", // 错误信息\n \"content\": \"\u003cabc /\u003e\", // 元素拾取内容\n \"imageUri\": \"/rpa/files/...\", // 拾取元素图像获取uri\n \"requestId\": \"20230728...\" // 请求ID\n }\n ```", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "rpa" ], "summary": "进入元素选择器状态", "operationId": "/api/rpa/in_selector", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "description": "需启动的任务列表", "name": "args", "in": "body", "required": true, "schema": { "$ref": "#/definitions/rpa.inSelectorArgs" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/api.Success" } } } } }, "/rpa/{id}/selector_validate": { "post": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "rpa" ], "summary": "元素选择器结果验证", "operationId": "/api/rpa/selector_validate", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "description": "需启动的任务列表", "name": "args", "in": "body", "required": true, "schema": { "$ref": "#/definitions/rpa.selectorValidateArgs" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/api.Success" } } } } }, "/script/{id}/run": { "post": { "consumes": [ "multipart/form-data" ], "produces": [ "application/json" ], "tags": [ "script" ], "summary": "执行脚本", "operationId": "/api/script/run", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "file", "description": "文件", "name": "file", "in": "formData", "required": true }, { "enum": [ "sh", "bash", "python", "python3", "bat", "powershell", "php", "lua" ], "type": "string", "description": "脚本类型", "name": "type", "in": "formData", "required": true }, { "type": "array", "items": { "type": "string" }, "collectionFormat": "csv", "description": "参数", "name": "args", "in": "formData" }, { "type": "string", "description": "md5校验码", "name": "md5", "in": "formData" }, { "enum": [ "", "sudo", "su" ], "type": "string", "description": "提权方式,仅linux有效", "name": "auth", "in": "formData" }, { "type": "string", "description": "运行身份,仅linux有效", "name": "user", "in": "formData" }, { "type": "string", "description": "工作目录", "name": "workdir", "in": "formData" }, { "type": "array", "items": { "type": "string" }, "collectionFormat": "csv", "description": "环境变量", "name": "env", "in": "formData" }, { "type": "integer", "default": 60, "description": "超时时间", "name": "timeout", "in": "formData" } ], "responses": { "200": { "description": "OK", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "$ref": "#/definitions/script.runPayload" } } } ] } } } } }, "/snmp/{id}/list": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "snmp" ], "summary": "获取snmp清单", "operationId": "/api/snmp/list", "parameters": [ { "type": "string", "description": "节点ID", "name": "id", "in": "path", "required": true }, { "type": "string", "description": "SNMP服务地址", "name": "host", "in": "query", "required": true }, { "type": "string", "description": "SNMP community", "name": "community", "in": "query", "required": true }, { "type": "string", "description": "SNMP oid", "name": "oid", "in": "query" } ], "responses": { "200": { "description": "snmp列表", "schema": { "allOf": [ { "$ref": "#/definitions/api.Success" }, { "type": "object", "properties": { "payload": { "type": "array", "items": { "$ref": "#/definitions/anet.SNMPItem" } } } } ] } } } } } }, "definitions": { "agents.fileInfo": { "type": "object", "required": [ "mod_time", "name", "size" ], "properties": { "mod_time": { "description": "修改时间", "type": "integer", "example": 1663816771 }, "name": { "description": "文件名", "type": "string", "example": "metrics-agent.log" }, "size": { "description": "文件大小", "type": "integer", "example": 155 } } }, "agents.info": { "type": "object", "required": [ "arch", "id", "ip", "is_busy", "mac", "os", "platform", "type", "version" ], "properties": { "arch": { "description": "操作系统位数", "type": "string", "enum": [ "i386", "x86_64", "..." ], "example": "x86_64" }, "id": { "description": "agent-id", "type": "string", "example": "ct-01" }, "ip": { "description": "ip地址", "type": "string", "example": "127.0.0.1" }, "is_busy": { "description": "是否处于忙碌状态", "type": "boolean", "example": false }, "mac": { "description": "mac地址", "type": "string", "example": "00:15:5d:c9:e0:17" }, "os": { "description": "操作系统类型", "type": "string", "enum": [ "windows", "linux" ], "example": "linux" }, "platform": { "description": "操作系统名称", "type": "string", "enum": [ "debian", "centos", "..." ], "example": "debian" }, "type": { "description": "agent类型", "type": "string", "example": "container-agent" }, "version": { "description": "agent版本号", "type": "string", "example": "1.0.0" } } }, "anet.SNMPItem": { "type": "object", "properties": { "oid": { "description": "snmp oid", "type": "string" }, "type": { "description": "snmp type", "type": "string" }, "value": { "description": "snmp value", "type": "string" } } }, "api.Success": { "type": "object", "required": [ "code", "extime" ], "properties": { "code": { "description": "状态码", "type": "integer", "example": 200 }, "extime": { "description": "耗时(毫秒)", "type": "integer", "example": 70 }, "payload": { "description": "内容" } } }, "exec.info": { "type": "object", "required": [ "begin", "pid", "task_id" ], "properties": { "begin": { "description": "启动时间", "type": "integer", "example": 1665219359 }, "pid": { "description": "进程号", "type": "integer", "example": 11186 }, "task_id": { "description": "任务ID", "type": "string", "example": "20221008-00001-7a390a60f759aab5" } } }, "exec.result": { "type": "object", "required": [ "code", "running" ], "properties": { "code": { "description": "任务的返回状态", "type": "integer", "example": 0 }, "data": { "description": "返回内容(base64编码)", "type": "string" }, "end": { "description": "任务结束时间", "type": "integer", "example": 1663816771 }, "running": { "description": "任务是否还在执行中", "type": "boolean", "example": true } } }, "exec.runArgs": { "type": "object", "required": [ "cmd" ], "properties": { "args": { "description": "参数", "type": "array", "items": { "type": "string" }, "example": [ "hello world" ] }, "auth": { "description": "提权方式,仅linux有效", "type": "string", "enum": [ "", "sudo", "su" ], "example": "sudo" }, "cmd": { "description": "命令", "type": "string", "example": "echo" }, "env": { "description": "环境变量", "type": "array", "items": { "type": "string" }, "example": [ "DB_HOST=127.0.0.1", "DB_NAME=jkstack" ] }, "result": { "description": "是否直接返回数据", "type": "boolean", "default": true, "example": true }, "timeout": { "description": "超时时间", "type": "integer", "default": 60, "example": 3600 }, "user": { "description": "运行身份,仅linux有效", "type": "string", "example": "nobody" }, "workdir": { "description": "工作目录", "type": "string", "example": "/var/log" } } }, "exec.runPayload": { "type": "object", "required": [ "begin", "id", "pid" ], "properties": { "begin": { "description": "开始时间戳", "type": "integer", "example": 1663816771 }, "id": { "description": "任务ID", "type": "string", "example": "20220922-00001-4bc99720760771f6" }, "pid": { "description": "进程ID", "type": "integer", "example": 9655 }, "result": { "description": "任务状态,仅当result参数为true时返回", "allOf": [ { "$ref": "#/definitions/exec.result" } ] } } }, "exec.status": { "type": "object", "required": [ "begin", "done" ], "properties": { "begin": { "description": "任务开始时间", "type": "integer", "example": 1663816771 }, "code": { "description": "运行结果状态码", "type": "integer", "example": 0 }, "done": { "description": "该任务是否已执行完毕", "type": "boolean", "example": false }, "end": { "description": "结束时间,仅当running=false时返回", "type": "integer", "example": 1663816771 } } }, "file.info": { "type": "object", "required": [ "auth", "is_dir", "is_link", "mod_time", "name", "size" ], "properties": { "auth": { "description": "文件权限(10进制)", "type": "integer", "example": 777 }, "group": { "description": "所属组", "type": "string", "example": "root" }, "is_dir": { "description": "是否是目录", "type": "boolean", "example": true }, "is_link": { "description": "是否是软链", "type": "boolean", "example": false }, "link_dir": { "description": "连接路径", "type": "string", "example": "/usr/bin" }, "mod_time": { "description": "更新时间", "type": "integer", "example": 1663816771 }, "name": { "description": "文件名", "type": "string", "example": "bin" }, "size": { "description": "文件大小", "type": "integer", "example": 155 }, "user": { "description": "所属用户", "type": "string", "example": "root" } } }, "info.serverInfo": { "type": "object", "required": [ "agents", "id", "is_blocking", "version" ], "properties": { "agents": { "description": "当前连接的agent数量", "type": "integer", "example": 10 }, "id": { "description": "集群ID", "type": "string", "example": "cluster-01" }, "is_blocking": { "description": "是否处于限流状态", "type": "boolean", "example": false }, "version": { "description": "服务端版本号", "type": "string", "example": "1.0.0" } } }, "ipmi.deviceInfo": { "type": "object", "required": [ "firmware_version", "ipmi_version", "oem" ], "properties": { "firmware_version": { "description": "固件版本", "type": "string", "default": "0.0" }, "ipmi_version": { "description": "IPMI版本", "type": "string", "default": "2.0" }, "oem": { "description": "生产厂商", "type": "string", "default": "IBM" } } }, "ipmi.sensorCritical": { "type": "object", "properties": { "critical": { "description": "告警数值", "type": "number", "default": 70 }, "non_critical": { "description": "恢复数值", "type": "number", "default": 60 }, "non_recoverable": { "description": "严重告警数值", "type": "number", "default": 100 } } }, "ipmi.sensorInfo": { "type": "object", "required": [ "discrete", "entity_id", "id", "name", "sensor_id", "type" ], "properties": { "discrete": { "description": "是否是离散传感器", "type": "boolean", "default": false }, "entity_id": { "description": "实体ID", "type": "string", "default": "12.1" }, "id": { "description": "传感器序号", "type": "integer", "default": 0 }, "name": { "description": "传感器名称", "type": "string", "default": "Ambient Temp" }, "sensor_id": { "description": "传感器ID", "type": "integer", "default": 44 }, "type": { "description": "传感器类型", "type": "string", "default": "Temperature" }, "values": { "description": "传感器数值", "allOf": [ { "$ref": "#/definitions/ipmi.sensorValue" } ] } } }, "ipmi.sensorUnitValue": { "type": "object", "required": [ "base", "percent" ], "properties": { "base": { "description": "基本单位", "type": "string", "default": "degrees C" }, "mod": { "description": "第二项单位", "type": "string", "default": "minute" }, "op": { "description": "乘或除", "type": "string", "default": "/" }, "percent": { "description": "是否是百分比", "type": "boolean", "default": false } } }, "ipmi.sensorValue": { "type": "object", "required": [ "current", "unit" ], "properties": { "current": { "description": "当前数值", "type": "number", "default": 23 }, "lower": { "description": "最低告警数值", "allOf": [ { "$ref": "#/definitions/ipmi.sensorCritical" } ] }, "unit": { "description": "当前传感器的单位信息", "allOf": [ { "$ref": "#/definitions/ipmi.sensorUnitValue" } ] }, "upper": { "description": "最高告警数值", "allOf": [ { "$ref": "#/definitions/ipmi.sensorCritical" } ] } } }, "layout.nodeStatus": { "type": "object", "required": [ "begin", "id", "status" ], "properties": { "begin": { "description": "开始时间", "type": "integer", "example": 1663816771 }, "end": { "description": "仅当status=done时返回", "type": "integer", "example": 1663816771 }, "err": { "description": "错误信息", "type": "string", "example": "xxx not found" }, "id": { "description": "节点ID", "type": "string", "example": "exec-01" }, "status": { "description": "当前状态", "type": "string", "enum": [ "waiting", "running", "done" ], "example": "waiting" } } }, "layout.status": { "type": "object", "required": [ "begin", "done", "index" ], "properties": { "begin": { "description": "开始时间", "type": "integer", "example": 1663816771 }, "done": { "description": "该任务是否已执行完毕", "type": "boolean", "example": false }, "end": { "description": "结束时间,仅当done=true时返回", "type": "integer", "example": 1663816771 }, "index": { "description": "当前正在运行的批次号", "type": "integer", "example": 0 }, "nodes": { "description": "节点状态列表", "type": "array", "items": { "$ref": "#/definitions/layout.nodeStatus" } } } }, "metrics.batchSetArgs": { "type": "object", "required": [ "start" ], "properties": { "os": { "description": "操作系统", "type": "string", "enum": [ "linux", "windows" ], "example": "linux" }, "start": { "description": "是否启动", "type": "boolean", "example": true } } }, "metrics.connection": { "type": "object", "required": [ "fd", "pid", "status", "type" ], "properties": { "fd": { "description": "句柄号", "type": "integer", "example": 8 }, "local": { "description": "本地地址", "type": "string", "example": "127.0.0.1:13081" }, "pid": { "description": "所属进程ID", "type": "integer", "example": 28093 }, "remote": { "description": "远程地址", "type": "string", "example": "127.0.0.1:37470" }, "status": { "description": "连接状态", "type": "string", "enum": [ "", "ESTABLISHED", "SYN_SENT", "SYN_RECEIVED", "SYN_RECV", "FIN_WAIT_1", "FIN_WAIT_2", "FIN_WAIT1", "FIN_WAIT2", "TIME_WAIT", "CLOSE", "CLOSED", "CLOSE_WAIT", "LAST_ACK", "LISTEN", "CLOSING", "DELETE" ], "example": "ESTABLISHED" }, "type": { "description": "连接类型", "type": "string", "enum": [ "tcp4", "tcp6", "udp4", "udp6", "unix", "file" ], "example": "tcp4" } } }, "metrics.core": { "type": "object", "required": [ "core", "cores", "mhz", "model", "physical", "processor" ], "properties": { "core": { "description": "所在物理核上的编号", "type": "integer", "example": 0 }, "cores": { "description": "某块CPU上的编号", "type": "integer", "example": 0 }, "mhz": { "description": "核心频率", "type": "number", "example": 1600 }, "model": { "description": "CPU型号", "type": "string", "example": "Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz" }, "physical": { "description": "物理CPU编号", "type": "integer", "example": 0 }, "processor": { "description": "第几个核心", "type": "integer", "example": 0 } } }, "metrics.counts": { "type": "object", "required": [ "failure", "success", "total" ], "properties": { "failure": { "description": "失败节点数", "type": "integer", "example": 0 }, "success": { "description": "成功节点数", "type": "integer", "example": 10 }, "total": { "description": "触达节点数", "type": "integer", "example": 10 } } }, "metrics.disk": { "type": "object", "required": [ "model", "total", "type" ], "properties": { "disks": { "description": "逻辑分区", "type": "array", "items": { "type": "string" }, "example": [ "/boot", "/home" ] }, "model": { "description": "品牌型号", "type": "string", "example": "Samsung SSD 870 QVO 1TB" }, "total": { "description": "容量", "type": "integer", "example": 1000204886016 }, "type": { "description": "磁盘类型", "type": "string", "enum": [ "HDD", "SSD" ], "example": "HDD" } } }, "metrics.dynamicInfo": { "type": "object", "properties": { "connections": { "description": "连接列表", "type": "array", "items": { "$ref": "#/definitions/metrics.connection" } }, "process": { "description": "进程列表", "type": "array", "items": { "$ref": "#/definitions/metrics.process" } }, "temperatures": { "description": "传感器温度列表", "type": "array", "items": { "$ref": "#/definitions/metrics.temp" } }, "usage": { "description": "usage数据", "allOf": [ { "$ref": "#/definitions/metrics.usage" } ] } } }, "metrics.interfaceUsage": { "type": "object", "required": [ "bytes_recv", "bytes_sent", "name", "packets_recv", "packets_sent" ], "properties": { "bytes_recv": { "description": "接收字节数", "type": "integer", "example": 24422 }, "bytes_sent": { "description": "发送字节数", "type": "integer", "example": 6162729 }, "name": { "description": "网卡名称", "type": "string", "example": "eth0" }, "packets_recv": { "description": "接收数据包数量", "type": "integer", "example": 4399 }, "packets_sent": { "description": "发送数据包数量", "type": "integer", "example": 5699 } } }, "metrics.intf": { "type": "object", "required": [ "index", "mac", "mtu", "name" ], "properties": { "addrs": { "description": "网卡上绑定的IP地址列表", "type": "array", "items": { "type": "string" }, "example": [ "192.168.1.100" ] }, "flags": { "description": "网卡附加参数", "type": "array", "items": { "type": "string" }, "example": [ "UP", "BROADCAST", "RUNNING", "MULTICAST" ] }, "index": { "description": "网卡下标", "type": "integer", "example": 0 }, "mac": { "description": "网卡mac地址", "type": "string", "example": "26:29:93:f2:84:22" }, "mtu": { "description": "网卡mtu", "type": "integer", "example": 1500 }, "name": { "description": "网卡名称", "type": "string", "example": "lo" } } }, "metrics.job": { "type": "object", "required": [ "interval", "name" ], "properties": { "interval": { "description": "间隔时间", "type": "integer", "example": 5 }, "name": { "description": "任务名称", "type": "string", "enum": [ "static", "usage", "process", "conns" ], "example": "static" } } }, "metrics.partition": { "type": "object", "required": [ "mount", "total" ], "properties": { "fstype": { "description": "文件系统类型", "type": "string", "example": "NTFS" }, "inodes": { "description": "inode数量", "type": "integer", "example": 4072701 }, "mount": { "description": "linux为挂载路径如/run,windows为盘符如C:", "type": "string", "example": "/boot" }, "opts": { "description": "附加信息", "type": "array", "items": { "type": "string" }, "example": [ "rw", "nosuid", "nodev" ] }, "total": { "description": "总容量", "type": "integer", "example": 209666048 } } }, "metrics.partitionUsage": { "type": "object", "required": [ "free", "name", "read_per_second", "usage", "used", "write_per_second" ], "properties": { "free": { "description": "剩余字节数", "type": "integer", "example": 232815064 }, "inode_free": { "description": "inode剩余数量", "type": "integer", "example": 15998934 }, "inode_usage": { "description": "inode使用率", "type": "number", "example": 5.64 }, "inode_used": { "description": "inode已使用数量", "type": "integer", "example": 778282 }, "iops_in_progress": { "description": "正在等待的IO操作数量", "type": "integer", "example": 0 }, "name": { "description": "linux为挂载路径如/run,windows为盘符如C:", "type": "string", "example": "/" }, "read_per_second": { "description": "每秒读取字节数", "type": "number", "example": 100 }, "usage": { "description": "磁盘使用率", "type": "number", "example": 6.27 }, "used": { "description": "已使用字节数", "type": "integer", "example": 16920992 }, "write_per_second": { "description": "每秒写入字节数", "type": "number", "example": 200 } } }, "metrics.process": { "type": "object", "required": [ "conns", "id", "pid", "user" ], "properties": { "cmd": { "description": "命令行", "type": "array", "items": { "type": "string" }, "example": [ "/usr/bin/zsh", "-i" ] }, "conns": { "description": "连接数", "type": "integer", "example": 16 }, "cpu_usage": { "description": "CPU使用率", "type": "number", "example": 3.2 }, "id": { "description": "进程ID", "type": "integer", "example": 5167 }, "listen": { "description": "监听端口", "type": "array", "items": { "type": "integer" }, "example": [ 8080, 9090 ] }, "memory_usage": { "description": "内存使用率", "type": "number", "example": 6.4 }, "pid": { "description": "父进程ID", "type": "integer", "example": 1 }, "rss": { "description": "物理内存数", "type": "integer", "example": 37654 }, "swap": { "description": "swap内存数", "type": "integer", "example": 0 }, "user": { "description": "用户", "type": "string", "example": "root" }, "vms": { "description": "虚拟内存数", "type": "integer", "example": 26754 } } }, "metrics.setArgs": { "type": "object", "required": [ "jobs" ], "properties": { "jobs": { "description": "需启动的任务类型", "type": "array", "items": { "type": "string", "enum": [ "static", "usage", "process", "conns" ] }, "example": [ "static", "usage" ] } } }, "metrics.staticInfo": { "type": "object", "required": [ "cpu", "gateway", "host", "kernel", "memory", "nameservers", "os", "time" ], "properties": { "cpu": { "type": "object", "required": [ "logical", "physical" ], "properties": { "cores": { "description": "每个核心参数", "type": "array", "items": { "$ref": "#/definitions/metrics.core" } }, "logical": { "description": "逻辑核心数", "type": "integer", "example": 4 }, "physical": { "description": "物理核心数", "type": "integer", "example": 2 } } }, "disks": { "description": "物理磁盘列表", "type": "array", "items": { "$ref": "#/definitions/metrics.disk" } }, "gateway": { "description": "网关地址", "type": "string", "example": "192.168.1.1" }, "host": { "type": "object", "required": [ "name", "uptime" ], "properties": { "name": { "description": "主机名", "type": "string", "example": "DESKTOP-OQ8O3DR" }, "uptime": { "description": "启动时长", "type": "integer", "example": 1900 } } }, "interface": { "description": "网卡列表", "type": "array", "items": { "$ref": "#/definitions/metrics.intf" } }, "kernel": { "type": "object", "required": [ "arch", "version" ], "properties": { "arch": { "description": "位数", "type": "string", "enum": [ "x86_64", "i386", "..." ], "example": "x86_64" }, "version": { "description": "内核版本", "type": "string", "example": "3.10.0-1062.el7.x86_64" } } }, "memory": { "type": "object", "required": [ "physical", "swap" ], "properties": { "physical": { "description": "物理内存大小", "type": "integer", "example": 33363566592 }, "swap": { "description": "swap内存大小", "type": "integer", "example": 8589930496 } } }, "nameservers": { "description": "DNS服务器地址列表", "type": "array", "items": { "type": "string" }, "example": [ "192.168.1.1" ] }, "os": { "type": "object", "required": [ "install", "name", "platform_name", "platform_version", "startup" ], "properties": { "install": { "description": "系统安装时间", "type": "integer", "example": 1661396019 }, "name": { "description": "系统类型", "type": "string", "enum": [ "linux", "windows" ], "example": "linux" }, "platform_name": { "description": "系统名称", "type": "string", "enum": [ "redhat", "centos", "debian", "ubuntu", "..." ], "example": "centos" }, "platform_version": { "description": "系统版本号", "type": "string", "example": "7.7.1908" }, "startup": { "description": "系统启动时间", "type": "integer", "example": 1661396019 } } }, "partitions": { "description": "逻辑分区列表", "type": "array", "items": { "$ref": "#/definitions/metrics.partition" } }, "time": { "description": "客户端时间", "type": "integer", "example": 1661396019 }, "user": { "description": "用户列表", "type": "array", "items": { "$ref": "#/definitions/metrics.user" } } } }, "metrics.status": { "type": "object", "properties": { "allow_conns": { "description": "采集的连接类型", "type": "array", "items": { "type": "string", "enum": [ "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6", "unix" ] }, "example": [ "tcp", "udp" ] }, "jobs": { "description": "正在运行的任务列表", "type": "array", "items": { "$ref": "#/definitions/metrics.job" } } } }, "metrics.temp": { "type": "object", "required": [ "name", "temp" ], "properties": { "name": { "description": "名称", "type": "string", "example": "coretemp_core_0" }, "temp": { "description": "温度", "type": "number", "example": 38 } } }, "metrics.usage": { "type": "object", "properties": { "cpu": { "type": "object", "required": [ "load1", "load15", "load5", "usage" ], "properties": { "load1": { "description": "1分钟负载", "type": "number", "example": 0.3 }, "load15": { "description": "15分钟负载", "type": "number", "example": 0.5 }, "load5": { "description": "5分钟负载", "type": "number", "example": 0.4 }, "usage": { "description": "CPU使用率(百分比)", "type": "number", "example": 2.3 } } }, "interface": { "description": "网卡", "type": "array", "items": { "$ref": "#/definitions/metrics.interfaceUsage" } }, "memory": { "type": "object", "required": [ "available", "free", "swap_free", "swap_used", "usage", "used" ], "properties": { "available": { "description": "可用字节数", "type": "integer", "example": 201332 }, "free": { "description": "剩余字节数", "type": "integer", "example": 94896 }, "swap_free": { "description": "swap剩余字节数", "type": "integer", "example": 7242344 }, "swap_used": { "description": "swap已使用字节数", "type": "integer", "example": 1146264 }, "usage": { "description": "内存使用率(百分比)", "type": "number", "example": 1.2 }, "used": { "description": "已使用字节数", "type": "integer", "example": 1595712 } } }, "partitions": { "description": "分区", "type": "array", "items": { "$ref": "#/definitions/metrics.partitionUsage" } } } }, "metrics.user": { "type": "object", "required": [ "gid", "id", "name" ], "properties": { "gid": { "description": "用户组ID", "type": "string", "example": "0" }, "id": { "description": "用户ID", "type": "string", "example": "0" }, "name": { "description": "用户名", "type": "string", "example": "root" } } }, "rpa.inSelectorArgs": { "type": "object", "properties": { "callback": { "description": "回调地址", "type": "string", "example": "https://www.baidu.com" }, "requestId": { "description": "请求ID", "type": "string", "example": "20230728..." } } }, "rpa.selectorValidateArgs": { "type": "object", "properties": { "content": { "description": "验证内容", "type": "string" } } }, "script.runPayload": { "type": "object", "required": [ "begin", "code", "id" ], "properties": { "begin": { "description": "开始时间戳", "type": "integer", "example": 1663816771 }, "code": { "description": "任务的返回状态", "type": "integer", "example": 0 }, "data": { "description": "返回内容(base64编码)", "type": "string" }, "end": { "description": "任务结束时间", "type": "integer", "example": 1663816771 }, "id": { "description": "任务ID", "type": "string", "example": "20220922-00001-4bc99720760771f6" } } } }, "tags": [ { "description": "agent相关操作接口", "name": "agents" }, { "description": "exec-agent执行命令相关操作接口", "name": "exec" }, { "description": "exec-agent文件处理相关操作接口", "name": "file" }, { "description": "example-agent相关接口", "name": "foo" }, { "description": "服务器端信息相关接口", "name": "info" }, { "description": "编排运行相关接口", "name": "layout" }, { "description": "metrics-agent处理相关接口", "name": "metrics" }, { "description": "脚本运行相关接口", "name": "script" }, { "description": "ipmi相关接口", "name": "ipmi" }, { "description": "snmp相关接口", "name": "snmp" } ] }