You can configure an alarm to run a script or a command in the vSphere Web Client when the alarm is triggered.

Before you begin

Required Privilege: Alarms > Create alarm or Alarms > Modify alarm

About this task

Use the alarm environment variables to define complex scripts and attach them to multiple alarms or inventory objects. For example, you can write a script that enters the following trouble ticket information into an external system when an alarm is triggered:

  • Alarm name

  • Object on which the alarm was triggered

  • Event that triggered the alarm

  • Alarm trigger values

When you write the script, include the following environment variables in the script:

  • VMWARE_ALARM_NAME

  • VMWARE_ALARM_TARGET_NAME

  • VMWARE_ALARM_EVENTDESCRIPTION

  • VMWARE_ALARM_ALARMVALUE

You can attach the script to any alarm on any object without changing the script.

The script runs on the vCenter Server machine, and it runs even if you close the vSphere Web Client.

Procedure

  1. On the Actions tab of the alarm definitions wizard, click Add to add an action.
  2. In the Actions column, select Run a command from the drop-down menu.
  3. In the Configuration column, type script or command information:

    For this type of command...

    Enter this...

    EXE executable files

    Full pathname of the command. For example, to run the cmd.exe command in the C:\tools directory, type:

    c:\tools\cmd.exe.

    BAT batch file

    Full pathname of the command as an argument to the c:\windows\system32\cmd.exe command. For example, to run the cmd.bat command in the C:\tools directory, type:

    c:\windows\system32\cmd.exe /c c:\tools\cmd.bat.

    Note:

    The command and its parameters must be formatted into one string.

    If your script does not make use of the alarm environment variables, include any necessary parameters in the configuration field. Enclose parameters in curly brackets. For example:

    c:\tools\cmd.exe {alarmName} {targetName}
    c:\windows\system32\cmd.exe /c c:\tools\cmd.bat {alarmName} {targetName}

    The script can run on any platform. You must provide the path to the script and argument keys. For example:

    /var/myscripts/myAlarmActionScript {alarmName} {targetName}

  4. (Optional) : Configure alarm transitions and frequency.
  5. Click Finish to save the alarm settings.