
私は Zabbix とエンタープライズ監視の初心者です。Zabbix 2.4 のインストールを完了しました。
vhosts
さまざまなサーバー上のすべての配置の状態を監視しようとしています。
これまで私が思いついた唯一の解決策は、監視したいWeb scenario
各 Zabbix サーバー ホストに手動で追加することです。しかし、これはあまり便利ではありません。vhost
検索してみると、部分的に機能するアイデアが記載されたフォーラム スレッドが見つかりました: を使用して、template
ターゲット サーバーからすべての をvhosts
( を介してmacro
) 読み取り、Web scenario
各 に対してを作成しますvhost
。
編集: このソリューション (Zabbix 2.2 ベース) は、LLD (Low Level Discovery) を使用できないため機能しませんWeb scenarios
。
そこには機能リクエスト11月14日から実装するためにオープンしていLLD
ますWeb scenarios
。
質問
問題は、機能の実装を待つ間にこの種の監視にどのように取り組むべきかについて何らかの解決策や提案があるかどうか、あるいは私のアプローチが完全に間違っているかどうかです。
答え1
シナリオを作成するために、Zabbix API を使用するスクリプトを使用しました。
#!/bin/bash
read -s -p "Enter AdminAPI password: " password
response=$(curl "http://192.168.0.5:10052/api_jsonrpc.php" -H "Content-Type: application/json-rpc" --data @<(cat <<EOF
{
"jsonrpc": "2.0",
"method": "user.login",
"params": {
"user": "AdminAPI",
"password": "$password"
},
"id": 1,
"auth": null
}
EOF
))
read token id <<<$(echo $response | jq -r '.result, .id')
while read -p "enter quit or an url for a new web scenario" url && [ $url != "quit" ]
do
shorturl=$(echo $url | sed 's:.*//::')
echo ---------
echo $token
echo $url
echo $shorturl
echo ---------
# the hostid is visible when you are on the host page on the zabbix interface
#le hostid est visible dans l'url de de la page du host sur zabbix ici bunsrv
curl "http://192.168.0.5:10052/api_jsonrpc.php" -H "Content-Type: application/json-rpc" --data @<(cat <<EOF
{
"jsonrpc": "2.0",
"method": "httptest.create",
"params": {
"name": "$shorturl",
"hostid": "10120",
"steps": [
{
"name": "Homepage",
"url": "$url",
"status_codes": 200,
"no": 1
}
]
},
"auth": "$token",
"id": $id
}
EOF
)
done
トリガーの場合:
curl "http://192.168.0.5:10052/api_jsonrpc.php" -H "Content-Type: application/json-rpc" --data @<(cat <<EOF
{
"jsonrpc": "2.0",
"method": "trigger.create",
"params": [
{
"description": "Web scenario $shorturl failed: {ITEM.VALUE} from {HOST.NAME}",
"expression": "{BUNSRV:web.test.fail[$shorturl].last()}<>0 and {BUNSRV:web.test.error[$shorturl].strlen()}>0",
"priority": "2"
}
],
"auth": "$token",
"id": $id
}
EOF
)
done
答え2
ここおそらく役に立つスクリプトです。このスクリプトは URL を含むリストを読み取り、Zabbix データベースに直接 Web シナリオを作成します。