VMware Cloud Community
CyberlinkBob
Contributor
Contributor

APC Shutdown using apcuspd not working! Baffled!

Brief Background:

I have a ESXi6.0 server with only one VM on it, Windows 7 x64 with apcupsd installed, UPS is detected, shows status and everything looks to be fine.

I followed a guide here: http://www.pjb.cc/?p=34

I uploaded the script to the datastore, changed the path in my shutdown.sh script to the correct datastore path for logging

Everything appears to work fine except 1 step in the whole process...Plink/Putty

My doshutdown.bat looks like

@echo off

setlocal

set "plinkparms=-v -pw MyPassword -m gus.txt root@10.5.10.101"

plink.exe %plinkparms%

exit /b 0

if I run this from a command prompt it looks like it succeeds so I think Plink is working fine

If I manually putty into the box and issue the command the Plink is issuing then i see this

[root@localhost:~] nohup ./vmfs/volumes/datastore1/Scripts/shutdown.sh &

[1]-  Done(127)                  nohup ./vmfs/volumes/datastore1/Scripts/shutdown.sh

[root@localhost:~] nohup: appending output to nohup.out

But NOTHING happens!!!

If I try typing without the nohup then I get a

[root@localhost:~] ./vmfs/volumes/datastore1/Scripts/shutdown.sh &

[2]-  Done(127)                  nohup ./vmfs/volumes/datastore1/Scripts/shutdown.sh

[root@localhost:~] -sh: ./vmfs/volumes/datastore1/Scripts/shutdown.sh: not found

But it is there

If I cd to the directory, it goes there

If I type shutdown.sh then both my VM and my Server shut down

What am I missing???

I am a total noob to this whole stuff and I am not very good with Linux.  I appreciate greatly any and all help!

Joe

0 Kudos
5 Replies
ArnisR
Enthusiast
Enthusiast

I follow instructions from here - electrical power - VMware ESXi shutdown triggered by APC UPS connected via USB - Server Fault

But slightly modified plink command at stage 8 because in my case depending on VM's shutdown order, ESXi host doesn't correctly shutdown controlling VM or doesn't power off ESXi. I use only poweroff command and it correctly shutdown VMs first (VM or open VM tools installed) and power off ESXi/Server. Didn't test yet with real electricity cut-off.

0 Kudos
CyberlinkBob
Contributor
Contributor

There is a lot of Linux in that solution which is what we are trying to avoid.  The only command line in the solution im trying to use is the plink command being sent to VMware through SSH.  Can anyone help me figure out why the command isn't executing?  I have done +x on the shutdown script but know next to nothing about command line vmware.

0 Kudos
ArnisR
Enthusiast
Enthusiast

Try to use only poweroff command in plink command. As I wrote "shutdown.sh" doesn't work always for me.

I use:

plink root@< your ESXi host IP > -pw yourpassword "/sbin/poweroff"

A

0 Kudos
CyberlinkBob
Contributor
Contributor

This worked, but it did not perform a graceful shutdown of the OS's which is the whole point of this.  It just did a cold poweroff of all the VM's, then shut off the host.  How can I achieve a graceful shutdown using the command line?

0 Kudos
ArnisR
Enthusiast
Enthusiast

Hmm. In my case (HP Microserver Gen8) VMs are correctly shutted down and then the server itself. All VMs must have VM tools installed.

Did You try plink with system's shutdown script? For me it doesn't work correctly, but maybe it will work for You:

plink root@< your ESXi host IP > -pw password "/sbin/shutdown.sh && /sbin/poweroff"

A

0 Kudos