in reply to vmstat threshold script
use strict; use warnings; my $meminfo='/proc/meminfo'; my %Limits=('mem'=>0.99, 'swap'=>0.60); my %Info=(); open(MEM,"<$meminfo") or die "Can't read $meminfo: $!"; while(defined($_=<MEM>)){ if(/^(Mem|Swap):\s*/){ my $which=lc($1); my ($total,$used)=split(/\s/,$'); my $pct=$total?($used/$total):0; my $test=($pct ge $Limits{$which}?"WARN":"OK"); $Info{$which}=[$used, $total, $pct, $test]; } } close(MEM); #Quick and dirty way to print the %Info hash in a readable form use Data::Dumper; print Dumper(\%Info);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: vmstat threshold script
by Anonymous Monk on Jun 23, 2003 at 18:10 UTC |