I'm trying to create a new Alarm using a certain event type ID as a trigger, since the 6.7 Html5-GUI for creating Alarms have made 99% of all guides relying on the Flash-GUI useless.
Return Type
VMware.VimAutomation.ViCore.Types.V1.Alarm.AlarmTriggerTo my very limited understanding of powershell, the output of the command: Get-EventType | Where Id -eq "esx.problem.vmsyslogd.remote.failure" should return a object, right?
I have passed "esx.problem.vmsyslogd.remote.failure" as a variable to EventType just as a test and and get complaints that the variable is a string ...
So if it wont accept either a string of a object, what format should the variable have? This is where my powershell knowledge hits a brick wall.
This could all be avoided of there was a simpler way to specify esx.problem.vmsyslogd.remote.failure as a trigger for a alarm, but alas VMware has removed that.
At the end, all i need is a alarm for when syslog stops working, to comply with DoD STIG for vCenter.
This seems to work for me
$eventType = Get-EventType | where{$_.Id -match $eventId}
$root = Get-Folder -Name Datacenters
$trigger = New-AlarmTrigger -EventType $eventType -EntityType HostSystem -EntityStatus Red
New-AlarmDefinition -Name 'Remote syslog fail' -AlarmTrigger $trigger -Entity $root -Disabled
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This seems to work for me
$eventType = Get-EventType | where{$_.Id -match $eventId}
$root = Get-Folder -Name Datacenters
$trigger = New-AlarmTrigger -EventType $eventType -EntityType HostSystem -EntityStatus Red
New-AlarmDefinition -Name 'Remote syslog fail' -AlarmTrigger $trigger -Entity $root -Disabled
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That solved the parameter problem indeed 😃
If even made my vCenter STIG compliance script pass!
I'm still not 100% sure why, but hey .. knowledge is a journey!
Thanx alot for the help, much appreciated!!
\\C
The issue was that the Get-Event returns an object where the Id property contains 'EventType-EventEx;FullFormat-esx.problem.vmsyslogd.remote.failure'
With an -eq you do not find a match, that is why I used the -match operator.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
I'm having a different but somewhat similar issues. I'm trying to create some alarms but I cannot find the EventType for them. Existing Alarm - "Datastore usage on disk" doesn't show up in the Event Types. If I run the following, I don't see it:
Get-EventType | where description -like "*datastore*"
Any ideas? Because without that, I'm unable to use the new POWERCLI commands such as New-AlarmTrigger.
Thanks.
That alarm is not based on an Event but on a Metric.
You can see this with
Get-AlarmDefinition -Name 'Datastore usage on disk' | Get-AlarmTrigger
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hey LucD,
I've read a ton of your posts and you've helped me a lot in recent years so thanks for that!
We're trying to do something similar to in this post:
https://blogs.vmware.com/PowerCLI/2019/11/new-vsphere-alarm-management.html
So we can have a script with all our own alarms defined to apply on multiple vCenters. We want to avoid creating an export/import so we don't have to manage all the alarms on a vCenter but rather just have a static script we can modify thresholds or add new alarms.
The part that is not working is:
$vmReconfigEvt = Get-EventType | Where-Object {$_.Description -eq "VM reconfigured"}
$alarmTriggerInput = @{
EventType = $vmReconfigEvt
EntityStatus = "Yellow"
EntityType = "VirtualMachine"
}
$alarmTrigger = New-AlarmTrigger @alarmTriggerInput
$alarmDefInput = @{
Name = "VM Reconfiguration"
Description = "Alarm to monitor virtual machine reconfiguration events"
AlarmTrigger = $alarmTrigger
Entity = Get-Folder -Type Datacenter -NoRecursion
}
New-AlarmDefinition @alarmDefInput
And I don't know how I would work around the above using:
Get-AlarmDefinition -Name 'Datastore usage on disk' | Get-AlarmTrigger
Hope that makes sense
You define a Trigger, but instead of an Event you use a Metric.
Something like this
$metric = Get-Metric -Name 'Space actually used'
$trigger = New-AlarmTrigger -Metric $metric -MetricAlarmOperator Above -Yellow 5000 -Red 7500 -EntityType Datastore
$root = Get-Folder -Name Datacenters
New-AlarmDefinition -Name 'New alarm' -Disabled -AlarmTrigger $trigger -Entity $root
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference