E-mail Notification Struggle

I have been trying to get e-mail notifications working from my Iconga install for quite some time and struggling royally. Despite services being down, I never seem to get an e-mail. I’ve captured my configuration below and hope someone can help me find the problem and fix my configuration

**Notification configuration: **

apply Notification "apply-service-down-notification" to Service {
    import "service-down-notification"

    assign where match("*", service.name)
    user_groups = [ "icinga-notifications" ]
}
template Notification "service-down-notification" {
    command = "email_service_notification"
    states = [ Critical, Warning ]
    types = [ Problem, Recovery ]
    user_groups = [ "icinga-notifications" ]
}

User and group configuration:

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

    display_name = "Icinga Notification"
    email = "art@xxx.xxx"
    pager = "4125551212@tmomail.net"
    groups = [ "icinga-notifications" ]
}
template User "generic-notification-user" {
    enable_notifications = true
    states = [ Critical, Down, Warning ]
    types = [ FlappingEnd, FlappingStart, Problem, Recovery ]
}
object UserGroup "icinga-notifications" {
    display_name = "Icinga Service Alert Notifications"
}

Commands:

object NotificationCommand "email_service_notification" {
    import "plugin-notification-command"
    command = [ "/etc/icinga2/scripts/mail-service-notification.sh" ]
    arguments += {
        notification_address = {
            description = "The host’s IPv4 address. Defaults to $address$."
            order = 11
            required = false
            value = "$address$"
        }
        notification_author = {
            description = "Comment author. Defaults to $notification.author$."
            order = 12
            required = false
            value = "$notification.author$"
        }
        notification_comment = {
            description = "Comment text. Defaults to $notification.comment$."
            order = 13
            required = false
            value = "$notification.comment$"
        }
        notification_date = {
            description = "Date and time. Defaults to $icinga.long_date_time$."
            order = 1
            required = true
            value = "$icinga.long_date_time$"
        }
        notification_from = {
            description = "Define a valid From: string. Default \"Icinga 2 Host Monitoring <notifications@unknownrealm.org>\""
            order = 13
            required = false
            value = "Icinga Host Monitoring <notifications@unknownrealm.org>"
        }
        notification_hostdisplayname = {
            description = "Host display name. Defaults to $host.display_name$."
            order = 4
            required = true
            value = "$host.display_name$"
        }
        notification_hostname = {
            description = "The host’s FQDN. Defaults to $host.name$."
            order = 2
            required = true
            value = "$host.name$"
        }
        notification_icingaweb2url = {
            description = "URL to your Icinga Web 2. Defaults to 'https://tatooine.unknownrealm.org/icingaweb2.'"
            order = 14
            required = false
            value = "https://tatooine.unknownrealm.org/icingaweb2"
        }
        notification_logtosyslog = {
            description = "Set true to log notification events to syslog; useful for debugging. Defaults to false."
            order = 14
            required = false
            value = "false"
        }
        notification_servicedisplayname = {
            description = "Service display name. Defaults to $service.display_name$."
            order = 5
            required = true
            value = "$service.display_name$"
        }
        notification_servicename = {
            description = "The service name. Defaults to $service.name$."
            order = 3
            required = true
            value = "$service.name$"
        }
        notification_serviceoutput = {
            description = "Output from service check. Defaults to $service.output$."
            order = 6
            required = true
            value = "$service.output$"
        }
        notification_servicestate = {
            description = "Current state of host. Defaults to $service.state$."
            order = 8
            required = true
            value = "$service.state$"
        }
        notification_type = {
            description = " Type of notification. Defaults to $notification.type$."
            order = 9
            required = true
            value = "$notification.type$"
        }
        notification_useremail = {
            description = " The notification’s recipient(s). Defaults to $user.email$."
            order = 7
            required = true
            value = "$user.email$"
        }
    }
}

tail of /var/log/icinga2/icinga2.log

[2025-02-25 21:25:16 -0500] information/Checkable: Checkable 'deathstar.xxxxxxxxxxxxxxxxxxx.org!LMS' has 1 notification(s). Checking filters for type 'Problem', sends will be logged.
[2025-02-25 21:25:16 -0500] information/Notification: Sending 'Problem' notification 'deathstar.xxxxxxxxxxxxxxxxxxx.org!LMS!apply-service-down-notification' for user 'notification'
[2025-02-25 21:25:16 -0500] information/Notification: Completed sending 'Problem' notification 'deathstar.xxxxxxxxxxxxxxxxxxx.org!LMS!apply-service-down-notification' for checkable 'deathstar.xxxxxxxxxxxxxxxxxxx.org!LMS' and user 'notification' using command 'email_service_notification'.
[2025-02-25 21:25:16 -0500] warning/PluginNotificationTask: Notification command for object 'deathstar.xxxxxxxxxxxxxxxxxxx.org!LMS' (PID: 1383220, arguments: '/etc/icinga2/scripts/mail-service-notification.sh' 'notification_date' '2025-02-25 21:25:16 -0500' 'notification_hostname' 'deathstar.xxxxxxxxxxxxxxxxxxx.org' 'notification_servicename' 'LMS' 'notification_hostdisplayname' 'deathstar' 'notification_servicedisplayname' 'LMS' 'notification_serviceoutput' 'CRITICAL - Socket timeout after 10 seconds' 'notification_useremail' 'art@xxxxxxxxxxxxxxxxxxx.org' 'notification_servicestate' 'CRITICAL' 'notification_type' 'PROBLEM' 'notification_address' '192.168.0.1' 'notification_author' '' 'notification_comment' '' 'notification_from' 'Icinga Host Monitoring <notifications@xxxxxxxxxxxxxxxxxxx.org>' 'notification_icingaweb2url' 'https://tatooine.xxxxxxxxxxxxxxxxxxx.org/icingaweb2' 'notification_logtosyslog' 'false') terminated with exit code 1, output: Required parameter 'LONGDATETIME' is missing.

So I dug into this a bit more and I realized that the Arguments on my commands were specified incorrectly. I need to use the actual parameter names.

ie: for my service notification, i needed to use these parameter names

Once i had that all correct, it worked as expected!

I am glad you were able to fix this. I marked it as solved.

Please note, the log already contained an explaining error.

[....] terminated with exit code 1, output: Required parameter 'LONGDATETIME' is missing.
1 Like