monitoring - Icinga:如何通过远程 api 或工具启用维护模式?
问题描述
我正在使用 Icinga 版本 2.4.2 来监控多台主机上的服务。我希望能够使用 cli 工具或 rest API 而不是 Web UI 将某些主机置于维护模式一段时间。
这可能吗?如果可以,我应该使用什么工具/api?如果我不能通过远程工具/api 执行此操作,我应该在服务器或客户端上使用什么命令将客户端置于维护模式?
更新:似乎其余的 api 有一个解决方案。这组权限有效:
object ApiUser "root" {
password = "foobar"
permissions = [ "console", "objects/query/Host", "objects/query/Service", "actions/schedule-downtime", "actions/remove-downtime"]
}
然后以下允许我制作和删除停机时间:
curl -k -s -u root:foobar -H 'Accept: application/json' -X POST "https://localhost:5665/v1/actions/schedule-downtime?filter=host.name==%22${TARGET}%22&type=Host" -d '{ "start_time": "1528239116", "end_time": "1528325561", "duration": 1000, "author": "root", "comment": "downtime on $TARGET" }' | jq .
curl -k -s -u root:foobar -H 'Accept: application/json' -X POST "https://localhost:5665/v1/actions/remove-downtime?filter=host.name==%22${TARGET}%22&type=Host" | jq .
现在我遇到的唯一问题是如何传递开始和停止日期的变量。尝试这样做会导致以下错误:
{
"status": "Invalid request body: Error: lexical error: invalid char in json text.\n { \"start_time\": $current_time,\n (right here) ------^\n\n",
"error": 400
}
解决方案
推荐阅读
- html - 页面外边框但在标题图像顶部
- vue.js - VueJS + Chartjs - 图表仅在代码更改后呈现
- python - 用于检查 Linux 绑定状态的 Python 脚本
- mathematical-optimization - 澄清 SCIP“显示问题”和“写入统计信息”命令中使用的术语
- javascript - 如何使用两个参数进行完全匹配搜索?
- javascript - npm install 失败,弃用 core.js
- powershell - 如何将追加添加到我的 powershell 脚本?
- apache-kafka - 哪些消息应该发布到 Kafka 主题,何时发布?
- c++ - g++ 和 clang++ 与 enable_if 的区别
- php - 如何将编码从 utf8 更改为大端