VMware Cloud Community
antoniogemelli
Hot Shot
Hot Shot
Jump to solution

Cluster cpu info

Hello,

I have this script where I can get some CPU/Memory info:

Get-VMHost -Name tec-vm-ki* , tec-vm-* |

Select Name,

    @{N='CPU GHz Capacity';E={[math]::Round($_.CpuTotalMhz/1000,2)}},

    @{N='CPU GHz Used';E={[math]::Round($_.CpuUsageMhz/1000,2)}},

    @{N='CPU GHz Free';E={[math]::Round(($_.CpuTotalMhz - $_.CpuUsageMhz)/1000,2)}},

    @{N='Memory Capacity GB';E={[math]::Round($_.MemoryTotalGB,2)}},

    @{N='Memory Used GB';E={[math]::Round($_.MemoryUsageGB,2)}},

    @{N='Memory Free GB';E={[math]::Round(($_.MemoryTotalGB - $_.MemoryUsageGB),2)}} | Export-Csv -Path C:\Users\gemela\cpu_mem_Hardware_info.csv -NoTypeInformation -UseCulture

I would like to add some columns;

Number of CPU for Cluster

Cpu (number) usage for each host

Memory (Gb) usage for each host

Thanks

Tags (1)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Sure, try like this

Get-VMHost -Name tec-vm-ki* , tec-vm-* |

Select Name,

  @{N='CPUCoreCluster';E={(Get-Cluster -VMHost $_).ExtensionData.Summary.NumCpuCores}},

  @{N='CPUCoreESXi';E={$_.NumCpu}},

  @{N='MemGBEsxi';E={$_.MemoryTotalGB}},

  HyperthreadingActive,

  @{N='CPU GHz Capacity';E={[math]::Round($_.CpuTotalMhz/1000,2)}},

  @{N='CPU GHz Used';E={[math]::Round($_.CpuUsageMhz/1000,2)}},

  @{N='CPU GHz Free';E={[math]::Round(($_.CpuTotalMhz - $_.CpuUsageMhz)/1000,2)}},

  @{N='Memory Capacity GB';E={[math]::Round($_.MemoryTotalGB,2)}},

  @{N='Memory Used GB';E={[math]::Round($_.MemoryUsageGB,2)}},

  @{N='Memory Free GB';E={[math]::Round(($_.MemoryTotalGB - $_.MemoryUsageGB),2)}} |

Export-Csv -Path C:\Users\gemela\cpu_mem_Hardware_info.csv -NoTypeInformation -UseCulture


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

View solution in original post

5 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VMHost -Name tec-vm-ki* , tec-vm-* | 

Select Name,

    @{N='CPUCoreCluster';E={(Get-Cluster -VMHost $_).ExtensionData.Summary.NumCpuCores}},

    @{N='CPUCoreESXi';E={$_.NumCpu}},

    @{N='MemGBEsxi';E={$_.MemoryTotalGB}},

  @{N='CPU GHz Capacity';E={[math]::Round($_.CpuTotalMhz/1000,2)}}, 

  @{N='CPU GHz Used';E={[math]::Round($_.CpuUsageMhz/1000,2)}}, 

  @{N='CPU GHz Free';E={[math]::Round(($_.CpuTotalMhz - $_.CpuUsageMhz)/1000,2)}}, 

  @{N='Memory Capacity GB';E={[math]::Round($_.MemoryTotalGB,2)}}, 

  @{N='Memory Used GB';E={[math]::Round($_.MemoryUsageGB,2)}}, 

  @{N='Memory Free GB';E={[math]::Round(($_.MemoryTotalGB - $_.MemoryUsageGB),2)}} |

Export-Csv -Path C:\Users\gemela\cpu_mem_Hardware_info.csv -NoTypeInformation -UseCulture 


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

antoniogemelli
Hot Shot
Hot Shot
Jump to solution

Great! This is what I wanted, thanks a lot LucD 🙂

0 Kudos
antoniogemelli
Hot Shot
Hot Shot
Jump to solution

One more info,  can include "hyperthreading" if is enabled or not?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Sure, try like this

Get-VMHost -Name tec-vm-ki* , tec-vm-* |

Select Name,

  @{N='CPUCoreCluster';E={(Get-Cluster -VMHost $_).ExtensionData.Summary.NumCpuCores}},

  @{N='CPUCoreESXi';E={$_.NumCpu}},

  @{N='MemGBEsxi';E={$_.MemoryTotalGB}},

  HyperthreadingActive,

  @{N='CPU GHz Capacity';E={[math]::Round($_.CpuTotalMhz/1000,2)}},

  @{N='CPU GHz Used';E={[math]::Round($_.CpuUsageMhz/1000,2)}},

  @{N='CPU GHz Free';E={[math]::Round(($_.CpuTotalMhz - $_.CpuUsageMhz)/1000,2)}},

  @{N='Memory Capacity GB';E={[math]::Round($_.MemoryTotalGB,2)}},

  @{N='Memory Used GB';E={[math]::Round($_.MemoryUsageGB,2)}},

  @{N='Memory Free GB';E={[math]::Round(($_.MemoryTotalGB - $_.MemoryUsageGB),2)}} |

Export-Csv -Path C:\Users\gemela\cpu_mem_Hardware_info.csv -NoTypeInformation -UseCulture


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

antoniogemelli
Hot Shot
Hot Shot
Jump to solution

Perfect! many thanks

0 Kudos