VMware Cloud Community
aw443
Contributor
Contributor

Stats for esx hosts --help

Would anyone like to take a stab at this one...?

I'd like to have average CPU usage (%) and average Memory usage (%) stats for the last 1 month broken down for a monthly report I run. I do all of this manually, by obtaining my info from VC, and then plotting into an Excel spreadsheet manually. This is only a portion of the report I run, but its probably the most time consuming. If I could pump this part out through a VI PS script, it would free up a LOT of time!

If possible, I'd like it to list as so:

-DataCenterA - DataCenter avg CPU usage, DataCenter avg Memory

--Cluster1 - Cluster avg CPU usage, Cluster avg Memory

---ESXhost1 - CPU usage, Memory usage (over last 30 days)

---ESXhost2 - CPU usage, Memory usage (over last 30 days)

--Cluster2 - Cluster avg CPU usage, Cluster avg Memory

---ESXhost3 - CPU usage, Memory usage (over last 30 days)

---ESXhost4 - CPU usage, Memory usage (over last 30 days)

-DataCenterB - DataCenter avg CPU usage, DataCenter avg Memory

--Cluster1b - Cluster avg CPU usage, Cluster avg Memory

---ESXhost1b - CPU usage, Memory usage (over last 30 days)

---ESXhost2b - CPU usage, Memory usage (over last 30 days)

--Cluster4b - Cluster avg CPU usage, Cluster avg Memory

---ESXhost3b - CPU usage, Memory usage (over last 30 days)

---ESXhost4b - CPU usage, Memory usage (over last 30 days)

Any takers? Or any other ideas? Thanks in advance!

-alan

0 Kudos
6 Replies
Niket
Enthusiast
Enthusiast

Hi aw443,

To get the average CPU usage and average memory usage use the following script

Get-Stat -Entity (Get-VMHost) -start (get-date).AddDays(-30) -IntervalMins 50 -MaxSamples 1000 -memory -Cpu

You can change the Entity type as per your choice like Host,VM etc in the -Entity(Get-Cluster)

To get in a particular format

Get-Stat -Entity (Get-VMHost) -start (get-date).AddDays(-30) -IntervalMins 50 -MaxSamples 1000 -memory -Cpu | ft metricid, value

The MaxSamples defaults to 10 if not otherwise specified and if you want more samples than you will have to increase

the number of samples.

Time range depends on the value on which your server is configured normally its configured at 5-minute interval

if is not configured the closest available one will be picked.

I hope it clears your understanding.

Thanks

-Niket

LucD
Leadership
Leadership

Any clue why the Entity field is empty ?

I tried to pipe the output of get-stat to ft entity.name, metricid, value


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

0 Kudos
aw443
Contributor
Contributor

Thanks Niket, I'll give this a try.

0 Kudos
aw443
Contributor
Contributor

Yes, this is very helpful - thanks Niket. But is there a way to set the CPU stat output to %, (as available in VC), not mHz ? And I can't seem to get the ESX host name outputted with the stats -- (similar question to LUC D's post below). If the name is not possible, its ok. I can just run this for each host separately, and output to a file based on the ESX host name.

However, the CPU % would be very helpful for me. This is for a report for the "higher-ups", and providing the % usage is an easier way to quantify this particular stat so they understand its usage. Any thoughts?

0 Kudos
LucD
Leadership
Leadership

Use the parameter -Stat cpu.usage.average instead of -Cpu


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

aw443
Contributor
Contributor

Cool, thanks. I will give that a try...

0 Kudos