[Nagiosplug-help] check_mem problem

Subhendu Ghosh sghosh at sghosh.org
Fri Jan 24 16:18:03 CET 2003


On Fri, 24 Jan 2003 Lukasz.Lesniak at gpw.com.pl wrote:

> 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
> 

I get data for $4 with vmstat from procps v 2.0.7

-- 
-sg





More information about the Help mailing list