8

We just picked up a new development server that I've loaded ESXi on.

The room it's in is well ventilated during the day but at night the door is closed and it gets quite toasty in there. I've been asked to have the box shut down nightly, as we won't be using it anyways when we're not in the office.

Is there a way to do this?

3
  • You can use a cron job to shut down the server, but how will you boot it again in the next day!?
    – Khaled
    Dec 23, 2011 at 14:58
  • @Khaled: Some BIOS implementations can schedule automatic power-on.
    – pauska
    Dec 23, 2011 at 15:04
  • 1
    @Khaled Manual booting would be fine. It's a lot easier to remember to turn it on (we can't do any work with it off) than it is to turn it off at the end of a long day!
    – ceejayoz
    Dec 23, 2011 at 15:06

6 Answers 6

9

I'd personally let the server run or move it to a better running environment. This may not be worth automating.

If you must shut down the entire host, please make sure that your VMs have the VMWare tools installed (to allow graceful shutdown and power up) and that they're set to stop and start with the host.

You can use the vCli and schedule a cron job to place the host in maintenance mode and/or shut down the host entirely. I would probably just manually run the host shutdown command from the GUI client at the end of the day, though.

2
  • Quick side question: I know home VM solutions like virtual box give the option to just save the machine state and boot to that state later. Would this be possible or better with ESXi?
    – TheLQ
    Dec 28, 2011 at 19:48
  • Yep. You can pause/suspend VMs in vSphere/ESXi. In the context of this question, this could be scheduled as well.
    – ewwhite
    Dec 29, 2011 at 2:02
3

Before auto shutdown you should look at the host power settings and adjust them acordingly. See https://www.vmware.com/files/pdf/techpaper/hpm-performance-vsphere55-white-paper.pdf powercycling (and also thermalcycling from what you say) will reduce the lifespan of the server

2

vCli has already been mentioned and it is a best way to go in my opion.
However it seems you are dealing with a bigger problem , i.e overheating server room.This needs to be dealt with on a correct level.Fix HVAC asap or you will damage your equipment eventually.Read on http://www.openxtra.co.uk/articles/skimp-server-room-ac

1
  • 2
    It's a single server in our back room. Landlord's not going to install AC there, and it's a perfectly fine temperature (server temp averages 26 degrees C, fans at minimum) with the door open. We just like to leave the room locked when we're all out of the office, but it gets warm in the winter as the thermostat is in another room. That article refers to 60, 100, 200 node server rooms. We've got one, and it can be turned off when the door is shut. All of our production servers are in a proper datacenter.
    – ceejayoz
    Dec 24, 2011 at 17:37
0

You can power it on by LAN. If you have such option in ESXi's BIOS (Usually Wake On LAN option). So you can add schedule in another machine to wake up your ESXi. And do not forget configure auto start your VMs when ESXi starting. Some times BIOSes have schedule option for power on machine.

You can use VMware Distributed Power Management (DPM) for power saving.

2
  • I'm looking to power off, not save money or wake up.
    – ceejayoz
    Dec 27, 2011 at 1:41
  • Usually people like to automate all things. May be somebody will help you with shuting down your ESX. So you'll have complete solution.
    – BBK
    Dec 27, 2011 at 9:12
0

You can enable ssh server on ESXi and copy your ssh key to the server, read the following on how to do that: Monitor LSI 3ware raid controller on ESXi

Then to shutdown the virtual machines and power off the ESXi server I would schedule a cronjob on a remote physical server:

20 9    12 22 * root    ssh 10.1.1.140 /sbin/shutdown.sh
30 9    12 22 * root    ssh 10.1.1.140 /sbin/poweroff

In this case shutdown the virtual machines at Dec. 22, 9:20 AM and power down the ESXi server at Dec. 22, 9:30 AM.

The /sbin/shutdown.sh file is a script that cleanly shuts down the virtual machines and it comes with the ESXi instance. The poweroff command is just "busybox poweroff".

0

If you have python running you can use the script I wrote below to wake up and shutdown your ESXi server. I have a Dell R810 at home that I use as my Cisco VIRL Server and other things but i only power it up when I need it. It is downstairs so i wanted a way that i could start it and stop it from upstairs. I have enabled Wake On Lan on the primary NIC on the server (CTRL-S as it is booting and enable for your primary NIC). In vSphere set your VMs to start and stop with the server as this script will shutdown your VMs and power off the server. Enable ssh for your ESXi server, enter the MAC of the primary NIC, and change the root password, server ip, and path to python below.

python esxi.py -w Will Wake the server by sending the WOL magic packet. python esxi.py -s will shutdown your VMs and power-off your server.

Dependencies

paramiko wakeonlan argparse

####################Start Script
#!/home/mikepartain/scripts/esxi/bin/python

from wakeonlan import wol
import time, argparse, paramiko


parser = argparse.ArgumentParser()
parser.add_argument('-w', action='store_true', dest='wakeup')
parser.add_argument('-s', action='store_true', dest='shutdown')
args = parser.parse_args()


if args.wakeup:
    print 'Waking up ESXI Server'
    wol.send_magic_packet('f0.4d.a2.aa.aa.aa')

if args.shutdown:
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect('192.168.178.10', username='root', password='#PASSWORD#')
    stdin, stdout, stderr = ssh.exec_command('powerOffVms && halt')
    print 'Shutting down ESXi Server'
    ssh.close()


####################END Script

If this works for you, or if you have a way to improve it, please let me know!

Mike Partain

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .