Page 1 of 1

send warning/critical notifications

Posted: Wed Jul 22, 2020 12:19 pm
by jh129666
For a given service, I want to send warning notifications to an email contact and critical notifications to a file on our nagios server. I have things setup and the warning notifications are working but the critical notifications are not getting written to the file on our nagios server. I'm thinking it's a configuration issue but I haven't been able to figure it out yet.

Here's the service configuration.

define service {
host_name abc123.prod.com
service_description LnM db: AUDIT_2021 - warning 20 GB -- critical 10 GB
use oraclequery_service_warning
check_command check_xi_oraclequery!--connect '12.345.67.89:1521/lmnor' --username 'xxxxx' --password 'abc123' --mode tablespace-free --name AUDIT_2021 --units GB --warning 20: --critical 10:!!!!!!!
contact_groups +dbas_service_prod_critical
register 1
}

Here's the oraclequery_service_warning template.

define service {
name oraclequery_service_warning
check_command check_xi_oraclequery!!!!!!!!
max_check_attempts 2
check_interval 60
retry_interval 5
check_period xi_timeperiod_24x7
high_flap_threshold 45
notification_interval 60
notification_period 24x7-Prod
notification_options w,
notifications_enabled 1
contacts dbaops-email
register 0
}


Here's the dbas_service_prod_critical contact group.

define contactgroup {
contactgroup_name dbas_service_prod_critical
alias DBAs alarmpoint prod
members dbaops-alarmpoint-24x7
}


Here's the dbaops-alarmpoint-24x7 contact.

define contact {
contact_name dbaops-alarmpoint-24x7
alias alarmpoint interface - critical db services
host_notifications_enabled 0
service_notifications_enabled 1
host_notification_period 24x7-Prod
service_notification_period 24x7-Prod
host_notification_options d,u,r,
service_notification_options c,
host_notification_commands notify-host-by-email-html
service_notification_commands dbas-service-notify-alarmpoint
use xi_contact_generic
}


Here's the dbas-service-notify-alarmpoint command.

define command {
command_name dbas-service-notify-alarmpoint
command_line /usr/bin/printf "%b" "|2|HTS-Database-Operations|****SERVICE:$SERVICEDESC$ ****HOST:$HOSTALIAS$ ****ADDRESS:$HOSTADDRESS$ ****STATE:$SERVICESTATE$ ****DATE/TIME:$LONGDATETIME$ ****ADDITIONAL INFO:$SERVICEOUTPUT$$LONGSERVICEOUTPUT$\n" >> /opt/NagiosAlert/NagiosAlertsCreateAutomatedTickets
}

Re: send warning/critical notifications

Posted: Thu Jul 23, 2020 12:51 pm
by benjaminsmith
HI,

So for the service, you have it set to notify the contact for a warning state, so it's not going to trigger any notification handlers when it's in a critical state.

For writing log information on critical states, you could set this up as an event handler. Event handlers are triggered on state changes and you can set up the logic of the script to check the state and then write to the log file when it's critical, the following guide has some detailed instructions on how to do this in Nagios XI.

Introduction to Event Handlers

Also, this data is kept in the nagios.log, so you could set up scheduled reporting on this service, take a look at the State History report.

Let us know if you have any more questions.

Benjamin

Re: send warning/critical notifications

Posted: Mon Jul 27, 2020 12:28 pm
by jh129666
Thanks for the info!!

I thought there was a way this could be done using object inheritance with a template such that a different contact method (writing to a specific file on the nagios server) would be used for a critical state.

https://assets.nagios.com/downloads/nag ... tance.html

Re: send warning/critical notifications

Posted: Mon Jul 27, 2020 4:01 pm
by benjaminsmith
Hi,

Right now the notification handler will not execute on critical since the service template is set to only notify on warning. Try changing that to critical as well and let me know if it works now.
define service {
name oraclequery_service_warning
check_command check_xi_oraclequery!!!!!!!!
max_check_attempts 2
check_interval 60
retry_interval 5
check_period xi_timeperiod_24x7
high_flap_threshold 45
notification_interval 60
notification_period 24x7-Prod
notification_options w,
notifications_enabled 1
contacts dbaops-email
register 0
}
Also, if your still having an issue, send over your system profile and I can view the objects.cache file to see the final object definitions.

To send us your system profile.
Login to the Nagios XI GUI using a web browser.
Click the "Admin" > "System Profile" Menu
Click the "Download Profile" button
Save the profile.zip file and share in a private message or upload it to the post/ticket, and then reply to this post to bring it up in the queue.

Re: send warning/critical notifications

Posted: Tue Jul 28, 2020 10:52 am
by jh129666
Thanks for the additional info.

I'm going to create a service escalation and see if I can get it working that way.

You can go ahead and lock this.

Re: send warning/critical notifications

Posted: Tue Jul 28, 2020 2:46 pm
by scottwilkerson
jh129666 wrote:Thanks for the additional info.

I'm going to create a service escalation and see if I can get it working that way.

You can go ahead and lock this.
Great!

Locking thread