VMware Cloud Community
bansne
Enthusiast
Enthusiast
Jump to solution

Get /tmp details for all esxi

Hi,

I found out this thread Free INODES and % free RAMDISK  with exactly what I was looking for.

However, I want export that will list details of only ESXi with more than 50% memory been used under /tmp directory. eq to 100 or maybe greater than 50%.

foreach($esxi in (Get-VMHost)){

    $esxcli = Get-EsxCli -vmhost $esxi

    $details +=(

        $esxcli.system.visorfs.get() |

         if ($details | where {$_.'Ramdisk Name' -eq "tmp"}) -eq 100){ write-output $esxi.name}

}

     

LucD

Regards

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could do something like this

$report = @()

foreach($esxi in (Get-VMHost)){

    $esxcli = Get-EsxCli -VMHost $esxi -V2

    $report += $esxcli.system.visorfs.ramdisk.list.Invoke() |

    where{$_.RamDiskName -eq 'tmp' -and [int]$_.Free -lt 100} |

    Add-Member -Name VMHost -Value $esxcli.VMHost.Name -MemberType NoteProperty -PassThru

}

$report | Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture

   


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

You could do something like this

$report = @()

foreach($esxi in (Get-VMHost)){

    $esxcli = Get-EsxCli -VMHost $esxi -V2

    $report += $esxcli.system.visorfs.ramdisk.list.Invoke() |

    where{$_.RamDiskName -eq 'tmp' -and [int]$_.Free -lt 100} |

    Add-Member -Name VMHost -Value $esxcli.VMHost.Name -MemberType NoteProperty -PassThru

}

$report | Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture

   


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
bansne
Enthusiast
Enthusiast
Jump to solution

Hi,

The script works i am getting values less than100 and =0 . However , what if i want all values greater than 50% or equal to 100%.

What i want is to check if my  /tmp directory is full or about to be full. I got alert on one esxi "The ramdisk 'root' is full. As a result, the file /testfile could not be written." need to validate other hosts stats in vc.

Regards

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can change the Where-clause

where{$_.RamDiskName -eq 'tmp' -and [int]$_.Free -lt 50} |


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

bansne
Enthusiast
Enthusiast
Jump to solution

Thanks for your reply. Always been of great help.  Smiley Happy LucD

Reply
0 Kudos