December 31, 20214 yr Is there a plugin, container or app that can send a notification (email or other) when an VM has stopped? Edited December 31, 20214 yr by FransHalsjes
December 31, 20214 yr Hi, I think it's possible with qemu hooks and notify command available in unraid. Search about hooks for qemu in unraid and create one to push a notification (setup the parameters in unraid), something like this (not tested): #!/bin/bash if [[ $1 == "NameOfVM" ]] && [[ $2 == "stopped" ]] then /usr/local/emhttp/webGui/scripts/notify -i normal -s "VM stopped" fi Replace NameOfVM with your vm name. Info about notify command: # /usr/local/emhttp/webGui/scripts/notify notify [-e "event"] [-s "subject"] [-d "description"] [-i "normal|warning|alert"] [-m "message"] [-x] [-t] [add] create a notification use -e to specify the event use -s to specify a subject use -d to specify a short description use -i to specify the severity use -m to specify a message (long description) use -x to create a single notification ticket use -t to force send email only (for testing) all options are optional notify init Initialize the notification subsystem. notify smtp-init Initialize sendmail configuration (ssmtp in our case). notify get Output a json-encoded list of all the unread notifications. notify archive file Move file from 'unread' state to 'archive' state.
January 22, 20233 yr Would anyone be willing to explain how to do this to a noob? I've done a ton of Googleing and for the life of me just cannot figure this out. I'm currently running Home Assistant as a VM on Unraid. It works great, but occasionally it will crash. The only way I find out is when some sort of automation won't work or when the wife yells at me about something not working. If I could get a notification when this happens I could restart Home Assistant before anyone runs into issues. Thanks for you help! On 12/31/2021 at 3:30 AM, ghost82 said: Hi, I think it's possible with qemu hooks and notify command available in unraid. Search about hooks for qemu in unraid and create one to push a notification (setup the parameters in unraid), something like this (not tested): #!/bin/bash if [[ $1 == "NameOfVM" ]] && [[ $2 == "stopped" ]] then /usr/local/emhttp/webGui/scripts/notify -i normal -s "VM stopped" fi Replace NameOfVM with your vm name. Info about notify command: # /usr/local/emhttp/webGui/scripts/notify notify [-e "event"] [-s "subject"] [-d "description"] [-i "normal|warning|alert"] [-m "message"] [-x] [-t] [add] create a notification use -e to specify the event use -s to specify a subject use -d to specify a short description use -i to specify the severity use -m to specify a message (long description) use -x to create a single notification ticket use -t to force send email only (for testing) all options are optional notify init Initialize the notification subsystem. notify smtp-init Initialize sendmail configuration (ssmtp in our case). notify get Output a json-encoded list of all the unread notifications. notify archive file Move file from 'unread' state to 'archive' state.
February 13, 20242 yr I would be interested in doing the same thing. There must be an easy way to notify when a VM goes down?
February 13, 20242 yr Community Expert 3 hours ago, The Transplant said: I would be interested in doing the same thing. There must be an easy way to notify when a VM goes down? Here is a simple item you can create in this directory, You will need to chmod +x the file. root@computenode:/etc/libvirt/hooks/qemu.d# cat Notify #!/usr/bin/env php <?php if ($argv[2] == 'started' || $argv[2] == 'stopped'){ shell_exec("/usr/local/emhttp/webGui/scripts/notify -i normal -s \"VM {$argv[1]}\" -d \"".ucfirst($argv[2])."\" >/dev/null 2>&1 & disown") ; } ?> root@computenode:/etc/libvirt/hooks/qemu.d#
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.