+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
Thin Client and Virtual Machines Thread, script to shutdown guest & host ESXi in Technical; Hi All, I installed UPS monitoring application on one guest vm and now I want to shutdown all virtual machines ...
  1. #1

    Join Date
    Oct 2010
    Posts
    16
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    script to shutdown guest & host ESXi

    Hi All,

    I installed UPS monitoring application on one guest vm and now I want to shutdown all virtual machines and then host when power goes off or any specific event occurs.
    I installed VMware ESXi 4.0 server as host and different guest VM(Linux,Windows,Unix) on host.Now I want to shutdown all virtual machines which are running on server and then ESXi host.

    So how can I do it.

    Thanks in advance.

  2. #2
    somabc's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    2,337
    Thank Post
    83
    Thanked 388 Times in 258 Posts
    Rep Power
    112
    You can probably use vSphere Command-Line Interface and VMware APIs and SDKs Documentation to script this. Not tried it myself though so sorry I can't be of further help.
    Last edited by somabc; 26th October 2010 at 01:21 PM.

  3. #3

    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,168
    Thank Post
    98
    Thanked 319 Times in 261 Posts
    Blog Entries
    4
    Rep Power
    113
    PowerCLI: Shutdown your Virtual Infrastructure | Virtu-Al might have the answer you're looking for.

  4. #4

    Join Date
    Oct 2010
    Posts
    16
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    I am newbie in VMware and we need not to use vSphere Command-Line Interface or vMA.
    Is there any way that I can fire it from ESXi server?

  5. #5

    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,168
    Thank Post
    98
    Thanked 319 Times in 261 Posts
    Blog Entries
    4
    Rep Power
    113
    Quote Originally Posted by Vanit View Post
    I am newbie in VMware and we need not to use vSphere Command-Line Interface or vMA.
    Is there any way that I can fire it from ESXi server?
    I wouldn't have thought so, no. At least not any supported way I can think of since the Tech Support console isn't meant to be used.

    Can I ask why you're not meant to use the management tools which VMWare recommend?

  6. #6

    Join Date
    Oct 2010
    Posts
    16
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Thanks for reply.
    I have developed it with vMA and able to shutdown as required but now I want to do the same with other option.So please provide me other options which can perform the same task.
    I will appreciate if you can provide me the script also.

  7. #7

    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,168
    Thank Post
    98
    Thanked 319 Times in 261 Posts
    Blog Entries
    4
    Rep Power
    113
    You could use PowerShell, or just about anything else, to directly access the vCenter API if you're using vCenter I suppose.

  8. #8
    somabc's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    2,337
    Thank Post
    83
    Thanked 388 Times in 258 Posts
    Rep Power
    112
    You could turn on the tech support console, turn on SSH, use a script to SSH in and issue a shutdown command?

    VMware KB: ESX 4.0 and ESXi 4.0 shutdown and reboot commands

  9. #9

    Join Date
    Oct 2010
    Posts
    16
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    OK.. Now If I want to monitor the UPS via ESXi server and when power goes off or any event occers then it should do the following things-
    i) shutdown all vm running on ESXi server.
    ii) shutdown ESXi host also.

    How can I achieve it.

  10. #10

    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,168
    Thank Post
    98
    Thanked 319 Times in 261 Posts
    Blog Entries
    4
    Rep Power
    113
    Quote Originally Posted by Vanit View Post
    OK.. Now If I want to monitor the UPS via ESXi server and when power goes off or any event occers then it should do the following things-
    i) shutdown all vm running on ESXi server.
    ii) shutdown ESXi host also.

    How can I achieve it.
    You can't - you need a separate box (or VM) monitoring the UPS and ready to send the commands to ESXi.

    Remember, ESXi doesn't have a kernel, or even an OS, other than a very, very limited tech support console with a scattering of commands which isn't intended to be used to manage the server.

  11. #11

    Join Date
    Oct 2010
    Posts
    16
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    I installed vmware vSphare CLI on guest VM(Windows7) and when I am trying to run--
    vicfg-hostops.pl -a poweroff -o shutdown -d Name of your ESXi server -f
    getting the following error--

    'vicfg-hostops.pl' is not recognized as is not recognized as an internal or external command,operable program or batch file.
    Last edited by Vanit; 27th October 2010 at 02:37 PM.

  12. #12
    somabc's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    2,337
    Thank Post
    83
    Thanked 388 Times in 258 Posts
    Rep Power
    112
    You need to install PERL and make sure perl.exe is in your path and associated with .pl

    ActivePerl is Perl for Windows, Mac, Linux, AIX, HP-UX & Solaris | ActiveState

  13. #13

    Join Date
    Oct 2010
    Posts
    16
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    vSphere CLI installer installs both the vSphere CLI and vSphere SDK for Perl. So I dont think to install active perl externally.
    When I am typing the following command-

    C:\Program Files\VMware\VMware vSphere CLI\Perl\apps>perl -v

    This is perl, v5.8.8 built for MSWin32-x86-multi-thread
    (with 50 registered patches, see perl -V for more detail)
    Copyright 1987-2006, Larry Wall
    and when I am trying to execute other commands like-

    C:\Program Files\VMware\VMware vSphere CLI\bin>esxcfg-nas.pl --server ESXi server address here --list

    it is working fine and I am also able to see this file in bin directory but I didn't found vicfg-hostops.pl file anywhere in the directory.

    Please let me know what is going wrong here and how to resolve it.
    Last edited by Vanit; 28th October 2010 at 09:23 AM.

  14. #14

    Join Date
    Mar 2008
    Location
    Surrey
    Posts
    2,168
    Thank Post
    98
    Thanked 319 Times in 261 Posts
    Blog Entries
    4
    Rep Power
    113
    Might be worth reinstalling, or just doing a search to try and make sure the perl script is in the right path.

  15. #15

    Join Date
    Oct 2010
    Posts
    16
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Thanks a lot for support....As per your suggestion, I reinstall it and now I am able to execute most of the scripts.


    but this is useful for shutting down ESXi server from guest VM which is not my requirement.

    My requirement is to shutdown all guest from ESXi server and then server itself.so how can I make it?
    Last edited by Vanit; 29th October 2010 at 08:06 AM.

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. RUCKUS help - Guest access & the internet via Proxy
    By jamin100 in forum Wireless Networks
    Replies: 24
    Last Post: 15th March 2012, 09:21 AM
  2. Shutdown ESXi Server
    By Hightower in forum Thin Client and Virtual Machines
    Replies: 20
    Last Post: 23rd February 2010, 02:45 PM
  3. Windows Script Host
    By neilmc in forum Windows
    Replies: 2
    Last Post: 30th November 2009, 09:43 AM
  4. Replies: 2
    Last Post: 25th November 2009, 08:58 AM
  5. [Gentoo] x64 windows guest VM on x64 gentoo host
    By RabbieBurns in forum *nix
    Replies: 10
    Last Post: 13th November 2009, 02:23 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •