Multiline output in nagios


#1

Hi,
we are using nagios 2.8.we tried to measure the memory performance and obtain a status information about the memory performance.the problem is that we get only the first line output in status information in nagios window.the remaining lines are not displayed.what is the procedure to get multiline status information in nagios.


#2

As I remember with 2.x, multiline information is not possible. I dont have any plugins that return more than 1 line, but I read in 3.x multiline returns are possible.
Check out item 15
nagios.sourceforge.net/docs/3_0/whatsnew.html
3.0 is now stable!

HTH
-peter


#3

another way would be to write a little script that will take the values you need and put them a one line.

For example, on a linux server, we have this output:

[root@noc/bin]# free -mt total used free shared buffers cached Mem: 375 351 24 0 134 64 -/+ buffers/cache: 152 222 Swap: 509 26 482 Total: 885 378 506

Thus, I wrote this script:
(note: “seuil” means “threshold” in french … the rest should be clear enough :))

[code]#!/usr/bin/perl

use strict;

my $count = @ARGV;
if ($count != 2) {
print “Usage: commande \n”;
exit 3;
}

my $seuil_warn = $ARGV[0];
my $seuil_crit = $ARGV[1];

if ( $seuil_warn < $seuil_crit ) {
print “Usage! \n”;
exit 3;
}

my @result = free -mt;

my $total;
my $used;
my $free;
foreach my $line (@result) {
if ( $line =~ /^Mem:\s+(\d+)\s+(\d+)\s+(\d+).$/ ) {
$total = $1;
}
if ( $line =~ /^-/+ buffers/cache:\s+(\d+)\s+(\d+).
$/ ) {
$used = $1;
$free = $2;
}
}
my $percent_free = $free*100/$total;
$percent_free = sprintf("%.1f", $percent_free);

print $percent_free."% free memory";
if ( $percent_free > $seuil_warn ) {
print " (seuil: $seuil_warn)\n";
exit 0;
} elsif ( $percent_free < $seuil_crit ) {
print " (seuil: $seuil_crit)\n";
exit 0;
#exit 2;
}
print " (seuil warning: $seuil_warn; seuil critique: $seuil_crit)\n";
exit 0;
[/code]

You may have to adapt this script to your needs, but it may give you some ideas.
The goal of this script is to compute the % of free memory and check it against the thresholds given as 2 parameters: the first for the warning; the second for critical.

Hope this helps :slight_smile: