[Nagiosplug-help] check_mem problem

Lukasz.Lesniak at gpw.com.pl Lukasz.Lesniak at gpw.com.pl
Fri Jan 24 03:29:03 CET 2003


Hi!

I am using check_mem.pl plugin from nagios-plugins "contrib"

I think there is an error in code:
****************************************************************************
# This the unix command string that brings Perl the data
$command_line = `vmstat | tail -1 | awk '{print \$4,\$5}'`;

chomp $command_line;
@memlist      = split(/ /, $command_line);

# Define the calculating scalars
$used_memory  = $memlist[0];
$free_memory  = $memlist[1];
$total_memory = $used_memory + $free_memory;
****************************************************************************

vmstat | tail -1 | awk '{print \$4, \$5}'
The 4th parameter is "swpd" and 5th is "free". On my computer 4th
partameter = 0 so I have always 100% free memory because $4=0 and
$5=something.
In code there is a sum $total_memory = $used_memory + $free_memory;
****************************************************************************
 $percent    = $free_memory / $total_memory * 100;
  $fmt_pct    = sprintf "%.1f", $percent;
****************************************************************************

Is this ok or not? I have a vmstat (procps) version  2.0.6.

Lukasz Lesniak








More information about the Help mailing list