VMware Cloud Community
ehermouet44
Contributor
Contributor
Jump to solution

Powercli script mem, cpu, disk, uptime

Hi all

first tks for this forum. i just see that very good tool exist -> powercli Smiley Happy

i try to do somethings.

first i want per vm the % of uptime per vm

and the average of cpu usage, mem usage etc... from last year.

i can do this per script but i don't found how.

tks for your help

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

That explains it, the metric was only introduced in vSphere 5

osuptime.png


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

View solution in original post

Reply
0 Kudos
35 Replies
LucD
Leadership
Leadership
Jump to solution

If you have to go back 1 year in time, the historical interval will only have 1 sample per day.

Is that sufficient for your purpose ?

What exactly do you want to use as a measurement for uptime ?

The percentage of time that a VM was powered on ?

Or do you want to report on the time since the last OS boot ?


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

Reply
0 Kudos
ehermouet44
Contributor
Contributor
Jump to solution

hi,

first tks lucD for all your other post Smiley Wink

so i must have stats for this year for all of my vm.

i want to know downtime per vm machine or uptime on % for 1 year if it's possible.

tks advance

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I think the best option would be to look at the sys.osUptime.latest metric to calculate the uptime.

Since you want to go back for 1 year, the samples will come from Historical Interval 4.

And the statistics level will need to be set to level 4 for Historical Interval 4. Is that the case in your environment ?

The alternative is to use sys.uptime.latest, that only requires statistics level 1.

Let me check how the aggregation jobs handle this kind of metric.


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

Reply
0 Kudos
ehermouet44
Contributor
Contributor
Jump to solution

Hi

tks for your reply

how to know level ?

tks

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Like this

$si = Get-View ServiceInstance 
$perfMgr
= Get-View $si.Content.PerfManager
$perfMgr
.HistoricalInterval | Select Name,Level


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

Reply
0 Kudos
ehermouet44
Contributor
Contributor
Jump to solution

Ok. i'm on level 1 how i can change this ? to have more log ?

tks advance again Smiley Happy

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Through the vSphere client.

Have a look at my PowerCLI & vSphere statistics – Part 1 – The basics post. There I explain several of these statistics related concepts.


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

Reply
0 Kudos
ehermouet44
Contributor
Contributor
Jump to solution

It's ok now i'm on level 4 Smiley Happy tks

i suppose level 4 is since this day not before ?

sys.osUptime.latest -> and complete script to export all of this data ?

tks advance


Reply
0 Kudos
ehermouet44
Contributor
Contributor
Jump to solution

Luc

sorry but sys.osUptime.latest  not work. how do you use it ?

tks advance

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Over which period did you try to get the sys.osUptime.latest ?

Since you only changed the statistics level to 4 last week, you can only get this for the last couple days right now.

Or do you mean something else ?


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

Reply
0 Kudos
ehermouet44
Contributor
Contributor
Jump to solution

if i have last log next time i will know how to do for long time. can you help me ? tks

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, the following script reports how long the OS in each VM has been running.

$vms = Get-VM

Get-Stat
-Entity $vms -Stat "sys.osUptime.latest" -Realtime -MaxSamples 1 |
Group-Object -Property {$_.Entity.Name} |
Select
@{N="VM";E={$_.Name}},
@{N="OS running";E={New-TimeSpan -Seconds $_.Group[0].Value}}


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

Reply
0 Kudos
ehermouet44
Contributor
Contributor
Jump to solution

Ressource unavalaible :s

+ CategoryInfo          : ResourceUnavailable: (sys.osuptime.latest:String
[Get-Stat], VimException

Smiley Sad

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

What version do you have running ?

For PowerCLI do a

Get-PowerCLIVersion

Which vSphere/ESXi versions ?

Does the metric exist ?

$vm = Get-VM -Name MyVM
Get-StatType -Entity $vm -Realtime | 
where {$_ -match "sys.osUptime.latest"}

Does this return anything ?


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

Reply
0 Kudos
ehermouet44
Contributor
Contributor
Jump to solution

esx 4.1 and power cli 5.1 R1

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That explains it, the metric was only introduced in vSphere 5

osuptime.png


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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You might be interested in my post called Game of Nines – VM Uptime Report.


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

Reply
0 Kudos
ehermouet44
Contributor
Contributor
Jump to solution

hi luc

tks for this

i want to test it but nothing appear on my powercli...do you knwo why ?

tks advance

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did you look at the Sample Usage section, it contains several examples on how to use the Get-VMUptime function.

How did you call the function ?

Can you include your code ?


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

Reply
0 Kudos