Xmpp notifications

Hello

I am tryin to configure xmpp notification (on Debian 11)
I installed XMPP Notifications :: Icinga Exchange and test it in CLI it’s worked great
But I’m unable to use it with icinga
When I try to send notification test from WebUI
I’ve got error in icinga log

[2023-02-05 15:35:05 +0100] warning/PluginNotificationTask: Notification command for object 'host.fr' (PID: -1, arguments: 'sh' '-c' '') terminated with exit code 3, output: Error: Non-optional macro 'notification_output' used in argument '-O' is missing.

I tryin to modify the script to make this argument not needed but it’s another error with argument missing …

sudo icinga2 --version
icinga2 - The Icinga 2 network monitoring daemon (version: r2.13.6-1)

System information:
  Platform: Debian GNU/Linux
  Platform version: 11 (bullseye)
  Kernel: Linux
  Kernel version: 5.10.0-20-amd64
  Architecture: x86_64

Build information:
  Compiler: GNU 10.2.1
  Build host: runner-hh8q3bz2-project-575-concurrent-0
  OpenSSL version: OpenSSL 1.1.1n  15 Mar 2022

Application information:

General paths:
  Config directory: /etc/icinga2
  Data directory: /var/lib/icinga2
  Log directory: /var/log/icinga2
  Cache directory: /var/cache/icinga2
  Spool directory: /var/spool/icinga2
  Run directory: /run/icinga2


Disabled features: command compatlog debuglog elasticsearch gelf graphite ido-pgsql influxdb influxdb2 livestatus opentsdb perfdata statusdata syslog
Enabled features: api checker icingadb mainlog notification

Notification is activated

I’ve got set the template conf like this (follow the doc of the script)

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

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

  vars += {
    notification_xmpp_password = "password"
    notification_xmpp_sender = "icinga@host.tld"
    notification_output = "$host.output$"
    notification_state = "$host.state$"
  }

  period = "24x7"
}
template Notification "service-jabber-notification" {
  command = "jabber-notification-command"

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

  vars += {
    notification_xmpp_password = "password"
    notification_xmpp_sender = "icinga@host.tld"
    notification_output = "$service.output$"
    notification_state = "$service.state$"
  }
  period = "24x7"
}

And the command conf

Object 'jabber-notification-command' of type 'NotificationCommand':
  % declared in '/etc/icinga2/zones.d/master/commands.conf', lines 222:1-222:56
  * __name = "jabber-notification-command"
  * arguments
    % = modified in '/etc/icinga2/zones.d/master/commands.conf', lines 225:3-276:3
    * -D
      * required = true
      * value = "$notification_date$"
    * -H
      * required = true
      * value = "$notification_hostname$"
    * -O
      * required = true
      * value = "$notification_output$"
    * -S
      * required = true
      * value = "$notification_state$"
    * -a = "$notification_author$"
    * -c = "$notification_comment$"
    * -d
      * value = "$notification_hostdisplayname$"
    * -e
      * value = "$notification_servicename$"
    * -f
      * description = "JID to send from"
      * required = true
      * value = "$notification_xmpp_sender$"
    * -p
      * description = "Password for XMPP account"
      * required = true
      * value = "$notification_xmpp_password$"
    * -r
      * required = true
      * value = "$notification_userjid$"
    * -t
      * required = true
      * value = "$notification_type$"
    * -u
      * value = "$notification_servicedisplayname$"
  * command = [ "/etc/icinga2/scripts/jabber-notification.py" ]
    % = modified in '/etc/icinga2/zones.d/master/commands.conf', lines 223:3-223:61
  * env = null
  * execute
    % = modified in 'methods-itl.conf', lines 23:3-23:30
    * arguments = [ "notification", "user", "cr", "itype", "author", "comment", "resolvedMacros", "useResolvedMacros" ]
    * deprecated = false
    * name = "Internal#PluginNotification"
    * side_effect_free = false
    * type = "Function"
  * name = "jabber-notification-command"
  * package = "_etc"
  * source_location
    * first_column = 1
    * first_line = 222
    * last_column = 56
    * last_line = 222
    * path = "/etc/icinga2/zones.d/master/commands.conf"
  * templates = [ "jabber-notification-command", "plugin-notification-command" ]
    % = modified in '/etc/icinga2/zones.d/master/commands.conf', lines 222:1-222:56
    % = modified in 'methods-itl.conf', lines 22:2-22:122
  * timeout = 60
  * type = "NotificationCommand"
  * vars
    % = modified in '/etc/icinga2/zones.d/master/commands.conf', lines 278:3-287:3
    * notification_author = "$notification.author$"
    * notification_comment = "$notification.comment$"
    * notification_date = "$icinga.long_date_time$"
    * notification_hostdisplayname = "$host.display_name$"
    * notification_hostname = "$host.name$"
    * notification_servicename = "$service.name$"
    * notification_type = "$notification.type$"
    * notification_userjid = "$userjid$"
  * zone = "master"

And users conf

object User "myuser" {
  import "generic-user"
  vars.userjid = "mycontact@host.tld"
  display_name = "user"
  groups = [ "icingaadmins" ]
  email = bbb@host.tld"
}

