4 Replies Latest reply on Nov 21, 2016 7:54 AM by jseide86

    Need powercli script to stop smartd daemon service on morethan 50 ESXi6.0 hosts

    swamynaveen Novice

      Issue Discription:

      ================

      • ESXi hosts appear as Not Responding in vCenter Server.
      • Running esxcli commands on the ESXi host fail with the error:

        Error interacting with configuration file /etc/vmware/lunTimestamps.log: Timeout while waiting for lock, /etc/vmware/lunTimestamps.log.LOCK, to be released. Another process has kept this file locked for more than 30 seconds. The process currently holding the lock is smartd(PID). This is likely a temporary condition. Please try your operation again.

        Note: PID is the process ID for the smartd service.

      • In the /var/log/hostd.log file, you see entries similar to:

        Error interacting with configuration file /etc/vmware/lunTimestamps.log: Timeout while waiting for lock, /etc/vmware/lunTimestamps.log.LOCK, to be released. Another process has kept this file locked for more than 30 seconds. The process currently holding the lock is smartd(PID). This is likely a temporary condition. Please try your operation again.

      Workaround:

      ===========

      Need to stop smartd daemon service on ESXi 6.0 host

        • 1. Re: Need powercli script to stop smartd daemon service on morethan 50 ESXi6.0 hosts
          LucD Guru
          User ModeratorsCommunity WarriorsvExpert

          You will need to use the plink.exe command from the PuTTY Suite

          The script will check if the SSH service is running, if not, it will start it, and also stop it after the smartd service has been stopped.

          .

          Something like this

           

          $user = <user>

          $pswd = <password>

           

          $plink = "<PuTTY dir>\plink.exe"

          $plinkoptions = " -batch -pw $pswd"

          $cmd = 'etc/init.d/smartd stop'

          $remoteCommand = '"' + $cmd + '"'

           

          Get-VMHost | %{

              $ssh =Get-VMHostService -VMHost $_ | where{$_.Key -eq 'TSM-SSH'}

              if(!$ssh.Running){

                  Start-VMHostService -HostService $ssh -Confirm:$false > $null

              }

             

              $command = $plink + " " + $plinkoptions + " " + $User + "@" + $_.Name + " " + $remoteCommand

             

              Invoke-Expression -command $command

             

              if(!$ssh.Running){

                  Stop-VMHostService -HostService $ssh -Confirm:$false > $null

              }

          }

           

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: Need powercli script to stop smartd daemon service on morethan 50 ESXi6.0 hosts
            swamynaveen Novice

            thanks a lot Luc for prompt respons. I'll execute below script and let u know the status.

            POst this change wanna pull the host report in orderto make sure that   Smartd service status should be in stop. Could u pls help on this as well.

             

            Thanks in Advance!!!

             

            Best Regards,

            SWamy Naveen.

            • 3. Re: Need powercli script to stop smartd daemon service on morethan 50 ESXi6.0 hosts
              LucD Guru
              Community WarriorsvExpertUser Moderators

              The smartd service is not included in the ones returned by Get-VMHostService, so you will have to use the plink.exe again.

              Replace the command by

               

              $cmd = 'etc/init.d/smartd status'

               

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              • 4. Re: Need powercli script to stop smartd daemon service on morethan 50 ESXi6.0 hosts
                jseide86 Novice

                Here's a script that logs in to your hosts in the specified cluster, disabled the smartd service and stops the service from starting again on next reboot (as per ESXi 6.0 host is disconnected from vCenter Server (2145106) | VMware KB)

                 

                Loosely based on LucD's script:

                 

                $user = 'yourlogin'
                $pswd = 'yourpassword'
                
                $cmd = 'etc/init.d/smartd stop'
                $cmd2 = 'chkconfig smartd off'
                
                Get-Cluster -Name yourclustername | Get-VMHost | %{
                    $ssh =Get-VMHostService -VMHost $_ | where{$_.Key -eq 'TSM-SSH'}
                    if(!$ssh.Running){
                        Start-VMHostService -HostService $ssh -Confirm:$false > $null
                    }
                
                    Write-host "Running remote SSH commands on $($_.Name)." -ForegroundColor Yellow
                    Echo Y | ./plink.exe $_.Name -pw $pswd -l $user $cmd
                    Echo Y | ./plink.exe $_.Name -pw $pswd -l $user $cmd2
                
                    if(!$ssh.Running){
                        Stop-VMHostService -HostService $ssh -Confirm:$false > $null
                    }
                }