I created a script that builds a String to echo to the "send_nsca" command to send a Passive Check to Nagios using NSCA Plugin.
In the Message String I send to Nagios I added a couple HTML Tags like <b> and <i> for certain circumstances to make it standout from the rest of the
Services listed on the "Services Page" in a browser.
This works just fine, but when I get the email notification for this Service I can see that the <b> and <i> tags are getting the "<" & ">" angled
brackets removed and it is printing a lonely "i" and/or "b"... I'm assuming the angled-brackets are being removed because they are in the "illegal characters" in
the "nagios.cfg" Config File.
But anyway, this can get confusing for someone who doesn't know why they are there. So I was trying to pipe a "sed" command to the Notification Command "notify-by-email-test".
Which is a test command I setup to try and pipe it to sed. The test Notification Command is the exact same thing as the "notify-by-email Command except that I added the sed command
to the end of the "command_line" Line.
For Example: *Here is my test Notification Command. I simply added "i" to be removed and replaced Globally with nothing.
Code: Select all
define command{
command_name notify-by-email
command_line /usr/bin/printf "%b" "***** Nagios 3.2.3 *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ | sed 's/i//g'
}
So I guess it would be helpful to know, WHEN does Nagios replace the "Macros" (i.e. the Variables) with their actual values...?
If anyone has ANY suggestions please feel free to reply.
Thoughts:
Just thought of something right before submitting this post... I should probably pipe the printf to sed then pipe that to mail...?
So it would basically look something like this:
/usr/bin/printf "message_string" | sed '/search/replace/' | /bin/mail -s "subject" contactAddress
I will try it this way and post back with my results...
Thanks in Advance,
Matt