This commit is contained in:
2023-12-10 14:52:45 -06:00
parent 6171d86562
commit 63ff0751b9
3 changed files with 27 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
VERS='2.4.10-12102023'
VERS='2.4.11-12102023'
noheader=' update service dailytemp '
hc_cw=60

View File

@@ -11,32 +11,32 @@ for VM in $VMS ; do
name=`vim-cmd vmsvc/get.config $VM | grep -i "name =" | awk '{print $3}' | head -1 | cut -d "\"" -f2`
echo "Powered on: $name"
echo "Suspending: $name"
# vim-cmd vmsvc/power.suspend $VM > /dev/null &
vim-cmd vmsvc/power.suspend $VM > /dev/null &
fi
done
# while true ; do
# RUNNING=0
# for VM in $VMS ; do
# PWR=`vim-cmd vmsvc/power.getstate $VM | grep -v "Retrieved runtime info"`
# if [ "$PWR" == "Powered on" ] ; then
# echo "Waiting..."
# RUNNING=1
# fi
# done
# if [ $RUNNING -eq 0 ] ; then
# echo "Gone..."
# break
# fi
# sleep 1
# done
#
# echo "Now we put the Host into maintenance mode..."
# vim-cmd hostsvc/maintenance_mode_enter
#
# echo "Now we suspend the Host..."
# esxcli system shutdown poweroff -d 10 -r "Shell initiated system shutdown"
#
# esxcli system maintenanceMode set -e false -t 0
while true ; do
RUNNING=0
for VM in $VMS ; do
PWR=`vim-cmd vmsvc/power.getstate $VM | grep -v "Retrieved runtime info"`
if [ "$PWR" == "Powered on" ] ; then
echo "Waiting..."
RUNNING=1
fi
done
if [ $RUNNING -eq 0 ] ; then
echo "Gone..."
break
fi
sleep 1
done
echo "Now we put the Host into maintenance mode..."
vim-cmd hostsvc/maintenance_mode_enter
echo "Now we suspend the Host..."
esxcli system shutdown poweroff -d 10 -r "Shell initiated system shutdown"
esxcli system maintenanceMode set -e false -t 0
exit

View File

@@ -116,14 +116,14 @@ $(date)"
touch ${PW_TMPFOLDER}/power.offsite.ac.low.notice
fi
if ([ ${OFFSITE_BATT_CAP%.*} -lt ${SHUTDOWNSERVERS_AT_LOAD} ] || [ $(expr `date +%s` - $(stat -f %m ${PW_TMPFOLDER}/power.offsite.ac.low)) -ge $(echo "scale=2; ${SHUTDOWNSERVERS_AFTER}*60" | bc) ]) && [ ! -f ${PW_TMPFOLDER}/power.offsite.off ]; then
if ([ ${OFFSITE_BATT_CAP%.*} -le ${SHUTDOWNSERVERS_AT_LOAD} ] || [ $(expr `date +%s` - $(stat -f %m ${PW_TMPFOLDER}/power.offsite.ac.low)) -ge $(echo "scale=2; ${SHUTDOWNSERVERS_AFTER}*60" | bc) ]) && [ ! -f ${PW_TMPFOLDER}/power.offsite.off ]; then
echo "($(date +'%Y-%m-%d %H:%M:%S')) - ${OFFSITE_VOLTIN}'volts - ${OFFSITE_BATT_CAP}'% Battery - Powering Down Hosts!" >> ${PW_LOGFILE}
SENDNOTICE "OFFSITE HOST POWER" "Powering DOWN offsite host(s) due to power outage" 1
touch ${PW_TMPFOLDER}/power.offsite.off
for host in ${PW_OFFSITEHOSTS}; do
if [ "$TEST" = "" ] || [ "$TEST" = "full" ]; then
# ssh root@${host} /vmfs/volumes/652c94ef-ee49895b-365d-00109b3fea40/.SCRIPTS/esxi-shutdown2.sh &
ssh root@${host} "sh -s" < ${PW_FOLDER}/esxi-scripts/esxi-shutdown2.sh &
ssh root@${host} sh < ${PW_FOLDER}/esxi-scripts/esxi-shutdown2.sh &
else
echo "TESTMODE: Shutting down '${host}'"
fi