VMware Cloud Community
DZ1
Hot Shot
Hot Shot

Creating Alarms for datastore usage.

I am trying create an alarm that's basically a copy of an existing vSphere alarm that alerts you when a datastore has reached a certain percentage of disk space used.  This will be created in multiple folders on each datastore in different datacenters.  I found some information online, I've been looking over it, and I understand the basics of what the scripts are doing, but I can't seem to make it fit into what I need.
When an alarm is manually created, at least the one that I want, I just need a name and a trigger with the trigger type, but the examples that I have seen used an event under the Triggers tab.  I've tried to decipher the API/SDK documentation but I'm out of my league.  So far, I have this:
$alarmMgr = Get-View AlarmManager
# Create AlarmSpec object
$alarm = New-Object VMware.Vim.AlarmSpec
$alarm.Name = "TestDSAlarm"
$alarm.Description = "Datastore Alarm usage"
$alarm.Enabled = $TRUE
Now I need a trigger, and the option to send the email when the alarm changes.  Is there a good reference for me to look this up?  Any help is appreciated.  Also, how in the heck do I space my paragraphs on this forum now?  Everything is all together even though I have carriage returns in my post.
0 Kudos
2 Replies
LucD
Leadership
Leadership

There is an older blog post of mine, see Alarm expressions – Part 2 : Event alarms, that discusses how to use events as a trigger in an alarm.

And it shows how to add a Send Mailmessage action.


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

0 Kudos
DZ1
Hot Shot
Hot Shot


Thanks for the feedback, I did take a look at the article, and then used Project Onyx to help create the bulk of the script.  From there, I can change the folder names and alarms as I see fit.  Thanks again.  Good luck with finishing the PowerCLI book.  

0 Kudos