11 Replies Latest reply on Jan 18, 2012 11:00 PM by azaveri

    VMWARE Tools Status

    timcwhite Enthusiast

       

      Good morning,

       

       

      I am currently running ESX 3.0.2. We are also running VCB. I have noticed that the vmtools status for some virtual machines in Virtual Center shows that the tools aren't running. It also shows that the VM doesn't have an ipaddress assigned to it when it actually does. When this happens, our VCB backup fails because it can't poll Virtual Center for an IP Address. When I check the VM to see if the tools are actually installed, it shows that they are.

       

       

      Question

       

       

      Is there a way to set up an alarm within virtual center that will alert me when the tools status shows not running in Virtual Center?

       

       

       

       

       

        • 1. Re: VMWARE Tools Status
          kjb007 Guru

           

          There is an alarm for tools status, and you can use that.

           

           

           

           

           

          If your tools are incorrectly reporting the status, I would uninstall, and reinstall the tools.  This should fix most issues with the tools service.

           

           

           

           

           

          -KjB

           

           

          • 2. Re: VMWARE Tools Status
            Jasemccarty Champion
            VMware EmployeesvExpert

            I don't think there is one for the tools status, but I have one for the Heartbeat that seems to do the trick for me.

             

            When the Heartbeat acts up, I have it fire off a VBS that remotely restarts the VMware Tools.

             

            Here's the VBS:

             

             

                 Set objSWbemLocator = CreateObject("WBemScripting.SWbemLocator")
                            set objWMIService = objSWbemLocator.ConnectServer (Wscript.Arguments(0), "root\cimv2", "DOMAIN\Username", Wscript.Arguments(1))
                            Set colServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name = 'vmtools'")
                            For Each objService in colServices
                        errReturnCode = objService.StopService()
                            Next

                 Wscript.Sleep 20000
                            For Each objService in colServices
                                  errReturnCode = objService.StartService()
                            Next

            And the alarm looks like this:

             
                            cscript.exe c:\scripts\restarttools.vbs

            1. cscript is the engine for the VBS,
            2. c:\scripts\restarttools.vbs is the VBS that does the work
            Password So, that being said, is the name of the VM (which matches the NetBios name of the guest

            1. The password for the domain account that has rights to restart the service

             

            That seems to keep me out of trouble when the tools crap out.

             

             

            When there is a Heartbeat issue, the script simply restarts the tools.  And typically, within a minute, the error is cleared up.

             

             

             

            Jase McCarty

            http://www.jasemccarty.com

            Co-Author of VMware ESX Essentials in the Virtual Data Center

            (ISBN:1420070274) from Auerbach

            • 3. Re: VMWARE Tools Status
              Karunakar Hot Shot

               

              HI,

               

               

              The vmware tools shows this behaviour some times if the vmware tools are updated in the VM, and if the tools does not give any heartbeat to the ESX or VC.

               

               

              There is no alarm in VC to check if the tools are running are not, but you can get some information from the alarm which sends information of the state of the VM.

               

               

              Try to refresh the tools in VM, or restart the vmware tools service, then it comes back to normal.

               

               

              -Karunakar

               

               

              • 4. Re: VMWARE Tools Status
                kjb007 Guru

                 

                You are correct.  Since the heartbeat status is actually talking and retrieving information from the VMware tools, I incorrectly referred to it as the tools status alarm.  The script is helpful as well.

                 

                 

                 

                 

                 

                -KjB

                 

                 

                • 5. Re: VMWARE Tools Status
                  timcwhite Enthusiast

                  Thanks for your help.
                  I need a little hand holding on this one. I assume the only values that need to change in the text below are  "DOMAIN\Username", where Domain=My company and Username =an account with priveledges to restart the service.
                  Is there anything else that I need to change in the script below?
                  Set objSWbemLocator = CreateObject("WBemScripting.SWbemLocator")
                       set objWMIService = objSWbemLocator.ConnectServer (Wscript.Arguments(0), "root\cimv2", "DOMAIN\Username", Wscript.Arguments(1))
                       Set colServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name = 'vmtools'")
                       For Each objService in colServices
                       errReturnCode = objService.StopService()
                       Next

                  Wscript.Sleep 20000
                       For Each objService in colServices
                       errReturnCode = objService.StartService()
                       Next
                  I created the heartbeat alarm and set the following:
                  Trigger Type = Virtual machine Heartbeat
                  Condition = Is equal to
                  Warning = Intermittent
                  Alert = No Heartbeat
                  Under the Actions tab I set the following:
                  Action = Run a script
                  Value = cscript.exe c:\scripts\restarttools.vbs Password
                  What should I enter as the targetName and what password is the script looking for.
                  Thanks for you help!!!!!

                   

                  • 6. Re: VMWARE Tools Status
                    Jasemccarty Champion
                    vExpertVMware Employees

                    In my environment, DOMAIN\Username is a domain account in my AD environment that has administrative rights on my Windows systems.

                     

                    That's the only change in the script you need.

                     

                    The is a VirtualCenter variable that is sent to the script. That being said, if the alert fires for a VM named TESTVM and the account password being "P@ssw0rd", then the script executed would be: cscript.exe c:\scripts\restarttools.vbs TESTVM P@ssw0rd In this case: gets put into Wscript.Arguments(0) (VirtualCenter passes the name of the VM into this value)

                    P@ssw0rd gets put into Wscript.Arguments(1)

                     

                    Additionally, if you modify the script to read like this (with added documentation)

                     

                    'Some Windows WMI Stuff

                    Set objSWbemLocator = CreateObject("WBemScripting.SWbemLocator")

                     

                    'Connect to the WMI service on box with DOMAN\User and P@ssw0rd credentials set objWMIService = objSWbemLocator.ConnectServer  (Wscript.Arguments(0), "root\cimv2", Wscript.Arguments(1), Wscript.Arguments(2))  'Changed line ' List all the services named "vmtools" Should only be one Set colServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name = 'vmtools'") 'Loop through the returned services, and attempt to stop them. For Each objService in colServices errReturnCode = objService.StopService() Next ' Wait 2 Seconds Wscript.Sleep 20000 'Loop through the returned services again, and attempt to start them. For Each objService in colServices errReturnCode = objService.StartService() Next Then your alarm could run this instead: *cscript.exe c:\scripts\restarttools.vbs DOMAIN\Username P@ssw0rd*

                     

                    In this case:

                    gets put into Wscript.Arguments(0) (VirtualCenter passes the name of the VM into this value)

                    DOMAIN\Username gets put into Wscript.Arguments(1)

                    P@ssw0rd gets put into Wscript.Arguments(2)

                     

                    Hope that helps you out.

                     

                    And feel free to award points for helpful posts/replies.

                     

                    Jase

                    • 7. Re: VMWARE Tools Status
                      timcwhite Enthusiast

                       

                      Ok this helps.

                       

                       

                      I tried testing the script along with the alarm by manualy stopping the tools on a windows 2003 server. I received an email advising me that the tools status changed from Green to Red but virtual center still shows that it is running ok, eventhough the service is down on the server. The script didn't restart the service.

                       

                       

                       

                       

                       

                      Can I test the script directly on the server? I created a scripts folder at c:scripts and dumped the .vbs file in that folder called restarttools. I then opened a command prompt and ran the following:

                       

                       

                      c:\scripts>cscript.exe  restarttools.vbs "password of my account"

                       

                       

                      it returned an error: Microsoft VBscript runtime error: Subscript out of range

                       

                       

                      Any ideas?

                       

                       

                       

                       

                       

                       

                       

                       

                      • 8. Re: VMWARE Tools Status
                        Jasemccarty Champion
                        vExpertVMware Employees

                        Unfortunately, I found that stopping the tools didn't automatically trigger the alarm.

                         

                        But I can run the script from a cmd prompt.

                         

                        And the reason that you got a subscript out of range, is because you are missing the name of the VM.

                         

                         

                         

                        cscript.exe c:\scripts\restarttools.vbs VMNAME Password is how is should read

                         

                         

                         

                        If you run it from a cmd prompt, while having the VM's console open, you will see the tools stop and then restart.  This is signified by the tools icon changing in the system tray.

                         

                         

                         

                        Jase McCarty

                        http://www.jasemccarty.com

                        Co-Author of VMware ESX Essentials in the Virtual Data Center

                        (ISBN:1420070274) from Auerbach

                        • 9. Re: VMWARE Tools Status
                          timcwhite Enthusiast

                           

                          YES!! It worked!

                           

                           

                           

                           

                           

                          Jase, thank you for your patience and time. I can now check this off my "to do" list. If you have any other scripts that may help make my VM life easier please pass them on.

                           

                           

                           

                           

                           

                          Again thanks again for your help.

                           

                           

                          Tim

                           

                           

                          • 10. Re: VMWARE Tools Status
                            Jasemccarty Champion
                            VMware EmployeesvExpert

                            Glad to help...

                             

                            There are tons of scripts out there for these types of things...  Every so often I post some of them to my site.

                             

                             

                             

                            Oh, and I take Paypal...

                             

                             

                            And thanks for the points!

                             

                             

                            Jase McCarty

                            http://www.jasemccarty.com

                            Co-Author of VMware ESX Essentials in the Virtual Data Center

                            (ISBN:1420070274) from Auerbach

                            • 11. Re: VMWARE Tools Status
                              azaveri Lurker

                              Hi Jase,

                               

                              After stopping VMware Tools service in the virtual machine, i got the trigger 'No heart beat' and alarm was successfully triggered.

                               

                              Please let me know if I set to trigger the alarm for VM heartbeat trigger state equal to 'Intermittent heartbeat', then how can it be generated?