director cant send mail notification

This forum was archived to /woltlab and is now in read-only mode.
  • Hi coolegian,
    help to understand why does not send notifications.


    i did it use the article https://www.unixe.de/icinga2-director-notifications/


    Icinga 2.6
    Director 1.2
    MTA - postfix


    i Create Time period and user with email








    i create command and template notification


    Code: zones.d/it-netmon/notification_templates.conf
    1. template Notification "Template For Host" {
    2. command = "email-host"
    3. period = "IT Department 24x7"
    4. states = [ Down, Up ]
    5. types = [ Custom, Problem, Recovery ]
    6. users = [ "Pavel Kozlov" ]
    7. }


    and i create apply notification


    Code: zones.d/it-netmon/notification_apply.conf
    1. apply Notification "IT Department" to Host {
    2. import "Template For Host"
    3. interval = 2h
    4. assign where host.address == "1.1.1.1"
    5. }


    after i run send custom notification - nothing
    script not run.
    if i run script from console, script send correct email

  • Would you please issue on the master:
    icinga2 feature enable debuglog; service icinga2 restart


    and issue your custom notification.
    After that, i would be interested in:


    Code
    1. root@debian85:/var/log/icinga2# grep 'notice/Process' /var/log/icinga2/debug.log | grep scripts
    2. [2016-12-31 16:58:57 +0100] notice/Process: Running command '/etc/icinga2/scripts/mail-service-notification.sh': PID 3130
    3. [2016-12-31 16:58:57 +0100] notice/Process: PID 3130 ('/etc/icinga2/scripts/mail-service-notification.sh') terminated with exit code 0

    and the output of the below, you may shorten that to the host in question:
    icinga2 object list --type notification --name "IT Department"


    Finally, disable the debuglog again:
    icinga2 feature disable debuglog; service icinga2 restart

  • thank you for ansver


    I did what you asked to do.
    i create two notification: force and standard
    force notification i recive, standard not


    log from force notification


    netadmin@it-netmon:/var/log/icinga2$ grep 'notice/Process' /var/log/icinga2/debug.log | grep scripts
    [2016-12-31 19:38:20 +0300] notice/Process: Running command '/etc/icinga2/scripts/host-by-mail.sh' '-a' '1.1.1.4' '-b' 'pkozlov' '-c' 'test 3' '-d' '2016-12-31 19:38:20' '-l' 'it-logmon01' '-o' 'PING OK - Packet loss = 0%, RTA = 0.22 ms' '-r' 'pkozlov@wt.ru' '-s' 'UP' '-t' 'CUSTOM': PID 12917
    [2016-12-31 19:38:21 +0300] notice/Process: PID 12917 ('/etc/icinga2/scripts/host-by-mail.sh' '-a' '1.1.1.4' '-b' 'pkozlov' '-c' 'test 3' '-d' '2016-12-31 19:38:20' '-l' 'it-logmon01' '-o' 'PING OK - Packet loss = 0%, RTA = 0.22 ms' '-r' 'pkozlov@wt.ru' '-s' 'UP' '-t' 'CUSTOM') terminated with exit code 0


    [2016-12-31 19:38:20 +0300] information/ExternalCommandListener: Executing external command: [1483202300] SEND_CUSTOM_HOST_NOTIFICATION;it-logmon01;2;pkozlov;test 3
    [2016-12-31 19:38:20 +0300] information/Checkable: Checking for configured notifications for object 'it-logmon01'
    [2016-12-31 19:38:20 +0300] information/Notification: Sending 'Custom' notification 'it-logmon01!IT Department for user 'Pavel Kozlov'
    [2016-12-31 19:38:20 +0300] information/Notification: Completed sending 'Custom' notification 'it-logmon01!IT Department' for checkable 'it-logmon01' and user 'Pavel Kozlov'.


    root@it-netmon:~# icinga2 object list --type notification --name "IT Department"
    Object 'it-logmon01!IT Department' of type 'Notification':
    % declared in '/var/lib/icinga2/api/packages/director/it-netmon-1483155178-0/zones.d/it-netmon/notification_apply.conf', lines 1:0-1:41
    * __name = "it-logmon01!IT Department"
    * command = "email-host"
    % = modified in '/var/lib/icinga2/api/packages/director/it-netmon-1483155178-0/zones.d/it-netmon/notification_templates.conf', lines 2:5-2:26
    * command_endpoint = ""
    * host_name = "it-logmon01"
    % = modified in '/var/lib/icinga2/api/packages/director/it-netmon-1483155178-0/zones.d/it-netmon/notification_apply.conf', lines 1:0-1:41
    * interval = 7200
    % = modified in '/var/lib/icinga2/api/packages/director/it-netmon-1483155178-0/zones.d/it-netmon/notification_apply.conf', lines 4:5-4:17
    * name = "IT Department"
    * package = "director"
    % = modified in '/var/lib/icinga2/api/packages/director/it-netmon-1483155178-0/zones.d/it-netmon/notification_apply.conf', lines 1:0-1:41
    * period = "IT Department 24x7"
    % = modified in '/var/lib/icinga2/api/packages/director/it-netmon-1483155178-0/zones.d/it-netmon/notification_templates.conf', lines 3:5-3:33
    * service_name = ""
    * states = [ "Down", "Up" ]
    % = modified in '/var/lib/icinga2/api/packages/director/it-netmon-1483155178-0/zones.d/it-netmon/notification_templates.conf', lines 4:5-4:25
    * templates = [ "IT Department", "Template For Host" ]
    % = modified in '/var/lib/icinga2/api/packages/director/it-netmon-1483155178-0/zones.d/it-netmon/notification_apply.conf', lines 1:0-1:41
    % = modified in '/var/lib/icinga2/api/packages/director/it-netmon-1483155178-0/zones.d/it-netmon/notification_templates.conf', lines 1:0-1:40
    * times = null
    * type = "Notification"
    * types = [ "Custom", "Problem", "Recovery" ]
    % = modified in '/var/lib/icinga2/api/packages/director/it-netmon-1483155178-0/zones.d/it-netmon/notification_templates.conf', lines 5:5-5:41
    * user_groups = null
    * users = [ "Pavel Kozlov" ]
    % = modified in '/var/lib/icinga2/api/packages/director/it-netmon-1483155178-0/zones.d/it-netmon/notification_templates.conf', lines 6:5-6:30
    * vars = null
    * zone = "it-netmon"
    % = modified in '/var/lib/icinga2/api/packages/director/it-netmon-1483155178-0/zones.d/it-netmon/notification_apply.conf', lines 1:0-1:41



    P.S. HNY )))

  • I solved the problem )


    it was wrong timeperiod


    at first i did templates and object
    template TimePeriod "Global 24x7" { import "legacy-timeperiod" display_name = "Global 24x7" ranges = { "friday" = "00:00-24:00" "monday" = "00:00-24:00" "saturday" = "00:00-24:00" "thursday" = "00:00-24:00" "tuesday" = "00:00-24:00" "wednesday" = "00:00-24:00" }}


    object TimePeriod "IT Department 24x7" { import "legacy-timeperiod" import "Global 24x7" display_name = "IT Department 24x7" ranges = { }}


    I thought that object "IT Department 24x7" takes the periods from a template.
    i was wrong )


    after i add perion to object notification will sent


    thank you sru for help )))


    P. S. now I don't understand why, then need templates )))

  • P. S. now I don't understand why, then need templates )))

    templates work in a similar manner as include / #include in languages like php or cpp.
    You are not required to use them. Above Object should be rewriteable as: