Setup vCenter Alarm Action Script To Send Push Notifications

I recently came across this useful app, Alertzy.app. It’s a service that allows you to send and receive real-time alerts as push notifications on your iOS and Android device. I was impressed with how simple it was to set up and use, and it’s free for up to 100 notifications per day. I figured this could be useful to integrate with vCenter alarms, so I’ll guide you through setting this up in this post.

Step 1

First, you will need to download Alertzy.app on your mobile device, which can be found here and sign up for a free account. Once you are signed in, you will need to take note of your Account key, you will need that in Step 2.


Step 2

Next you will need to download the following script vc_alarm_push.sh and upload it to your VCSA Appliance, (I stored script it in /root). Alternatively you can run this wget command from your VCSA to download the script directly to the /root directory.

wget -P /root https://raw.githubusercontent.com/virtuallywired/AlertzyScripts/main/vc_alarm_push.sh

At the minimum, you will need to update line 7 with your Alertzy account key. You can also change the title and folder name if you wish. The folder name is just a way to organise and group the alerts within the Alertzy app.

From lines 11-15, you can see I have added 5 alarm environmental variables, you can modify this to your desired state, check out this VMware document Environment Variables for Scripts to view all the other available environmental variables you can use in your scripts and this document on running a script or a Command as an Alarm Action.

Sample of the script below
#!/bin/sh
# Author: Nicholas Mangraviti
# Website: virtuallywired.io
# Description: Sends vCenter Alarm Push notifications using Alertzy.app
# Reference: http://virtuallywired.io

key="b40i57zzzzzzwq9" # Update this with your own Alertzy Account Key
title="vCenter Alarm"
folder="Production"

text="Alarm: $VMWARE_ALARM_NAME
Target: $VMWARE_ALARM_TARGET_NAME
Value: $VMWARE_ALARM_ALARMVALUE
Description: $VMWARE_ALARM_EVENTDESCRIPTION
Status: $VMWARE_ALARM_NEWSTATUS"

curl -s \
    --form-string "accountKey=$key" \
    --form-string "title=$title" \
    --form-string "message=$text" \
    --form-string "group=$folder" \
https://alertzy.app/send

Note: I’m not great with bash scripts so feel free to improve it 🙂

Now set the script to be executable by running the following command.

chmod +x vc_alarm_push.sh

At this point, you could execute the script via SSH to confirm it works and that you receive a push notification on your mobile device. Run the following command from within the /root directory to do this.

./vc_alarm_push.sh

If everything works as it should, you should see a success response and instantly receive a push notification on your mobile device.


Step 3

You now need to add an alarm action to run the script. In this example, I will modify one of the default alarms, “Host connection and power state” I will then simulate a host failure on one of my Nested ESXi hosts to see if it works. Select the alarm and press EDIT.

Toggle the switch “Run script” and paste the following code, then press next until you review and save. I haven’t tested this, but you should be able to configure the same script for the reset rule.

/root/vc_alarm_push.sh

Step 4

Now it’s time to simulate a host failure by suspending the ESXi VM; when the host went into a “Not responding” state, an event triggered, stating it ran the script.

I instantly received the following push notification on my phone and my Apple Watch.

And this is what the alert looks like from within the app.


So as you can see, it’s pretty simple to set up, and there are many other use cases; I’m also using Alertzy to monitor my internet connection. Alertzy has stated to contact them if you need a higher quoter than 100 notifications per day.

Another app I found is Tenta.me, which offer 10 free notifications per day with a cost-effective premium option offering unlimited notifications.

Thank you for reading; as always, feel free to comment below 🙂

2 comments Add yours
  1. This is a great source of information on how to set up an alarm action script to send push notifications. Source information includes installing the vCenter server, configuring the notification channel, configuring the notification message template, configuring the notification channel, configuring alarms and the notification event type, and configuring operational level for notifications.

Leave a Reply