[Nagiosplug-devel] patch: contrib/check_mem.pl using incorrect command

Nick Burch nick at torchbox.com
Wed Aug 18 03:54:12 CEST 2004


On Wed, 18 Aug 2004, Stanley Hopcroft wrote:
> - *BSD systems (FreeBSD 4.x anyway) do _not_ have a 'free' command
> 
> - they do however have a vmstat command which displays
> 
> stan> vmstat 
>  procs      memory      page                    disks     faults      
> cpu
>  r b w     avm    fre  flt  re  pi  po  fr  sr ad0 ac0   in   sy  cs us 
> sy id

Ah. That'll be exactly the format that the old plugin expected

Anyone object to me putting some conditional logic in to check the system 
type, and try to guess the appropriate command for that platform?

> Would it be better to fish the free mem from the vmstat output (for 
> those systems whose vmstat do show free memory) ?

Almost certainly. Anyone got any other platforms to hand who could let me 
know the format (if any) of their "free" and "vmstat" commands?
 
> On another matter, you may want to save a few fork and execs by
> replacing the piped calls to awk and head and friends with direct Perl
> manipulation of the command output

The old version didn't bother doing it in perl. I've tried a perl version 
- it doesn't cause any noticable speed improvements (both versions take 
0.037+-0.02 seconds to run, averaged over 4 runs), and makes the code 
less readable
 
Nick





More information about the Devel mailing list