Pushover notification with Icinga 2

Here is the quick guide to making your Icinga 2 do notifications using the Pushover service.
Sorry for the brevity.

You need to create one file - notify_by_pushover2.sh in my example. Permissions on that file need to be like the existing files in the same folder. My script is based on what i learnt from the script found in Using Pushover to push Nagios notifications.

You need to edit four files: commands.conf, templates.conf, notifications.conf and users.conf. This is assuming the out of the box default configuration files are used.
The text that i show in my examples below is text that you should add to the existing configuration files, you should not replace the existing text in those files.

In my example notifications.conf i use some assign where that relate to mail. I am sure this could be done better.

Hope this will help you.

/etc/icinga2/scripts/notify_by_pushover2.sh

#!/bin/sh 

curl -F "token=$PUSHOVERTOKEN" \ 
-F "user=$PUSHOVERUSER" \ 
-F "title=$PUSHOVERTITLE" \ 
-F "message=$PUSHOVERMESSAGE" \ 
https://api.pushover.net/1/messages 

exit 0 

/etc/icinga2/conf.d/commands.conf

object NotificationCommand "pushover-host-notification" { 
import "plugin-notification-command" 

command = [ SysconfDir + "/icinga2/scripts/notify_by_pushover2.sh" ] 

env = { 
    PUSHOVERUSER = "$user.vars.pushover_user$" 
    PUSHOVERTOKEN = "$user.vars.pushover_token$" 
    PUSHOVERTITLE = "Icinga Skanderborg" 
    PUSHOVERMESSAGE = "$notification.type$ $host.display_name$ $host.state$ $icinga.long_date_time$" 
  } 
} 

object NotificationCommand "pushover-service-notification" { 
  import "plugin-notification-command" 

  command = [ SysconfDir + "/icinga2/scripts/notify_by_pushover2.sh" ] 

  env = { 
    PUSHOVERUSER = "$user.vars.pushover_user$" 
    PUSHOVERTOKEN = "$user.vars.pushover_token$" 
    PUSHOVERTITLE = "Icinga" 
    PUSHOVERMESSAGE = "$notification.type$ $host.display_name$ $service.display_name$ $service.state$ $icinga.long_date_time$" 
  } 
} 

/etc/icinga2/conf.d/templates.conf

template Notification "pushover-host-notification" { 
  command = "pushover-host-notification" 

  states = [ Up, Down ] 
  types = [ Problem, Acknowledgement, Recovery, Custom, 
        FlappingStart, FlappingEnd, 
        DowntimeStart, DowntimeEnd, DowntimeRemoved ] 

  period = "24x7" 
} 

template Notification "pushover-service-notification" { 
  command = "pushover-service-notification" 

  states = [ OK, Warning, Critical, Unknown ] 
  types = [ Problem, Acknowledgement, Recovery, Custom, FlappingStart, FlappingEnd, DowntimeStart, DowntimeEnd, DowntimeRemoved ] 

  period = "24x7" 
} 

/etc/icinga2/conf.d/notifications.conf

apply Notification "pushover-icingaadmin" to Host { 
  import "pushover-host-notification" 

  user_groups = host.vars.notification.mail.groups 
  users = host.vars.notification.mail.users 

  assign where host.vars.notification.mail 
  interval = 0 // disable re-notification 
} 


apply Notification "pushover-icingaadmin" to Service { 
  import "pushover-service-notification" 

  user_groups = host.vars.notification.mail.groups 
  users = host.vars.notification.mail.users 

  assign where host.vars.notification.mail 
  interval = 0 // disable re-notification 
} 

/etc/icinga2/conf.d/users.conf

object User "icingaadmin" { 
  import "generic-user" 

  display_name = "Icinga 2 Admin" 
  groups = [ "icingaadmins" ] 

  email = "admin@bruntt.dk" 
  vars.pushover_user = "YOUR PUSHOVER USER TOKEN HERE" 
  vars.pushover_token = "YOUR PUSHOVER APPLICATION TOKEN HERE" 

}