VMware Cloud Community
prasanna22kumar
Contributor
Contributor

Cluster Utlisaton report

Hello,

I'm new to scripting, Kindly assist me on getting CPU,Memory for Cluster & Esxi Host's under the Cluster in the below format

ClusterEsxi Host NameCPU GHz CapacityCPU GHz UsedCPU GHz FreeMemory Capacity GBMemory Used GBMemory Free GBTimeStamp

 

Thanks,

Kumar

Reply
0 Kudos
10 Replies
scott28tt
VMware Employee
VMware Employee

@prasanna22kumar 

What did you find when you did a search in this area of VMTN? (this topic will have been covered many times before)


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi Scott,

I was able to pull few information using the previous Script, But I was unable to pull in required format as below.

ClusterEsxi Host NameCPU GHz CapacityCPU GHz UsedCPU GHz FreeMemory Capacity GBMemory Used GBMemory Free GBTimeStamp

 

this is the link I tried few options.

https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Powercli-Script-to-Capture-ESXi-Host-C...

If can assist me on that I will be thankful.

Regards,

Kumar

Reply
0 Kudos
LucD
Leadership
Leadership

Just providing a link to another post is not really saying what your problem is.
That other post has 90% of the information you requested.
What is missing?
What did you try, and what didn't work?

And btw, you never replied on your other thread.


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

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi Lucd,

Yes, the link as information, But I required all cluster's & Esxi Host &  Timestamp to be added.

Cluster-Esxi-Timestamp, Kindly help me to add those cmdlet to Script..Please.

Previous one as suggested, I'm working on it...Once I do it...I will surely thank you on that thread.

As always you're so much helpful.

Thanks,

Kumar

Reply
0 Kudos
LucD
Leadership
Leadership

Try something like this

$time = Get-Date

Get-Cluster -PipelineVariable cluster |
Get-VMHost|
Select @{N='Cluster';E={$cluster.Name}},
    @{N='VMHost';E={$_.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)}},
    @{N='Timestamp';E={$time}} |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture


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

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Dear Lucd,

It worked....!! Thanks...!!

It's really admirable, As always you help other's and make sure it get's resolved.

You're the captain of this community.

Thanks a lot ..!!

Regards,

Kumar

 

  •  
Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi, 

How can I convert the output into percentage (%) ..Please.

Regards,

Kumar.

Reply
0 Kudos
LucD
Leadership
Leadership

Used/Capacity*100


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

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi,

Below is changes made for only ( Free Memory & CPU ) as per your instructions,

$time = Get-Date
Get-Cluster -PipelineVariable cluster |
Get-VMHost|
Select @{N='Cluster';E={$cluster.Name}},
    @{N='VMHost';E={$_.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)/100}},
    @{N='Memory Capacity GB';E={[math]::Round($_.MemoryTotalGB,2)}},
    @{N='Memory Used GB';E={[math]::Round($_.MemoryUsageGB,2)}},
    @{N='Memory Free %';E={[math]::Round(($_.MemoryTotalGB - $_.MemoryUsageGB),2)/100}},
    @{N='Timestamp';E={$time}}|
Export-Csv -Path c:\temp\ramdisk\Utilisationreport3.csv -NoTypeInformation -UseCulture

Below is the Ooutput.

CPU GHz CapacityCPU GHz UsedCPU GHz Free %Memory Capacity GBMemory Used GBMemory Free %Timestamp
79.854.760.25041023.65737.622.860304-12-2020 14:20
79.857.710.22091023.65459.155.64504-12-2020 14:20

 

Kindly let me whether OUT is correct, If yes... How I place percentage symbol next to Value as per Below 

CPU GHz CapacityCPU GHz UsedCPU GHz Free %Memory Capacity GBMemory Used GBMemory Free %Timestamp
79.854.760.25%1023.65737.622.86%04-12-2020 14:20
79.857.710.22%1023.65459.155.65%04-12-2020 14:20

 

Thanks,

Kumar

Reply
0 Kudos
prasanna22kumar
Contributor
Contributor

Hi,

Kindly can you help me to convert the same into percentage.

Regards,

Kumar.

Reply
0 Kudos