We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f396f38 commit bc23387Copy full SHA for bc23387
esxi-power-off-vms-without-tools.sh
@@ -5,16 +5,14 @@ GRACE_PERIOD=3600
5
6
for VMID in `vim-cmd vmsvc/getallvms | awk '{ if (NR > 1) print $1 }'`
7
do
8
- vim-cmd vmsvc/power.getstate $VMID
9
-
10
ON=`vim-cmd vmsvc/power.getstate $VMID | grep "Powered on" || EXIT=$?`
11
if [[ -n "$ON" ]]; then
12
HB=`vim-cmd vmsvc/get.guestheartbeatStatus $VMID`
13
if [ "$HB" != "green" ]; then
14
- UPTIME=`vim-cmd vmsvc/get.summary 259 | sed -rn 's/\ +uptimeSeconds\ =\ ([0-9]+),\ +/\1/p'`
+ UPTIME=`vim-cmd vmsvc/get.summary $VMID | sed -rn 's/\ +uptimeSeconds\ =\ ([0-9]+),\ +/\1/p'`
15
if [ "$UPTIME" -gt "$GRACE_PERIOD" ]; then
16
echo "Powering off VM: $VMID"
17
- vim-cmd vmsvc/power.off $VMID
+ vim-cmd vmsvc/power.off $VMID > /dev/null
18
fi
19
20
0 commit comments