ehermouet44
Contributor
Contributor

Powercli script mem, cpu, disk, uptime

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

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

0 Kudos
35 Replies
LucD
Leadership
Leadership

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

0 Kudos
ehermouet44
Contributor
Contributor

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

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
ehermouet44
Contributor
Contributor

Hi

tks for your reply

how to know level ?

tks

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
ehermouet44
Contributor
Contributor

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

tks advance again Smiley Happy

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
ehermouet44
Contributor
Contributor

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


0 Kudos
ehermouet44
Contributor
Contributor

Luc

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

tks advance

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
ehermouet44
Contributor
Contributor

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

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
ehermouet44
Contributor
Contributor

Ressource unavalaible :s

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

Smiley Sad

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
ehermouet44
Contributor
Contributor

esx 4.1 and power cli 5.1 R1

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
LucD
Leadership
Leadership

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


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

0 Kudos
ehermouet44
Contributor
Contributor

hi luc

tks for this

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

tks advance

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos