0

I use Nagios Core 4.4.6. I want Nagios to send services email notifications. I've used notify-host-by-email already and now want to use notify-service-by-email. If I use 'Send custom service notification' it success. But auto-alerts doesn't work.

templates.cfg

define contact {

name                            generic-contact         ; The name of this contact template
service_notification_period     24x7                    ; service notifications can be sent anytime
host_notification_period        24x7                    ; host notifications can be sent anytime
service_notification_options    w,u,c,r,f,s             ; send notifications for all service states,$
host_notification_options       d,u,r,f,s               ; send notifications for all host states, fl$
service_notification_commands   notify-service-by-email ; send service notifications via email
host_notification_commands      notify-host-by-email    ; send host notifications via email
register                        0                       ; DON'T REGISTER THIS DEFINITION - ITS NOT A$
}


define host {

name                            generic-host            ; The name of this host template
notifications_enabled           1                       ; Host notifications are enabled
event_handler_enabled           1                       ; Host event handler is enabled
flap_detection_enabled          0                       ; Flap detection is enabled
process_perf_data               1                       ; Process performance data
retain_status_information       1                       ; Retain status information across program r$
retain_nonstatus_information    1                       ; Retain non-status information across progr$
notification_period             24x7                    ; Send host notifications at any time
register                        0                       ; DON'T REGISTER THIS DEFINITION - ITS NOT A$
}


define host {

name                            linux-server            ; The name of this host template
use                             generic-host            ; This template inherits other values from t$
check_period                    24x7                    ; By default, Linux hosts are checked round $
check_interval                  5                       ; Actively check the host every 5 minutes
retry_interval                  1                       ; Schedule host check retries at 1 minute in$
max_check_attempts              10                      ; Check each Linux host 10 times (max)
check_command                   check-host-alive        ; Default command to check Linux hosts
notification_period             workhours               ; Linux admins hate to be woken up, so we on$
                                                        ; Note that the notification_period variable$
                                                        ; the value that is inherited from the gener$
notification_interval           120                     ; Resend notifications every 2 hours
notification_options            d,u,r                   ; Only send notifications for specific host $
contact_groups                  admins                  ; Notifications get sent to the admins by de$
register                        0                       ; DON'T REGISTER THIS DEFINITION - ITS NOT A$
}


define service {

name                            generic-service         ; The 'name' of thi$
active_checks_enabled           1                       ; Active service ch$
passive_checks_enabled          1                       ; Passive service c$
parallelize_check               1                       ; Active service ch$
obsess_over_service             1                       ; We should obsess $
check_freshness                 0                       ; Default is to NOT$
notifications_enabled           1                       ; Service notificat$
event_handler_enabled           1                       ; Service event han$
flap_detection_enabled          1                       ; Flap detection is$
process_perf_data               1                       ; Process performan$
retain_status_information       1                       ; Retain status inf$
retain_nonstatus_information    1                       ; Retain non-status$
is_volatile                     0                       ; The service is no$
check_period                    24x7                    ; The service can b$
max_check_attempts              3                       ; Re-check the serv$
check_interval                  10                      ; Check the service$
retry_interval                  2                       ; Re-check the serv$
contact_groups                  admins                  ; Notifications get$
notification_options            w,u,c,r                 ; Send notification$
notification_interval           60                      ; Re-notify about s$
notification_period             24x7                    ; Notifications can$
register                        0                       ; DON'T REGISTER TH$
}



# Local service definition template
# This is NOT a real service, just a template!

define service {

name                            local-service           ; The name of this $
use                             generic-service         ; Inherit default v$
max_check_attempts              4                       ; Re-check the serv$
check_interval                  5                       ; Check the service$
retry_interval                  1                       ; Re-check the serv$
register                        0                       ; DONT REGISTER THI$
}

test_server.cfg

define host {

use                     linux-server
host_name               test_server
alias                   test_server
address                 111.111.111.11 ; sample address
notification_interval   5
notification_period     24x7
}

define service {

use                     local-service           ; Name of service template to use
host_name               test_server
service_description     PING
check_command           check_ping!100.0,20%!500.0,60%
}

define service {

use                     local-service           ; Name of service template to use
host_name               test_server
service_description     SSH
check_command           check_ssh
notification_interval   5
}



define service {

use                     local-service           ; Name of service template to use
host_name               test_server
service_description     HTTP
check_command           check_http
notification_interval   5


  }

contacts.cfg

define contact {

contact_name            nagiosadmin             ; Short name of user
use                     generic-contact         ; Inherit default values from generic-contact templa$
alias                   Nagios Admin            ; Full name of user
email                   gmail@gmail.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****$
}

define contactgroup {

contactgroup_name       admins
alias                   Nagios Administrators
members                 nagiosadmin
}

How can I force nagios to send notification about services alerts?

  • I am not sure, but take a look to your Nagios logs for a clue. Do you see in web UI that notification settings is enabled for that service? – Rohlik Jul 02 '21 at 10:28
  • All the notifications are enabled and notification options are Unknown, Warning, Critical, Recovery. Check and notification periods are 24x7 and my email in contacts. Also all types of notifications enabled for my contact. Services doesn't work all day and I have not received any notifications. – Владислав Гнатюк Jul 02 '21 at 12:20
  • "doesn't work all day" - this can be a problem, because notifications are send when state change occurs. Can you try fix your monitored service and see if you will receive email? – Rohlik Jul 03 '21 at 21:01
  • "doesn't work all day" - I mean that service was OK and than CRITICAL for whole day. Also I doesn't have any notifications about recovery services(when it recover of course). – Владислав Гнатюк Jul 05 '21 at 05:34

0 Answers0