#! /bin/bash

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

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

report_resource_cpu ()
{
    if [ ! "X${_probe_cache}" = "X" ]
    then
	{
	    while read line
	    do
		eval "$line"
	    done < "${_probe_cache}" 

	    if [ ${_cpu_count} -eq 0 ]
	    then
		# cache is empty
		# so run heavy-weight probe directly
		exec ${libexecdir}/${grid_info_cpu} "$@" > /dev/null
	    else
		# update cache data with fresh uptime info
		probe_resource_cpufree_uptime

		# run this in initialized subshell environment
		emit_resource_cpu_descriptions
	    fi
	} 2> /dev/null
    else
	ldap_shell_log_error "must provide probe-cache filename"
    fi
}

#############
# do the work
report_resource_cpu
