VMware Cloud Community
MattGeorgey
Contributor
Contributor
Jump to solution

Creating New-Alarms in vCenter


Any possible ways/ scripts available to create new alarm definitions in vCenter Server ..?

Couldnt find any suitable cmdlet to create a new alarm definition .. Smiley Sad


-- Georgey

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Have a look at my Alarm expressions – Part 1 : Metric alarms and Alarm expressions – Part 2 : Event alarms posts.

Those are 2 examples on how to use the CreateAlarm method for different types of alarms.


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

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

I'm afraid there isn't such a cmdlet for now.

You can create triggers and actions on an existing alarm with cmdlets.

To create an alarm from scratch you will have to use the SDK method.

Which specific type of alarm do you want to create ?


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

MattGeorgey
Contributor
Contributor
Jump to solution

Looking to create custom alarms of both state and event triggered.

Objective is to write  a function which will define, add triggers and actions; given, all the required information and data.
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Have a look at my Alarm expressions – Part 1 : Metric alarms and Alarm expressions – Part 2 : Event alarms posts.

Those are 2 examples on how to use the CreateAlarm method for different types of alarms.


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

Reply
0 Kudos
srini_rocks
VMware Employee
VMware Employee
Jump to solution

Any update ?

Reply
0 Kudos
MattGeorgey
Contributor
Contributor
Jump to solution

Luc,

The script is fantastic.. Smiley Happy

But how to get the values of "VMware.Vim.MetricAlarmExpression"  "VMware.Vim.MetricAlarmExpression.Metric.CounterId" and "VMware.Vim.EventAlarmExpression.eventTypeId" for different tasks, in runtime ..?

Beacuse i'm trying to write a general purpose function to create both Event & Metric alarms from an XML given below or a CSV ..?

<alarm>
     <name> </name>                         # name for the alarm
     <description> </description>               # description for the alarm
     <enabled> </enabled>                     # true, false
     <monitor></monitor>                    # Hosts,Clusters,Datacenters, Datastores,vDS,dPG,dClusters,vC
     <type> </type>                         # condition, event
     <range></range>
     <frequency></frequency>
<triggers condition = "or">                    # or/and
     <trigger>
          <type>VMCpuUsage</type>               # VmNetworkUsage/VMHeartbeat/VM state
          <condition>Is above</condition>          # is above / is below
          <warning>70</warning>                    # 10-100 [x10]
          <wc_length>5</w_length>               # 5-60 [x5];0;30;1;2
          <alert>90</alert>                    # 10-100 [x10]
          <ac_lenght>5</ac_lenght>               # 5-60 [x5];0;30;1;2
     </trigger>
     <trigger>
          <type>VmNetworkUsage</type>               # VMCpuUsage/VMHeartbeat/VM state
          <condition>Is above</condition>          # is above / is below
          <warning>80</warning>                    # 10-100 [x10]
          <wc_length>5</w_length>               # 5-60 [x5];0;30;1;2
          <alert>90</alert>                    # 10-100 [x10]
          <ac_lenght>5</ac_lenght>               # 5-60 [x5];0;30;1;2
     </trigger>
<triggers>
     <action>
          <action>PowerOffVM</action>               # powerOnVM/migrateVM/resetVM
          <change repeat='y'>Y2R<change>          # G2Y/Y2R/R2Y/Y2G ; repeat -> y/n
     <action>
</alarm>

Is it possible to do that ..?

--Georgey

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, I think so.

It will be a matter of mapping the attribute values from your XML file to the matching metrics and/or events.

Once you have that mapping, you can automate the retrieval of the metricId and the eventTypeId.

In both my posts I gave scripts to retrieve those values.


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