#! /bin/bash

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

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

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

probe_resource_mem ()
{
    ${GLOBUS_SH_TOP-top} -d1 -b | \
    {
	read loadavgs
	read processes
	read cpuloads
	read Memory memtot Max memavail Avail memfree Free swaptot Swap swapfree rest

	${GLOBUS_SH_CAT-cat} > /dev/null

	memtot=`drop_M $memtot`


        _mem_size_mbytes=`drop_M $memtot`
        _mem_free_mbytes=`drop_M $memfree`

        _vm_size_mbytes=`drop_M $swaptot`
        _vm_free_mbytes=`drop_M $swapfree`


	# run this in initialized subshell environment
	emit_resource_mem_descriptions
    }
}

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