Please see the link below for a simple python script that when executed as a task via Morpheus will notify instance owners if the their instances are off for set number of days.
https://github.com/wabbas-morpheus/general/blob/main/automation/notifyStoppendInstances.py
- Create a python task in Morpheus and copy the content from the GitHub link above.
Make sure the additional packages are set as shown above.
- Set the following variables as required and save the task:
shutdownDays = 90 #Number of days before sending the notification
port = 587 # Email server starttls port
smtp_server = "smtp.office365.com" #SMTP server
sender_email = "myemail@outlook.com" #Senders email address
email_password=c.get("secret/mypass000") #Set the email password in Morpheus cypher
-
Create an execution schedule by navigating to Library >> Automation >> Execute Scheduling.
-
Create a task execution job via Provisioning >> Jobs and select the task and execution schedule created above.
Morpheus will now run the task on the scheduled times and notify the owners if the instances have been off for set number of days.