8

I have setup a nagios monitoring and configured check_http plugin to check for a specific URL in my application. That url returns either 'ok' or an error message.

My nagios sends me an email when it detects something not 'ok'. However what I am getting is only "HTTP CRITICAL - string not found". What I would like to get in email is the actual error message that is returned from my URL. I've tried using the verbose (-v) option. In command line it returns me a complete request including my error message, however nagios email would only send me the first line of the verbose response.

What I would like to get in nagios notification is instead of string not found to get the actual error message. Is there any way to do it using check_http (or may be some other) plugin or do I have to write my own?

Edit: So far I've been using $SERVICEOUTPUT$ in my email notification.

Sergey Golovchenko
  • 18,203
  • 15
  • 55
  • 72

1 Answers1

9

There seems to be two service output macros you can use (from http://nagios.sourceforge.net/docs/3_0/macrolist.html ) in your service notification command definition:

  • $SERVICEOUTPUT$: The first line of text output from the last service check (i.e. "Ping OK").
  • $LONGSERVICEOUTPUT$: The full text output (aside from the first line) from the last service check.

If you aren't successful with those, I guess the easiest path is to write a wrapper for check_http that puts your error message on the first output line.

Anders Lindahl
  • 41,582
  • 9
  • 89
  • 93
  • You will want to add this to your notify-service-by-email command definition, as described [here](http://serverfault.com/questions/410020/full-status-information-in-nagios-email-notification) – storm_m2138 Nov 25 '14 at 19:03
  • Be aware Nagios fills these variables after removing some sensitive characters, for example HTML tags are not preserved. For workaround, see http://serverfault.com/a/648781/256869 . – Tomáš Záluský Dec 03 '14 at 11:34