{
my @check;

if( Platforms::iswin32() ) {
    my $inst;
    my( $filesys );

    $args{"_eval"} = "mem";
    do "_evaluator";
    $args{"object"} = "Memory";
    do "_perflib";
    my $perflib = $memory{"perflib_$args{host}_$args{frequency}"};
    $perflib->check( "Memory" );

    $inst = $uxmon::monitor_variables{$args{"alias"}}->{"perflib.Memory.Instances"}->[0];
    my $freepage=$args{"freepage"}?$args{"freepage"}:10;
    my $freecomit=$args{"freecomit"}?$args{"freecomit"}:5;
    @check = ( 
	"%free committed", sub { 
	    my( $vars ) = @_;
	    return(undef) unless( defined $vars->{"perflib.Memory.$inst.%_Committed_Bytes_In_Use"} );
	    100-$vars->{"perflib.Memory.$inst.%_Committed_Bytes_In_Use"};
	}, $freecomit,
	"avail mem MB", sub {
	    my( $vars ) = @_; 
	    return(undef) unless( defined $vars->{"perflib.Memory.$inst.Available_Bytes"} );
	    $vars->{"perflib.Memory.$inst.Available_Bytes"} /1024/1024;
	}, $freepage
    );
}
elsif( -f "/proc/meminfo" ) {
    $args{"_eval"} = "mem";
    do "_evaluator";
    my $meminfo;
    unless( $meminfo = $memory{"lxmeminfo_$args{frequency}"} ) {
	&uxmon::load_module( "lxMeminfo" );
	&uxmon::checker(
		$memory{"lxmeminfo_$args{frequency}"} = $meminfo = Monitor::lxMeminfo->new( )
	);
	$meminfo->sched_frequency($args{"frequency"});
    }
    @check = ( 
	"%swap free", sub { 
	    my( $vars ) = @_;
	    return(undef) unless( defined $vars->{"linux.meminfo.%SwapFree"} );
	    $vars->{"linux.meminfo.%SwapFree"};
	}, 10,
	"avail swap MB", sub {
	    my( $vars ) = @_; 
	    return(undef) unless( defined $vars->{"linux.meminfo.SwapFree"} );
	    $vars->{"linux.meminfo.SwapFree"} /1024/1024;
	}, 10
    );
}


while( @check ) {
    my $text = shift( @check );
    my $val = shift( @check );
    my $limit = shift( @check );
    $args{"_evaluator"}->add_check( ($args{"check"}?$args{"check"}:"cpu"), sub {
	my( $vars ) = @_;

	my $val = &$val($vars);
	return( 2, "(no data available)" ) unless( defined $val );
	$val = int($val+0.5);
	if( $val > $limit ) {
	    return( 3, $text." = $val" );
	}
	if( $val > $limit/2 ) {
	    return( 1, $text."(<) $val" );
	}
	return( 0, $text."(<<) $val" );
      } );
}

}

1;
