• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

ESXi: Script to restart VM

wroopy

n00b
Joined
Nov 4, 2011
Messages
9
I have a VM that occasionally stops responding. To get it to work again I need to restart the VM. Until I've figured out why th VM stop responding I need a workaround.

I'm thinking of running a script on the ESXi 5 server that checks if Vmware Tools is responding. If it doesn't respond I wont to poweroff the VM and start it again.

How could a script look like that does what I want?
 
I don't think you'd run the script on the hypervisor itself. I'd install VMA appliance and run it there. If you google for VMA you can find docs on the various commands you can run on the hypervisor remotely.
 
You can easily make a script that runs on the hypervisor itself that starts/restarts a VM if you enable SSH, know shell scripting, and know how to use the console versions of the VMWare commands.
 
either or would work. you can check tools HB, but depending on what dies in the guest, tools may still be responding... hard to say.
 
I know that tools doesn't respond.

The problem is that I don't know the console version of VMWare commands. Is there any good guides/documentation?

I guess that I could use vim-cmd or vsish.
 
After some reserach on commands I created the script below. There are probably bether ways of doing it, but hopefully it would meet my needs.

Code:
#!/bin/sh

ID=`vim-cmd vmsvc/getallvms|grep $1|cut -d\  -f1`

if [ ! `vim-cmd vmsvc/get.guest $ID|grep toolsStatus|cut -d\" -f2` = toolsOk ]; then
        if [ "$2" = "RESTART" ]; then
                vim-cmd vmsvc/power.off $ID
                sleep 5
                vim-cmd vmsvc/power.on $ID
        else
                sleep 30
                $0 $1 RESTART
        fi
fi
 
Stop tools service and test ;) Why does the VM stop responding might be better question, is it an issue inside the os?
 
I think the problem is that I have passthrough a DVB-card to the client and sometimes I get a " irq 9: nobody cared (try booting with the "irqpoll" option)" and I think that the error is related to that device. Sometimes when I get the error the kernel coredumps and the host stops responding.

I've now added "noacpi irqpoll" to bootline and hopes that it would help.
 
Back
Top