object UserGroup "icingaadmins" {
  display_name = "Icinga 2 Admin Group"
}

And in notifications.conf I apply it like this

apply Notification "jabber-host" to Host {
  command = "jabber-notification-command"
  users = [ "myuser" ]
  assign where true
}
apply Notification "jabber-service" to Service {
  command = "jabber-notification-command"
  users = [ "myuser" ]
  assign where true
}

I tryin to switch command use to {service,host}-jabber-notification insteed of jabber-notification-command in command section but unble to relaod icinge because

usage!jabber-service’ of type ‘Notification’; Attribute ‘command’: Object ‘service-jabber-notification’ of type ‘NotificationCommand’ does not exist.

If someone have any idea

What’s the output of icinga running in debug mode (icinga2 daemon -x debug)?

After activate debuglog module and restart Icinga
No more information

[2023-02-05 15:35:05 +0100] information/ApiListener: New client connection from [::ffff:127.0.0.1]:60712 (no client certificate)
[2023-02-05 15:35:05 +0100] notice/ApiListener: New HTTP client
[2023-02-05 15:35:05 +0100] debug/HttpUtility: Request body: '{"author":"user","comment":"test","force":false,"host":"host.tld"}'
[2023-02-05 15:35:05 +0100] notice/ApiActionHandler: Running action send-custom-notification
[2023-02-05 15:35:05 +0100] information/Checkable: Checkable 'host.tld' has 1 notification(s). Checking filters for type 'Custom', sends will be logged.
[2023-02-05 15:35:05 +0100] notice/ApiListener: Relaying 'event::SendNotifications' message
[2023-02-05 15:35:05 +0100] notice/Notification: Attempting to send notifications of type 'Custom' for notification object 'host.tld!jabber-host'.
[2023-02-05 15:35:05 +0100] debug/Notification: Type 'Custom', TypeFilter: Acknowledgement, Custom, DowntimeEnd, DowntimeRemoved, DowntimeStart, FlappingEnd, FlappingStart, Problem and Recovery (FType=8, TypeFilter=-1)
[2023-02-05 15:35:05 +0100] notice/ApiListener: Relaying 'event::SetForceNextNotification' message
[2023-02-05 15:35:05 +0100] debug/Notification: User 'user' notification 'host.tld!jabber-host', Type 'Custom', TypeFilter: Acknowledgement, Custom, DowntimeEnd, DowntimeRemoved, DowntimeStart, FlappingEnd, FlappingStart, Problem and Recovery (FType=8, TypeFilter=-1)
[2023-02-05 15:35:05 +0100] debug/Notification: User 'user' notification 'host.tld!jabber-host', State 'Up', StateFilter: Critical, Down, OK, Unknown, Up and Warning (FState=16, StateFilter=-1)
[2023-02-05 15:35:05 +0100] information/Notification: Sending 'Custom' notification 'host.tld!jabber-host' for user 'user'
[2023-02-05 15:35:05 +0100] warning/PluginUtility: Error: Non-optional macro 'notification_output' used in argument '-O' is missing.
[2023-02-05 15:35:05 +0100] information/HttpServerConnection: Request: POST /v1/actions/send-custom-notification (from [::ffff:127.0.0.1]:60712), user: icingaweb2, agent: GuzzleHttp/6.5.5 curl/7.74.0 PHP/7.4.33, status: OK).
[2023-02-05 15:35:05 +0100] notice/ApiListener: Relaying 'event::NotificationSentToAllUsers' message
[2023-02-05 15:35:05 +0100] warning/PluginNotificationTask: Notification command for object 'host.tld' (PID: -1, arguments: 'sh' '-c' '') terminated with exit code 3, output: Error: Non-optional macro 'notification_output' used in argument '-O' is missing.
[2023-02-05 15:35:05 +0100] information/Notification: Completed sending 'Custom' notification 'host.tld!jabber-host' for checkable 'host.tld' and user 'user' using command 'jabber-host'.
[2023-02-05 15:35:05 +0100] notice/ApiListener: Relaying 'event::NotificationSentUser' message
[2023-02-05 15:35:05 +0100] information/HttpServerConnection: HTTP client disconnected (from [::ffff:127.0.0.1]:60712)

seems similar

Looks like a configuration error.

Yeah that’s what I said
I finally change some var to put in into command conf directly and it’s worked

/etc/icinga2/zones.d/master/commands.conf
...
    notification_output = "$output$"
    notification_state = "$state$"
    notification_xmpp_password = "password"
    notification_xmpp_sender = "icinga@myhost.tld"

And remove/change from /etc/icinga2/zones.d/master/templates.conf (look like this now)

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

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

  vars += {
    notification_output = "$output$"
    notification_state = "$state$"
  }

  period = "24x7"
}
template Notification "service-jabber-notification" {
  command = "jabber-notification-command"

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

  vars += {
    notification_output = "$output$"
    notification_state = "$state$"
  }
  period = "24x7"
}

and it’s worked !

[2023-02-05 22:08:04 +0100] information/Notification: Completed sending 'Custom' notification 'domain.tld!tcp!jabber-service' for checkable 'domain.tld!tcp' and user 'user' using command 'jabber-notification-command'.

1 Like