Automation

 View Only
Expand all | Collapse all

Script to check prerequisite to unmount datastores: CoreDump

LucD

LucDMar 31, 2022 02:56 PMBest Answer

  • 1.  Script to check prerequisite to unmount datastores: CoreDump

    Posted Mar 31, 2022 01:16 PM

    Hello,

    I found this link:  Script of LucD done by LucD.

    I need some help to add a new verification concerning coredump in this same script. By default the folder is vmkdump on datastore but maybe the name could be modify. So I'm sure that this function is accurate for example.

    # No CoreDump partition
    No_CoreDump_Partition = &{
    New-PSDrive -Location $ds -Name ds -PSProvider VimDatastore -Root '\' | Out-Null
    $result = Get-ChildItem -Path ds:\ -Recurse |
    where {$_.Name -match 'vmkdump'}
    Remove-PSDrive -Name ds -Confirm:$false
    if($result){$false}else{$true}

    If someone can help me on an other approach to insert in this existing script?

    regards,
    David



  • 2.  RE: Script to check prerequisite to unmount datastores: CoreDump
    Best Answer

    Posted Mar 31, 2022 02:56 PM

    Try with this version



  • 3.  RE: Script to check prerequisite to unmount datastores: CoreDump

    Posted Mar 31, 2022 03:27 PM

    Hello LucD

    If I understand, your proposition verify if there is a coredump is set on ESXi right?

    # No vmkdump
    NoVmkDumpFolder = &{
    $url = $ds.ExtensionData.Summary.Url.Replace('ds://','')
    $result = Get-VMHost -Datastore $ds -PipelineVariable esx |
    ForEach-Object -Process {
    $esxcli = Get-EsxCli -VMHost $esx -V2
    $esxcli.system.coredump.file.list.Invoke() | where{$_.Active -and $_.Path -match $url}
    }
    if($result){$false}else{$true}
    }

     

    My request is to verify the existance of coredump file and folder on datastore vmfs. I have configured this:

    # No CoreDump partition
    No_CoreDump_Partition = &{
      New-PSDrive -Location $ds -Name ds -PSProvider VimDatastore -Root '\' | Out-Null
      $result = Get-ChildItem -Path ds:\ -Recurse |
      where {$_.Name -match 'vmkdump' -or $_.Name -like '*.dumpfile'}
      Remove-PSDrive -Name ds -Confirm:$false
      if($result){$false}else{$true}
    }

    Can you explain what is the difference between these 2 propositions.

    regards,

    David



  • 4.  RE: Script to check prerequisite to unmount datastores: CoreDump

    Posted Mar 31, 2022 03:57 PM

    My code checks on all ESXi nodes that have the Datastore configured if there is an "active" dump.



  • 5.  RE: Script to check prerequisite to unmount datastores: CoreDump

    Posted Apr 01, 2022 06:06 AM

    If I understand your code check if an active dump exist between all ESXi nodes and a Datastore so if there is a configuration between them.

    I request your opinion what is the best or accurate between these 2 codes for you: one check existence of folder and files on datastore and one check if there is an active dump configure between ESXi servers and Datstore? Maybe use both?

    For you information, I check prerequisites including these codes in particular before to remove and detach Datastore from ESXi.

    regards,
    David



  • 6.  RE: Script to check prerequisite to unmount datastores: CoreDump

    Posted Apr 01, 2022 06:11 AM

    Depends on what you want to achieve.

    To check if there is a folder, and dump file, on the datastore, active or not active, might be useful when you want to first check if that dump should be safeguarded before removing the datastore.

    To check if there is an active dump file avoids having an issue with unmounting the datastore.




  • 7.  RE: Script to check prerequisite to unmount datastores: CoreDump

    Posted Apr 01, 2022 06:22 AM

    OK LucD

    Regarding your script Get-DatastoreUnmountStatus which is very good, I have a point I export in csv file:

    How I can set a specify order of column for Datastore, NoVM, NoDastoreClusterMember, NosDRS, NoSIOC, NoHAheartbeat, NovdSwFile, NoScratchPartition. Currently, if I rename one of them inside the script the order of column change randomly without sens and no alphabetical order. The column name of datastore are the lastest column and I prefer that it's first column for example.


    regards,
    David



  • 8.  RE: Script to check prerequisite to unmount datastores: CoreDump

    Posted Apr 01, 2022 06:29 AM

    The code above contains

    which should make the order fixed.



  • 9.  RE: Script to check prerequisite to unmount datastores: CoreDump

    Posted Apr 01, 2022 06:55 AM

    OK - This add-on code resolve the point to put the column name of datastore in first column in csv file.

    But the rest of NoVM, NoDastoreClusterMember, NosDRS, NoSIOC, NoHAheartbeat, NovdSwFile, NoScratchPartition are not order but nevermind it's design.

     

    Last point:

    The check Datastore Hearbeat is based on which of these 3 options ?
    - Automatically select datastores accessible from the hosts (normaly is the default option on ESXi cluster)
    - Use datastores only from the specified list
    - Use datastores from the specified list and complement automatically if needed
    Or other points ?
    Because I have a datastore which for that point NoHAheartbeat is "False" but there is nothing particular it's default option regarding the other datastores with the result "True"

     

    regards,

    David



  • 10.  RE: Script to check prerequisite to unmount datastores: CoreDump

    Posted Apr 01, 2022 07:22 AM

    Afaik, the RetrieveDasAdvancedRuntimeInfo method returns the used datastore(s), independent of which datastore selection method is defined. 



  • 11.  RE: Script to check prerequisite to unmount datastores: CoreDump

    Posted Apr 01, 2022 07:25 AM

    Ok LucD

    When I use your code, the execution is more longer but it's maybe normal because each ESXi servers is check multiply by number of datastore.

    # No vmkdump
    NoVmkDumpFolder = &{
    $url = $ds.ExtensionData.Summary.Url.Replace('ds://','')
    $result = Get-VMHost -Datastore $ds -PipelineVariable esx |
    ForEach-Object -Process {
    $esxcli = Get-EsxCli -VMHost $esx -V2
    $esxcli.system.coredump.file.list.Invoke() | where{$_.Active -and $_.Path -match $url}
    }
    if($result){$false}else{$true}
    }

    The incident that I have this message in powerCLI window : "WARNING: PowerCLI scripts should not use the 'DatastoreIdList' property of VMHost type. The property will be removed in a futur release."

    The prompt is stuck and not give back hand automaticaly whereas the csv file is already created. I need to Ctrl + C to stop and give back hand for the prompt

     

    regards,

    David

     



  • 12.  RE: Script to check prerequisite to unmount datastores: CoreDump

    Posted Apr 01, 2022 11:32 AM

    That is but a warning, and can safely be ignored.
    If you want to avoid those type of warnings, use the Set-PowerCLIConfiguration cmdlet and set the DisplayDeprecationWarnings to $false for all scopes.

    The script works perfectly for me.
    No hang at the end.
    Is one of the ESXi nodes on which the datastore is known perhaps powered off?

    The columns are exported in the order defined in the New-Object statement.
    I have no clue why that wouldn't work for you.



  • 13.  RE: Script to check prerequisite to unmount datastores: CoreDump

    Posted Apr 01, 2022 01:23 PM

    Hello LucD,

     

    It's OK.

     

    This part is long to execute to the end - that's all. I need to be patient. The execution time depends of number of ESXi servers and datastores.

    # No vmkdump
    NoVmkDumpFolder = &{
    $url = $ds.ExtensionData.Summary.Url.Replace('ds://','')
    $result = Get-VMHost -Datastore $ds -PipelineVariable esx |
    ForEach-Object -Process {
    $esxcli = Get-EsxCli -VMHost $esx -V2
    $esxcli.system.coredump.file.list.Invoke() | where{$_.Active -and $_.Path -match $url}
    }
    if($result){$false}else{$true}
    }

     

    Thanks a lot for your support on that subject. Your scripts are accurate and helpful to manage Vmware environement.

    Regard,

    David

     



  • 14.  RE: Script to check prerequisite to unmount datastores: CoreDump

    Posted Apr 01, 2022 01:26 PM

    And another one where your reply is the solution 



  • 15.  RE: Script to check prerequisite to unmount datastores: CoreDump

    Posted Apr 01, 2022 01:38 PM

    Sorry LucD you right. It's more accurate to your proposition.

    I corrected to your post.