Pushing vSphere Eventsto Phone Notifications
Why
I'm embarrassed to say, I created this hacky hack because I'm not smart enough to get the email functionality of ghettoVCB working 🙂 I use the free Pushover service for other notifications in my Home Lab, so I thought I would give Pushover a try to send the status of ghettoVCB backup jobs. Even though ghettoVCB doesn't need this functionality hack, I think this hack may be useful to the community for other purposes as well.
What
Pretty simple parts list for this one:
- vSphere
- curl
- A Pushover Account
How
Create a free Pushover account and API key
Head on over to Pushover.net, click "Login or Signup", then click "create a new account", follow the instructions.
Once you have your account, create a new Application/API Token at this page. Give your API a name, like "VMware", a description, upload a unique picture as an icon, check the box and click "Create Application".
You should see your new API on your main Pushover page. If you choose the name of your API, you will be presented with the API key to use to send notifications.
You also need your User Key in order to send a notification. You can find your User Key on the main Pushover page
Take note of your User Key and API Key
Install Pushover on your phone
You also need your User Key in order to send a notification. You can find your User Key on the main Pushover page
Start the Pushover app on your phone and login.
Install curl on ESXi
(There are most likely 1,000 security reasons that this is a bad idea, and I am sure I will hear them)
There are literally 21 supported programming languages/utilities supported by Pushover for sending notifications. I like bash, so I typically use curl which is easy. curl is not installed in ESXi (probably for a good security reason). I added curl and opened port 443 outbound in the ESXi firewall to allow curl to work.
Install curl binary
Open port 443 outbound in the ESXi firewall
When I ran a Pushover curl test on ESXi, curl just hung. When I ran curl -v, I saw that I was having trouble connecting over port 443. "Oh!" I thought "Firewall!". Off to vCenter to open port 443 outbound on that ESXi host. To make this even easier, there is already a port 443 outbound rule, for esxupdate, that just needs to be turned on.
Choose Outgoing, EDIT..., check the box for esxupdate and then click OK.
Now the Pushover test code should work
curl -s \ --form-string "token=APP_TOKEN" \ --form-string "user=USER_KEY" \ --form-string "message=hello world" \ https://api.pushover.net/1/messages.json
Write a hacky shell script
ghettoVCB status log (cron job once a day @ Midnight)
Hacky Shell Script (cron job once a day @ 2 AM)
How to update cron
Thank You
I hope you found this post helpful, or at least informational. I look forward to your feedback, improvements, and corrections.
Comments