The backup in the VAMI now contains a scheduler including retention policy:
Disclaimer: This is not officially supported by VMware, please use at your own risk.
Recently I faced the challenge with a script running on a VCSA which executes some checks and in case something gets detected it has to trigger a vCenter alarm.
My solution is to log a user event which will be captured by an vCenter alert definition.
1. vCenter alert definition
as trigger manually enter (type): vim.event.GeneralUserEvent
2. The script which will log the user event
#!/usr/bin/python #!/usr/bin/python import sys sys.path.insert(0, '/usr/lib/vmware/site-packages/') from pyVim.connect import SmartConnect from pyVmomi import vim import ssl import atexit username = 'email@example.com' password = 'VMware1!' v = sys.version_info try: if sys.version_info <7 or v.minor < 7: si = SmartConnect(host="localhost", user=username, pwd=password) content = si.RetrieveContent() ds = content.rootFolder log = si.content.eventManager.LogUserEvent(entity=ds, msg="Postgres Corruption detected") else: s = ssl.SSLContext(ssl.PROTOCOL_TLS) s.verify_mode = ssl.CERT_NONE si = SmartConnect(host="localhost", user=username, pwd=password, sslContext=s) content = si.RetrieveContent() ds = content.rootFolder log = si.content.eventManager.LogUserEvent(entity=ds, msg="Postgres Corruption detected") except: print("Unexpected error:", sys.exc_info())
The resulting alert can be catched by vROPs and trigger further events/ tickets.
I would like to receive push messages for triggered alerts from my vCenter. There is the possibility to execute a command when a alert has been triggered so I decided to write a script which will use Prowl to send push notification to my mobile apple device. I used Prowl already for other devices like my Homematic home automation system. It’s easy to use with an simple curl command. You can find a lot of good examples available by using Google.
Sources and Services:
You have to create an account on www.prowlapp.com and generate a new API key. The new API key has to be added to script (replace PLACE_YOUR_API_KEY_HERE with your API key).
This script is really basic and is only a proof of concept. I will extend and improve it over time.
root@vcenter [ ~ ]# mkdir bin root@vcenter [ ~ ]# cd bin root@vcenter [ ~/bin ]# vi alert.sh
#!/bin/bash #set -x value="$VMWARE_ALARM_ALARMVALUE" if [ $$value == "red" ]; then priority=2 else priority=0 fi app="$VMWARE_ALARM_NAME" event="$VMWARE_ALARM_EVENTDESCRIPTION" description="$VMWARE_ALARM_TARGET_NAME" apikey=PLACE_YOUR_API_KEY_HERE curl https://prowl.weks.net/publicapi/add -F apikey=$apikey -F priority=$priority -F application="$app" -F event="$event" -F description="$description"
Edit vCenter alert definition:
To receive the push notification you have to install the prowl app on your iOS device and login from the app to prowl.
Thats basically all what is required for vCenter push notifications on your iPhone.