万一有人想知道我到底用了什么来回答查尔斯·达菲的精彩答案,下面是全文
/usr/lib/check_mk_agent/local/qbittorrent
shell脚本,允许checkmk(1.5.0 raw)获取我认为与在服务器上的专用VM中运行的qBittorrent应用程序(qBittorrent v3.3.7 Web UI)最相关的信息:
#!/bin/sh
curl -s http://localhost:8080/query/transferInfo -o /tmp/transferInfo.json
curl -s http://localhost:8080/query/torrents -o /tmp/torrents.json
if [ -e /tmp/transferInfo.json ]
then
dwl=$(jq .dl_info_speed /tmp/transferInfo.json)
dwl_MB=$(bc <<< "scale=2;$dwl/1048576")
upl=$(jq .up_info_speed /tmp/transferInfo.json)
upl_MB=$(bc <<< "scale=2;$upl/1048576")
echo "0 qbt_Global_speed download=$dwl_MB|upload=$upl_MB Download: $dwl_MB MB/s, Upload: $upl_MB MB/s"
rm -f /tmp/transferInfo.json
else
echo "3 qbt_Global_speed download=0|upload=0 Can't get the information from qBittorrent WebUI API"
fi
if [ -e /tmp/torrents.json ]
then
jq -r '
def filterStates($stateMap):
if $stateMap[.] then $stateMap[.] else . end;
{"queuedDL": "downloading",
"checkingDL": "downloading",
"queuedUP": "uploading",
"checkingUP": "uploading",
"pausedUP": "pause",
"pausedDL": "pause",
"stalledUP": "stalled",
"stalledDL": "stalled",
"metaDL": "stalled"} as $stateMap |
# initialize an output array since we want 0 outputs for everything
{"pause": 0, "stalled": 0, "error": 0, "downloading": 0, "uploading": 0} as $counts |
# count number of items which filter to each value
reduce (.[].state | filterStates($stateMap)) as $state ($counts; .[$state]+=1) |
# output string
"P qbt_Nb_torrents total=\(values|add)|downloading=\(.["downloading"])|seeding=\(.["uploading"])|pause=\(.["pause"])|stalled=\(.["stalled"]);0|error=\(.["error"]);0;0 total is \(values|add), downloading is \(.["downloading"]), seeding is \(.["uploading"]), pause is \(.["pause"])"
' /tmp/torrents.json
rm -f /tmp/torrents.json
else
echo "3 qbt_Nb_torrents total=0|downloading=0|seeding=0|pause=0|stalled=0;0|error=0;0;0 Can't get the information from qBittorrent WebUI API"
fi
以下是1个失速torrent的输出:
0 qbt_Global_speed download=0|upload=0 Download: 0 MB/s, Upload: 0 MB/s
P qbt_Nb_torrents total=1|downloading=0|seeding=0|pause=0|stalled=1;0|error=0;0;0 total is 1, downloading is 0, seeding is 0, pause is 0
这个
errorLevel
我认为我需要的东西(见查尔斯的答案)不是必需的,因为Check-MK是如何工作的;它自己处理阈值
the metric parameter
指定警告和临界值时。
以下是支票中的内容:
注意Check\u MK是如何自动添加暂停和出错的torrents的。这是因为指定了警告和/或临界阈值。一般而言,指标(有或没有阈值)对于提供详细的相关图表非常重要。