Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 252940

Re: Create new alarms

$
0
0

Please ignore my previous post.

What I want to know is how to create a storage usage alarm for a datastore. I assume the $entity variable needs to be changed to the datastore name? 

 

 

$esxName = 'hostname'

$alarmMgr = Get-View AlarmManager #only works when connect to vc not esx
$entity = Get-VMHost -Name $esxName | Get-View

# AlarmSpec
$alarm = New-Object VMware.Vim.AlarmSpec
$alarm.Name = "Host Alarm"
$alarm.Description = "Monitoring host"
$alarm.Enabled = $TRUE

#Action
$alarm.action = New-Object VMware.Vim.GroupAlarmAction

$trigger = New-Object VMware.Vim.AlarmTriggeringAction
$trigger.action = New-Object VMware.Vim.SendSNMPAction

# Transaction
$trans = New-Object VMware.Vim.AlarmTriggeringActionTransitionSpec
$trans.startstate = "yellow"
$trans.finalstate = "red"
$trans.repeats = $false

$trigger.transitionspecs += $trans

$alarm.action.action += $trigger

# Expression
$expression = New-Object VMware.Vim.EventAlarmExpression
$expression.EventType = "EnteringMaintenanceModeEvent"
$expression.ObjectType = "HostSystem"
$expression.Status = "red"

$alarm.expression = New-Object VMware.Vim.OrAlarmExpression
$alarm.expression.expression += $expression

$alarm.setting = New-Object VMware.Vim.AlarmSetting
$alarm.setting.reportingFrequency = 0
$alarm.setting.toleranceRange = 0

# Create alarm.
$alarmMgr.CreateAlarm($entity.MoRef, $alarm)


Viewing all articles
Browse latest Browse all 252940

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>