My simple plugin


#1

I writed my plugin for the free memory monitoring in Nagios, but have one trouble - it returned value = 0, if I executed over nrpe. If I executed this plugin itself without nrpe, it returned normal value.
#!/usr/bin/perl
use Nagios::Plugin;
my $np = Nagios::Plugin -> new(
usage => “Usage: %s\n”,
shortname => ‘Memory’,
blurb => ‘Cheks the free memory’,
timeout => 10,
);
$np->getopts;
my $mem=top -n 1 | grep Mem:;
my @values = split(/\s+/, $mem);
$mem = sprintf “%d”, @values[6];
$np->add_perfdata(label=>“Free”, value=>$mem);
$np->nagios_exit(‘OK’,’’);

And one thing else: if I create the new variable my $var=356 and paste it in value …(label=>“Free”, value=>$mem), then nrpe return normal value. Any ideas???