Print only one line of text

jonas kellens jonas.kellens at telenet.be
Sat Nov 7 20:30:35 CET 2009


I read the following on
http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOUTPUT :

2.1. Print only one line of text
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.

Output should be in the format:

SERVICE STATUS: Information text


I'm using Nagios 3.2.0  and I still can't print multiple lines to be
send with the notification email.

What am I missing ??

My plugin :

$PEER=$argv[1];
$LINE=exec('/usr/sbin/asterisk -rx "sip show peers" | grep -w
"'.$PEER.'"');
if (!empty($LINE)) {
    if (strpos("$LINE"," OK ")) {
    $OUTPUT="OK: ".$LINE."\n";
    echo $OUTPUT;
    exit (0);
    }
    elseif (strpos("$LINE","UNREACHABLE")) {
    $OUTPUT="CRITICAL: ".$LINE."\n";
    $OUTPUT.="line 2";
    echo $OUTPUT;
    exit (2);
    }
}

On commandline :

bash-3.2# /usr/local/nagios/libexec/check_asterisk_sip_peer.php my_peer
CRITICAL: my_peer                (Unspecified)    D   N      0
UNREACHABLE
line 2

My notification :

# 'notify-service-by-email' command definition
define command{
        command_name    notify-service-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n
\nType : $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS
$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time:
$LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mutt
-s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is
$SERVICESTATE$ **" $CONTACTEMAIL$
        }

The email I receive :

***** Nagios *****

Type: PROBLEM

Service: SIP_peer_mypeer
Host: Asterisk
Address: ip_address
State: CRITICAL

Additional Info:

CRITICAL: my_peer                (Unspecified)    D   N      0
UNREACHABLE


You see that $SERVICEOUTPUT$ consists of only 1 line... How do I get my
extra line of text (line 2) ??


Jonas


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20091107/96ead0cd/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null


More information about the Users mailing list