Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Get notifications when a VM has stopped

Featured Replies

Is there a plugin, container or app that can send a notification (email or other) when an VM has stopped?

Edited by FransHalsjes

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.

 

  • 1 year later...

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.

 

 

  • 1 year later...

I would be interested in doing the same thing.  There must be an easy way to notify when a VM goes down?

  • 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# 

image.png

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.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.