VMware Cloud Community
cjwirweazel
Contributor
Contributor
Jump to solution

Alarm for VM Free space metric

i have a script that will show me the free space on the VM Guest OS disk

Get-VM | Where { $_.PowerState -eq "PoweredOn" } | Get-VMGuest | Select VMName -ExpandProperty Disks | Select VMName, Path, @{Name="DiskFreeGB";Expression={[math]::Round((($_.FreeSpace)/1GB),2)}}

I have seen that you can set up alarms though PCLI and was wondering if any has had a go at it with something like the above.

I don't really know where to start with it so any help would be great

chris

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try the attached script.

____________

Blog: LucD notes

Twitter: lucd22


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

View solution in original post

0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

The triggers that are available to fire an alarm are either a performance metric, an event or a state.

See AlarmExpression.

Afaik none of these has an option to use the free disk space from a guest as a trigger.

But you can always run your script on a scheduler and send an email when the free space percentage exceeds a threshold.

You only will not be using the vCenter Alarms.

____________

Blog: LucD notes

Twitter: lucd22


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

cjwirweazel
Contributor
Contributor
Jump to solution

thanks for that - was hoping i had missed something

so scheduled task to run script

any advice on getting it to read the data rather than output to a file?

cheers

Chris

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Sorry, not sure I understand that question about reading the data.

Can you elaborate ?

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
cjwirweazel
Contributor
Contributor
Jump to solution

the current script outputs to a CSV file

i am not sure how to get the script to look at the data in that script and find those with free space under a threshold and send an email

cheers

chris

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try the attached script.

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
cjwirweazel
Contributor
Contributor
Jump to solution

thats awesome - thank you vewry much

0 Kudos
dirch201110141
Enthusiast
Enthusiast
Jump to solution

This subject is always interesting - servers running out of disk space. For a couple of weeks my collegue and I have been looking for at way to trigger an event in Virtual Center when one of the dearly beloved virtual machines runs low on free space.

This mail thread seems to show that this is not possible through Virtual Center - at least not in december 2010.

Now were running 5.0 so the question is if anything has changed here? Could it be that a new event has arrived saying "fireTriggerWhenVMisAbove80percent" so we can see it in Virtual Center as well as send a trap to HPO ?

We're looking at this from two different angles:

1) Fire an event (hopefully an snmp trap) when free space falls below an absolute value (say: 1 Gb)

2) Fire an event (again, in best case an snmp trap) when space falls below a relative value (say: 80%)

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Afaik, vSphere 5 didn't bring any new triggers to do what you're looking at.

I think you could have better luck writing something in your monitor (HPO), that monitors the values you want to check regularly (with PowerCLI) and then raises an alarm in HPO.


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

0 Kudos
dirch201110141
Enthusiast
Enthusiast
Jump to solution

A speedy answer as always. Thank you.

We can get HPO to do it I am sure and we will be looking in that direction now.

The challenge of bending Virtual Center to my will and get the complete status of hosts and VMs in one view through VC must wait to another time Smiley Happy

0 Kudos