调用监控对象工具
curl --request POST \
--url 'https://api.flashcat.cloud/monit/tools/invoke?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"account_id": 10001,
"target_locator": "web-01",
"tools": [
{
"tool": "os.overview",
"params": {}
},
{
"tool": "net.tcp_ping",
"params": {
"host": "10.0.0.10",
"port": 3306
}
}
]
}
'import requests
url = "https://api.flashcat.cloud/monit/tools/invoke?app_key="
payload = {
"account_id": 10001,
"target_locator": "web-01",
"tools": [
{
"tool": "os.overview",
"params": {}
},
{
"tool": "net.tcp_ping",
"params": {
"host": "10.0.0.10",
"port": 3306
}
}
]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
account_id: 10001,
target_locator: 'web-01',
tools: [
{tool: 'os.overview', params: {}},
{tool: 'net.tcp_ping', params: {host: '10.0.0.10', port: 3306}}
]
})
};
fetch('https://api.flashcat.cloud/monit/tools/invoke?app_key=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.flashcat.cloud/monit/tools/invoke?app_key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'account_id' => 10001,
'target_locator' => 'web-01',
'tools' => [
[
'tool' => 'os.overview',
'params' => [
]
],
[
'tool' => 'net.tcp_ping',
'params' => [
'host' => '10.0.0.10',
'port' => 3306
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.flashcat.cloud/monit/tools/invoke?app_key="
payload := strings.NewReader("{\n \"account_id\": 10001,\n \"target_locator\": \"web-01\",\n \"tools\": [\n {\n \"tool\": \"os.overview\",\n \"params\": {}\n },\n {\n \"tool\": \"net.tcp_ping\",\n \"params\": {\n \"host\": \"10.0.0.10\",\n \"port\": 3306\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.flashcat.cloud/monit/tools/invoke?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"account_id\": 10001,\n \"target_locator\": \"web-01\",\n \"tools\": [\n {\n \"tool\": \"os.overview\",\n \"params\": {}\n },\n {\n \"tool\": \"net.tcp_ping\",\n \"params\": {\n \"host\": \"10.0.0.10\",\n \"port\": 3306\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/tools/invoke?app_key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"account_id\": 10001,\n \"target_locator\": \"web-01\",\n \"tools\": [\n {\n \"tool\": \"os.overview\",\n \"params\": {}\n },\n {\n \"tool\": \"net.tcp_ping\",\n \"params\": {\n \"host\": \"10.0.0.10\",\n \"port\": 3306\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"target": {
"kind": "host",
"locator": "web-01"
},
"results": [
{
"tool": "os.overview",
"params": {},
"tool_version": "0.6.0",
"data": {
"sample_interval_sec": 0.5,
"cpu": {
"cores": 4,
"usage_pct": 32.66,
"user_pct": 28.14,
"system_pct": 3.52,
"iowait_pct": 1.01,
"idle_pct": 67.34
},
"load": {
"load1": 1.79,
"load5": 1.83,
"load15": 1.67,
"runnable_procs": 7,
"total_procs": 1036
}
},
"summary": "os.overview cpu=32.66% mem=74.46% swap=not_configured oom_kill_since_boot=2 load1=1.79"
},
{
"tool": "net.tcp_ping",
"params": {
"host": "10.255.255.1",
"port": 3306
},
"tool_version": "0.1.0",
"error": {
"code": "timeout",
"message": "tool \"net.tcp_ping\" exceeded 8000ms"
}
}
]
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter is not valid."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "Unauthorized",
"message": "You are unauthorized."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "RequestTooFrequently",
"message": "Request too frequently."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InternalError",
"message": "We encountered an internal error, and it has been reported. Please try again later."
}
}诊断分析
调用监控对象工具
在单个监控对象上并发调用至多 8 个 monit-agent 工具。结果按入参 tools 数组顺序返回。长耗时——单个工具在 Agent 上有自己的超时,整体请求可能耗时数十秒。
POST
/
monit
/
tools
/
invoke
调用监控对象工具
curl --request POST \
--url 'https://api.flashcat.cloud/monit/tools/invoke?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"account_id": 10001,
"target_locator": "web-01",
"tools": [
{
"tool": "os.overview",
"params": {}
},
{
"tool": "net.tcp_ping",
"params": {
"host": "10.0.0.10",
"port": 3306
}
}
]
}
'import requests
url = "https://api.flashcat.cloud/monit/tools/invoke?app_key="
payload = {
"account_id": 10001,
"target_locator": "web-01",
"tools": [
{
"tool": "os.overview",
"params": {}
},
{
"tool": "net.tcp_ping",
"params": {
"host": "10.0.0.10",
"port": 3306
}
}
]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
account_id: 10001,
target_locator: 'web-01',
tools: [
{tool: 'os.overview', params: {}},
{tool: 'net.tcp_ping', params: {host: '10.0.0.10', port: 3306}}
]
})
};
fetch('https://api.flashcat.cloud/monit/tools/invoke?app_key=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.flashcat.cloud/monit/tools/invoke?app_key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'account_id' => 10001,
'target_locator' => 'web-01',
'tools' => [
[
'tool' => 'os.overview',
'params' => [
]
],
[
'tool' => 'net.tcp_ping',
'params' => [
'host' => '10.0.0.10',
'port' => 3306
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.flashcat.cloud/monit/tools/invoke?app_key="
payload := strings.NewReader("{\n \"account_id\": 10001,\n \"target_locator\": \"web-01\",\n \"tools\": [\n {\n \"tool\": \"os.overview\",\n \"params\": {}\n },\n {\n \"tool\": \"net.tcp_ping\",\n \"params\": {\n \"host\": \"10.0.0.10\",\n \"port\": 3306\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.flashcat.cloud/monit/tools/invoke?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"account_id\": 10001,\n \"target_locator\": \"web-01\",\n \"tools\": [\n {\n \"tool\": \"os.overview\",\n \"params\": {}\n },\n {\n \"tool\": \"net.tcp_ping\",\n \"params\": {\n \"host\": \"10.0.0.10\",\n \"port\": 3306\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/tools/invoke?app_key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"account_id\": 10001,\n \"target_locator\": \"web-01\",\n \"tools\": [\n {\n \"tool\": \"os.overview\",\n \"params\": {}\n },\n {\n \"tool\": \"net.tcp_ping\",\n \"params\": {\n \"host\": \"10.0.0.10\",\n \"port\": 3306\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"target": {
"kind": "host",
"locator": "web-01"
},
"results": [
{
"tool": "os.overview",
"params": {},
"tool_version": "0.6.0",
"data": {
"sample_interval_sec": 0.5,
"cpu": {
"cores": 4,
"usage_pct": 32.66,
"user_pct": 28.14,
"system_pct": 3.52,
"iowait_pct": 1.01,
"idle_pct": 67.34
},
"load": {
"load1": 1.79,
"load5": 1.83,
"load15": 1.67,
"runnable_procs": 7,
"total_procs": 1036
}
},
"summary": "os.overview cpu=32.66% mem=74.46% swap=not_configured oom_kill_since_boot=2 load1=1.79"
},
{
"tool": "net.tcp_ping",
"params": {
"host": "10.255.255.1",
"port": 3306
},
"tool_version": "0.1.0",
"error": {
"code": "timeout",
"message": "tool \"net.tcp_ping\" exceeded 8000ms"
}
}
]
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter is not valid."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "Unauthorized",
"message": "You are unauthorized."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "RequestTooFrequently",
"message": "Request too frequently."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InternalError",
"message": "We encountered an internal error, and it has been reported. Please try again later."
}
}调用限制
| 项 | 值 |
|---|---|
| 速率限制 | 600 次/分钟;10 次/秒 每账户 |
| 权限 | 任意有效的 app_key(只读;不受特定权限分类约束) |
使用说明
- 单次调用至多 8 个工具(
MaxToolsPerInvoke);超出需在客户端拆分。8 个工具的上限与单监控对象 Agent 的并发能力对齐。 - 工具在 Agent 上并行执行;webapi 返回的
results[]与请求中的tools[]顺序对齐。 - 长耗时:客户端超时至少设置 35 秒。该接口面向 AI-SRE / 人工排障流程,不适用于交互式 UI。
- 请求级错误(
target_unavailable、ambiguous_target_kind、forward_failed)以 HTTP 200 返回,data.error不为空,data.results = []。 - 单工具失败以 HTTP 200 返回,
data.error不输出,results[i].error被填充——务必同时检查三层(外层信封error、data.error、再到每个results[i].error)。 - 响应采用稀疏字段:字段不存在即表示为空。成功时
error直接省略而非返回null;失败时data、summary、truncated均不输出。不要依赖占位的null字段做判断;当 locator 无法唯一解析时,target同样不会出现。 results[i].data是 Tool 的业务数据,monit-agent 的 result envelope 已被解开——不会出现嵌套的data.data。一行摘要位于results[i].summary;results[i].truncated(内含reason)仅在结果确实被截断时出现。results[i].params回显 webapi 收到的该 Tool 调用参数,便于在批量调用中关联结果——即使其中某个 Tool 失败也能对上号。- 按
/monit/tools/catalog返回的input_schema构造tools[].params。对于无参工具,务必显式传params: {}。
授权
在 Flashduty 控制台 账户 → APP Key 中签发的 app_key。调用任何公开 API 时都必须携带。它等同于所属账户的身份凭证,请妥善保管。
请求体
application/json
此页面对您有帮助吗?
⌘I