<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.24.5">
</HEAD>
<BODY>
I read the following on <A HREF="http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOUTPUT">http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOUTPUT</A> :<BR>
<BR>
<B><I><FONT SIZE="2">2.1. Print only one line of text</FONT></I></B><BR>
<I><FONT SIZE="2">Nagios will only grab the first line of text from STDOUT when it notifies contacts about potential problems. If you print multiple lines, you're out of luck (though this will be a feature of Nagios 3). Remember, keep your output short and to the point.</FONT></I><BR>
<BR>
<I><FONT SIZE="2">Output should be in the format:</FONT></I><BR>
<BR>
<I><FONT SIZE="2">SERVICE STATUS: Information text</FONT></I><BR>
<BR>
<BR>
I'm using Nagios 3.2.0  and I still can't print multiple lines to be send with the notification email.<BR>
<BR>
What am I missing ??<BR>
<BR>
My plugin :<BR>
<BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">$PEER=$argv[1];</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">$LINE=exec('/usr/sbin/asterisk -rx "sip show peers" | grep -w "'.$PEER.'"');</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">if (!empty($LINE)) {</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">    if (strpos("$LINE"," OK ")) {</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">    $OUTPUT="OK: ".$LINE."\n";</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">    echo $OUTPUT;</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">    exit (0);</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">    }</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">    elseif (strpos("$LINE","UNREACHABLE")) {</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">    $OUTPUT="CRITICAL: ".$LINE."\n";</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">    $OUTPUT.="line 2";</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">    echo $OUTPUT;</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">    exit (2);</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">    }</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">}</FONT></FONT><BR>
<BR>
On commandline :<BR>
<BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">bash-3.2# /usr/local/nagios/libexec/check_asterisk_sip_peer.php my_peer</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">CRITICAL: my_peer                (Unspecified)    D   N      0        UNREACHABLE</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">line 2</FONT></FONT><BR>
<BR>
My notification :<BR>
<BR>
<FONT SIZE="2"><FONT COLOR="#0000ff"># 'notify-service-by-email' command definition</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">define command{</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">        command_name    notify-service-by-email</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nType : $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\n</FONT></FONT><FONT SIZE="2"><FONT COLOR="#0000ff"><B>Additional Info:\n\n$SERVICEOUTPUT$"</B></FONT></FONT><FONT SIZE="2"><FONT COLOR="#0000ff"> | /usr/bin/mutt -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">        }</FONT></FONT><BR>
<BR>
The email I receive :<BR>
<BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">***** Nagios *****</FONT></FONT><BR>
<BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">Type: PROBLEM</FONT></FONT><BR>
<BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">Service: SIP_peer_mypeer</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">Host: Asterisk</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">Address: ip_address</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">State: CRITICAL</FONT></FONT>
<BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">Additional Info:</FONT></FONT><BR>
<BR>
<FONT SIZE="2"><FONT COLOR="#0000ff">CRITICAL: my_peer                (Unspecified)    D   N      0        UNREACHABLE</FONT></FONT>
<BR>
<BR>
You see that <B><FONT SIZE="2"><FONT COLOR="#0000ff">$SERVICEOUTPUT$</FONT></FONT></B> consists of only 1 line... How do I get my extra line of text (line 2) ??
<BR>
<BR>
Jonas
<BR>
<BR>
</BODY>
</HTML>