Page 1 of 2
Email Notification - Is there a way to display the error?
Posted: Wed Aug 02, 2017 8:53 am
by JohnnieDaimler
I want my email notification to display the error it finds. Is there a way?
Re: Email Notification - Is there a way to display the error
Posted: Wed Aug 02, 2017 9:23 am
by mcapra
You would have to edit the command definition associated with your notification handler. This documentation describes all the macros you will have available for Host Notifications and Service Notifications:
https://assets.nagios.com/downloads/nag ... olist.html
You might find the documentation for these macros particularly relevant as they give the output of the plugin associated with the host/service:
Code: Select all
$SERVICEOUTPUT$
$LONGSERVICEOUTPUT$
$HOSTOUTPUT$
$LONGHOSTOUTPUT$
In my mind, you could just append the
$SERVICEOUTPUT$ or
$HOSTOUTPUT$ to your message body.
Re: Email Notification - Is there a way to display the error
Posted: Wed Aug 02, 2017 12:49 pm
by tmcdonald
Thanks for the assist,
@mcapra! OP, let us know if you need further assistance.
Re: Email Notification - Is there a way to display the error
Posted: Thu Aug 03, 2017 8:05 am
by JohnnieDaimler
I already attached the SERVICEOUTPUT macro. I'm getting the following on my email body.
WARNING - (1 warnings) - 08-01 20:36:37.553
I want a more detailed message of the error. Is there a way to edit the SERVICEOUTPUT response to display what the warning is? Note, that I'm scanning a .log file searching for an err pattern.
Re: Email Notification - Is there a way to display the error
Posted: Thu Aug 03, 2017 10:53 am
by mcapra
JohnnieDaimler wrote:
I want a more detailed message of the error. Is there a way to edit the SERVICEOUTPUT response to display what the warning is?.
Try
$LONGSERVICEOUTPUT$. Those macros only return whatever the plugin your check uses returned to
stdout. If your plugin isn't returning specific enough data, there's no modification that can be made to the macro to work around that.
If that doesn't give you what you're looking for, can you share the output of your check command executed from the CLI of your Nagios Core machine?
Re: Email Notification - Is there a way to display the error
Posted: Thu Aug 03, 2017 1:59 pm
by JohnnieDaimler
I attached the command as a screenshot. I'm getting a nothing back on the LONGSERVICEOUT marco
Re: Email Notification - Is there a way to display the error
Posted: Thu Aug 03, 2017 2:07 pm
by JohnnieDaimler
I'm guessing there isn't a way to attach the log file to the email is there?
Re: Email Notification - Is there a way to display the error
Posted: Thu Aug 03, 2017 2:14 pm
by mcapra
I'm actually looking for the command that produces this output:
Code: Select all
WARNING - (1 warnings) - 08-01 20:36:37.553
Not the command you are using for your notifications. Again, the various OUTPUT macros rely completely and entirely on what the plugin gives you, so it's valuable to know what, if anything, a given plugin produces.
For example, here's the output for an execution of the check_http plugin:
Code: Select all
[root@nagios ~]# /usr/local/nagios/libexec/check_http -H www.google.com
HTTP OK: HTTP/1.1 200 OK - 11974 bytes in 0.086 second response time |time=0.085856s;;;0.000000 size=11974B;;;0
If I were to include this plugin in a
service definition as part of it's
check_command, I would expect notifications for this service to have
$SERVICEOUTPUT$ return something like the following:
Code: Select all
HTTP OK: HTTP/1.1 200 OK - 11974 bytes in 0.086 second response time
Re: Email Notification - Is there a way to display the error
Posted: Thu Aug 03, 2017 2:38 pm
by JohnnieDaimler
Ok, where would I find out what plugin the service uses?
Re: Email Notification - Is there a way to display the error
Posted: Thu Aug 03, 2017 2:53 pm
by JohnnieDaimler
I believe that this service is using the check_nrpe plugin....note that I didn't create all the commands and services