WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / How to Ack & Reset vCenter Alarm implementing hidden API method

How to Ack & Reset vCenter Alarm implementing hidden API method

10.16.2010 by William Lam // 11 Comments

There was a recent question in the VMTN developers forum around automating the acknowledgment and resetting of a triggered vCenter alarm using vSphere SDK for Perl. This is actually a trivial task using the vSphere Client, you would first identify the alarm and acknowledge the alarm by right clicking on the alarm and selecting "Acknowledge Alarm". To reset the alarm, you would right click on the alarm and select "Reset Alarm to Green".

To automate this task using the vSphere SDK for Perl which uses the vSphere API, you would perform the same two API operations. Doing a search, you will find a method called AcknowledgeAarm which should does exactly that, but if you try to search for method to reset an alarm, you will notice no such method exists. This was something I was aware of since vSphere 3.5 API, but never understood why it was kept hidden.

UPDATE - The AcknowledgeAlarm API has been made public as of vSphere 7.x and later

Here is a screenshot of the alarmManager in the vSphere MOB and you will notice no methods pertains to resetting an alarm:

You might ask, how is the vSphere Client performing this operation and what API method is it using? Sadly, this operation is one of the many hidden API methods that VMware choose to hide and not public expose for various reasons.

However, there are several ways of identifying some of these hidden vSphere API methods and properties. When you install the vSphere Client on your workstation, there is a catalog directory (e.g. C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\4.1\Catalogs\Default)  that is created based on the version of vSphere and within the vim directory, there are these *.vmsg files that contain information regarding the VIM API (Virtual Infrastructure Management API) and searching within these files, you will find some hidden goodies.

Searching the task.vmsg file and within the alarm section, you will see a method name called setAlarmStatus:

alarm.AlarmManager.setAlarmStatus.label = "Set alarm status"
alarm.AlarmManager.setAlarmStatus.summary = "Sets the status of an alarm for an entity"

As you can see, there are other methods with respect to the alarmManager that is documented, but the method above is not documented in the vSphere API reference. We can take this information and further validate by using the vSphere MOB to see what parameters are required for this method.

By generating the proper URL, you can see the method is exposed and the required parameters to this function:

We can perform one additional confirmation to ensure that the method above is actually the method the vSphere Client is performing when resetting an alarm. The tool that we will use here is Onyx, yep, it is not only useful for PowerCLI but for all vSphere developers and administrators. I created a dummy alarm that would trigger if a VM is powered on or powered off and by running Onyx to capture the API calls when acknowledging and resetting an alarm.

Here is the output from Onyx:

As you can see, the two operations uses the AcknowledgeAlarm and the hidden SetAlarmStatus API method. We now can definitively say that the above hidden API method is being used and now we need to figure out how we can incorporate this method into the existing vSphere SDK for Perl.

In this example, I will be working with the vSphere SDK for Perl found on vMA 4.1, but the same set of changes will apply to vCLI 4.x being installed on a Windows or Linux system. There are two client Perl stubs or Perl Modules that contains prototype and definition of a vSphere API method:

/usr/lib/perl5/5.8.8/VMware/VIM25Stub.pm (prototype definition)
/usr/lib/perl5/5.8.8/VMware/VIM25Runtime.pm (method definition)

We will first edit the VIM25Runtime.pm module and if you are on vMA, you will need to use 'sudo' to edit the file. We will add the SetAlarmStatus entry try similar the AcknowledgeAlarm method:

Next we will edit the VIM25Stub.pm and again it will be very similar to an existing method, but now we must populate the parameters based on what we discovered from the vSphere MOB:

Now we are ready to implement this method in a vSphere SDK for Perl Script. I quickly threw together a script that helps manages your vCenter alarms using the CLI by listing all active and triggered alarms in either a red or yellow state.

Download Script: alarmManagement.pl

Here is an example of listing all triggered alarms that are either in a red or yellow state:

Here is an example of acking and resetting the above alarm and utilizing the new hidden API method that was just implemented:

There you have it, a method that was once hidden is no longer =)

If you are interested in locating other hidden API goodies, take a look at this post on How to browse the internal vSphere APIs

More from my site

  • How to Create a vCenter Alarm to Monitor for root Logins
  • How to Send vCenter Alarm Notification to Growl
  • Quick Tip - How to monitor when ESXi filesystem and partitions are filling up?
  • How to modernize your vSphere Alarm actions using the VMware Event Broker Appliance (VEBA)?
  • Customizing vCenter Alarm Email Subject and Body

