package Requester::procMeminfo;

use strict;

@Requester::procMeminfo::ISA = qw(Requester::Requester);

my $requester = new Requester::procMeminfo;

sub new
{
    my ($this, $args ) = @_;
    my  $class = ref($this) || $this;
    my  $self = {};

    bless($self, $class);
    $self->register( "procMeminfo" );
    return $self;
}




# the default "request()" method is good enough for our purposes


sub getinfo {
    my( $self ) = @_;

    my $info = {};
    open( INFO, "</proc/meminfo" ) || return {};
    while( <INFO> ) {
        chomp;
	if( /^([a-z_]+):[\s\t]*(\d+)[\s\t]*(.B)/i ) {
	    my( $var, $val, $unit ) = ($1,$2,$3);
	    ($val*=1024) if( $unit eq "MB" );
	    ($val*=1024*1024) if( $unit eq "GB" );
	    $info->{$var} = $val;
	}
    }
    close INFO;

    return { 0 => $info };
}


sub available {
    return( -f "/proc/meminfo" );
}


1;

