#! /bin/bash

# default libexecdir used to bootstrap scripts
libexecdir=${GLOBUS_LOCATION}/libexec

# load GRIS CPU common code and initialization
. ${libexecdir}/grid-info-mem-common

#########################################################################

probe_resource_mem ()
{
	# this explicit cat gets around a performance problem
	# redirecting the proc file into a shell on 2.2 kernels
	free -m | \
	{
        while read Type total used free shared buffers cached
        do
            case "X$Type" in
                XMem:)
                    _mem_size_mbytes="$total"
                    _mem_free_mbytes=`$EXPR $free + $cached`
		    ;;
		XSwap:)
                    _vm_size_mbytes="$total"
                    _vm_free_mbytes="$free" 
                    break
		    ;;
            esac

        done
	# run this in initialized subshell environment
	emit_resource_mem_descriptions
	}
}

#############
# do the work
probe_resource_mem