Categories // Automation, vSphere Web Client Tags // acknowledge alarm, alarm, reset alarm, vsphere sdk for perl

Comments

  1. *protectedDED says

    10/22/2010 at 9:19 am

    Cool! Thank you William. I've looked at file task.vmsg as you wrote and I've found this lines: UpgradeManager.#####. But I don't know how to use it. Could you looked at this UpgradeManager ? Could you answer me how could I use this manager, please ?

    Reply
  2. *protectedWilliam says

    10/26/2010 at 6:04 am

    @DED,

    There are many hidden API properties as mentioned in the blog post, some are trivial to implement and some are quite difficult or impossible. The "UpgradeManager" is more than just a simple method, it's most likely dealing with VUM based on some of the method names. Though this is not something you can just look at and reverse engineering, at least easily. I don't plan on reverse engineering this, especially not knowing what each of the method parameters require. You're more than welcome to try

    --William

    Reply
  3. *protectedDED says

    10/26/2010 at 9:17 am

    I want to do it, but I don't know how could I call methods of UpgradeManager. F.e. i saw method: cluster.transitionalevcmanager and i can call it from MOB (managedobject browser) just typing: ...domainX&method=transitionalevcmanager. But I don't know how could I call methods from UpgradeManager and how could I find UpgradeManager object in MOB. If you could help me just to find UpgradeManager in the MOB I would very happy 🙂

    Reply
  4. *protectedWilliam says

    10/26/2010 at 1:55 pm

    @DED,

    Yea I've tried few variations through the MOB and unfortunately I had no luck, it may be under different path or different name all together. One of the difficulties when it's hidden, sorry. Good Luck

    Reply
  5. *protectedDED says

    10/27/2010 at 7:09 am

    It's a pity but thanks anyway

    Reply
  6. *protectedSanjay says

    06/26/2015 at 5:02 pm

    Hi William,

    is there any way we can trigger a compliance change notification in VCM when some admin changes a default VMware vCenter alarm that was enabled on the environment.

    Thanks

    Reply
    • William Lam says

      06/26/2015 at 10:44 pm

      I'm not familiar with VCM, you would probably need to contact someone from your account team or potentially post on the VMTN Community forums for that question

      Reply
  7. *protectedKevin says

    09/29/2015 at 2:17 pm

    fyi, for version 6 of viperl, you need to add one extra line to the VIM25STub.pm function, and modify a line:

    my $soap_action = '"urn:vim25/6.0"';
    my ($result, $fault) = $vim_soap->request('SetAlarmStatus', $arg_string, $soap_action);

    Reply
  8. *protectedDavid says

    09/20/2018 at 3:35 am

    I'm using VCSA and accessing via vsphere web client.I am running PRTG to monitor alarms in vCentre and have an alarm in vcentre that runs a bash script that disables and enables sensors in PRTG based on if the hypervisor is going into or out of standby mode. My problem is that if the Alarm is NOT reset to green the script isn't run again until that centre alarm is "reset to green" and PRTG starts to alert (and fills up email!). How do I accomplish the above when using a web client and VCSA? I need to be able to acknowledge the alarm/ Reset to green either within my script (which is a simply bash script using curl to post to the PRTG API). You solution doesn't work unless I have a client installed which isn't available for 6.5. Also I am using VCSA and not the Windows version so POWERCLI not an option not to mention installing anything onto VCSA if not advisable. Any help greatly appreciated.

    Reply
  9. *protectedUG says

    04/15/2021 at 12:02 pm

    I am getting empty results while using the script but when I use browser to use vCenter it does indeed show three alarms present. What would be the modification in the perl script?

    Enter password:
    Alarm Key | Alarm State | Alarm Name | Alarm Entity
    -------------------------------------------------------------------------------------------------------------------------------------

    Reply

Trackbacks

  1. Reset vCenter Alarms from red to green using yavijava the vijava fork | errr-online.com says:
    10/18/2014 at 9:51 pm

    […] YAVIJAVA that allows you to reset an alarm status. William Lam has posted in the past about how to hack the perl sdk to add this functionality, so I thought it would be a good idea to add this functionality to […]

    Reply

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025