#!/usr/bin/bash

PROG="$(basename ${0})"

tool_output_dir="${1}"
if [[ ! -d "${tool_output_dir}" ]]; then
    printf -- "%s: invalid tool output directory, %s\n" "${PROG}" "${tool_output_dir}" >&2
    exit 1
fi

if [[ -d /sys/devices/system/cpu ]]; then
    # Assume we have a working CPU directory tree to
    # collect CPU online statuses.
    oc_fn=${tool_output_dir}/online-cpus.txt
    for cpuonline_fn in /sys/devices/system/cpu/cpu*/online; do
        cpuid=$(basename $(dirname ${cpuonline_fn}))
	printf "${cpuid#cpu}: $(cat ${cpuonline_fn})\n"
    done > ${oc_fn}
fi
exit 0
