Sending a test message from an OK check
Sending a test message from an OK check
I want to be able to send a test message from a service check that is OK. I there a way to use notify-by-email with check_nrpe from the command line and get it to send the results no matter if it is OK or not?
Re: Sending a test message from an OK check
Not from check_nrpe but there is a link in the right hand "service commands" control panel when you are on a service information screen that says "Send custom service notification" which might be what you are after?
Re: Sending a test message from an OK check
I didn't want to send a message to the whole notification list. I tried creating a copy of the service check and set the alerts to go to just me, but it never sends anything. All other emails work fine. However this service check wants to send alerts as an attachment to an email instead of a regular text email like everything else.
Re: Sending a test message from an OK check
That... doesn't sound good.What's the actual problem that you are experiencing that you are trying to test for? What does your email notify command look like?
Re: Sending a test message from an OK check
I have a service that runs check_nrpe to a particular host, where it runs a remote script that looks for a data file that gets created every night. If the data file is not found, it should send an email to our ticket system that automatically generates a ticket based on the content of the email. However, for some reason this particular alert gets sent as an email attachment with a blank email, so no ticket gets generated.
This is my email command, same one I use for about a thousand other service checks:
define command {
command_name notify-by-email
command_line /usr/bin/printf "%b" "Notification Type: $NOTIFICATIONTYPE$\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\nDate/Time: $LONGDATETIME$\nAdditional Info:\n$SERVICEOUTPUT$" | /usr/bin/mailx -s "$SERVICESTATE$ $HOSTNAME$/$SERVICEDESC$" $CONTACTEMAIL$
}
If I run the check_nrpe from a command line, this is what I get back:
nagios@nag01e:~/libexec> ./check_nrpe -H myhost -c check_data_file
OK: D:\\Interface Data\\Data Archive\\POS Data\\2012\\2012-03\\03-28-2012\\CHECK_DATA_*.txt found.
I suspect the escape characters for the directories might be causing a problem, and I want to be able to test sending the alert even if it is OK so that I can troubleshoot the format.
This is my email command, same one I use for about a thousand other service checks:
define command {
command_name notify-by-email
command_line /usr/bin/printf "%b" "Notification Type: $NOTIFICATIONTYPE$\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\nDate/Time: $LONGDATETIME$\nAdditional Info:\n$SERVICEOUTPUT$" | /usr/bin/mailx -s "$SERVICESTATE$ $HOSTNAME$/$SERVICEDESC$" $CONTACTEMAIL$
}
If I run the check_nrpe from a command line, this is what I get back:
nagios@nag01e:~/libexec> ./check_nrpe -H myhost -c check_data_file
OK: D:\\Interface Data\\Data Archive\\POS Data\\2012\\2012-03\\03-28-2012\\CHECK_DATA_*.txt found.
I suspect the escape characters for the directories might be causing a problem, and I want to be able to test sending the alert even if it is OK so that I can troubleshoot the format.
Re: Sending a test message from an OK check
Oh I see, what I normally do in these scenarios as a first port of call (1. because I'm lazy and 2. well... because I'm lazy) is just manually fill in an email with the output exactly as Nagios would and then attempt to send it manually.
If it works properly I begin to worry about what Nagios may or may not be doing and how I can set up a test case, if it doesn't then I try to work out what will fix it on the command line first.
Give that a go first
If it works properly I begin to worry about what Nagios may or may not be doing and how I can set up a test case, if it doesn't then I try to work out what will fix it on the command line first.
Give that a go first
Re: Sending a test message from an OK check
Tried all that and the string works using sendmail from the nagios server. I think now it is the NSClient++ and powershell script on the client side is sending the message back with some windows encoding even though it looks fine at the command line. Nagios forwards the message with the encoding to our email server where is is interpreted as "base64" instead of us-ascii. Our email server then bundles it as an attachment.
As a work-around, I'm going to have the powershell write a simpler message, or change "\\" to "/", which works just fine. So long as the Windows guys dont give me grief about not having their backwards directory whacks in the message it's all good.
As a work-around, I'm going to have the powershell write a simpler message, or change "\\" to "/", which works just fine. So long as the Windows guys dont give me grief about not having their backwards directory whacks in the message it's all good.
Re: Sending a test message from an OK check
Hmmm we have a couple of powershell scripts but haven't run into this problem... but I don't think we have \'s as an output character. I know with Powershell and outputting to a file you can change the encoding with the -Encoding switch... maybe there's a similar switch for standard out?