Error when deploying Apply Rule for Notifications

I am trying to create a test Apply Rule for my Notification Template, configuration is as follows:

Notification Template:

Apply Rule:

When trying to deplay i receive the following Error for all host that mach the apply rule.:

[2020-10-21 13:55:24 +0200] critical/config: Error: Validation failed for object 'myhost!Test Notification' of type 'Notification'; Attribute 'command': Object 'mail-host-notification' of type 'NotificationCommand' does not exist.
Location: in [stage]/zones.d/myendpoint/notification_templates.conf: 5:5-5:38
[stage]/zones.d/myendpoint/notification_templates.conf(3):         begin = 5s
[stage]/zones.d/myendpoint/notification_templates.conf(4):     }
[stage]/zones.d/myendpoint/notification_templates.conf(5):     command = "mail-host-notification"
[stage]/zones.d/myendpoint/notification_templates.conf(6):     interval = 0s
[stage]/zones.d/myendpoint/notification_templates.conf(7):     states = [ Critical, Down, Unknown, Up ]

I have the mail-host-notification command as an “external command” in director, its config is as follows:

object NotificationCommand "mail-host-notification" {
    import "plugin-notification-command"
    command = [ "/etc/icinga2/scripts/" ]
    timeout = 1m
    arguments += {
        "-4" = "$notification_address$"
        "-6" = "$notification_address6$"
        "-b" = "$notification_author$"
        "-c" = "$notification_comment$"
        "-d" = {
            required = true
            value = "$notification_date$"
        "-f" = {
            description = "Set from address. Requires GNU mailutils (Debian/Ubuntu) or mailx (RHEL/SUSE)"
            value = "$notification_from$"
        "-i" = "$notification_icingaweb2url$"
        "-l" = {
            required = true
            value = "$notification_hostname$"
        "-n" = {
            required = true
            value = "$notification_hostdisplayname$"
        "-o" = {
            required = true
            value = "$notification_hostoutput$"
        "-r" = {
            required = true
            value = "$notification_useremail$"
        "-s" = {
            required = true
            value = "$notification_hoststate$"
        "-t" = {
            required = true
            value = "$notification_type$"
        "-v" = "$notification_logtosyslog$"
    vars.notification_address = "$address$"
    vars.notification_address6 = "$address6$"
    vars.notification_author = "$$"
    vars.notification_comment = "$notification.comment$"
    vars.notification_date = "$icinga.long_date_time$"
    vars.notification_hostdisplayname = "$host.display_name$"
    vars.notification_hostname = "$$"
    vars.notification_hostoutput = "$host.output$"
    vars.notification_hoststate = "$host.state$"
    vars.notification_type = "$notification.type$"
    vars.notification_useremail = "$$"

If you need any further Information please don’t hesitate to let me know.
Thank you in advance.
(also how do i properly format the cli text?)

Hello and welcome to the community!

Here you have a handy markdown guide :slight_smile:

1 Like

Hi and Thanks!
I’ve edited the codeblocks for readabilty

1 Like

I’d assume your mail-host-notification object is no longer active e.g. you have disabled inclusion of /etc/icinga2conf.d at a later time. Please verify with

icinga2 object list -n mail-host-notification

1 Like

icinga2 object list -n mail-host-notification

returns nothing

I remember disabeling the inclusion of the conf.d directory somewhere along the line while installing director.

What would be the steps to include the mail-host/service-notification objects?

Hmm, that depends on your environment e.g. if you’ll have satellites. Without easiest way is to add it to your icinga2.conf e.g.:

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

Another option is to move commands.conf to your master’s directory e.g. /etc/icinga2/zones.d/master (where the dirname master must match your master zone name).

Third option is to move commands.conf to /etc/icinga2/zones.d/global-zones. It will be automatically distributed to all satellites.

1 Like

Thank you, as I intend to deploy satellites in the future, i’ve used option three and now everything seems to be working.