【vSphere】アラーム環境変数

アラーム環境変数とは

vCenterにおけるアラームは以下の変数を用いてスクリプトへ渡すことができる

※出典

https://docs.vmware.com/jp/VMware-vSphere/6.5/com.vmware.vsphere.monitoring.doc/GUID-B8DF4E10-89E3-409D-9111-AE405B7E5D2E.html

アラーム環境変数の利用例

・アラーム設定

デフォルトで定義されている「ホストの接続と電源状態」にて、"/root/test.sh {targetName}"を実行するように設定

スクリプト

#!/bin/bash
SERVER=$1

echo "echo "`date "+%Y-%m-%d %H:%M:%S" ` $SERVER" disconnected" >> /tmp/out.txt

・出力

# cat /tmp/out.txt
echo 2023-11-16 03:05:03 24-esxi-03.env.lab disconnected

・各種変数の出力例

・eventDescription
Alarm Host connection and power state on

・targetName
24-esxi-03.env.lab

・alarmName
changed from Green to Red 24-esxi-03.env.lab alarm.HostConnectionStateAlarm

・triggeringSummary
State is equal to Not responding AND State is equal to Unknown

・declaringSummary
(([Red state Is equal to notResponding] AND [Red state Not equal to standBy]))

・oldStatus
Normal

・newStatus
Critical

・target
HostSystem:host-18