cpu_information.sh 680 Bytes
gather_cpu_info() {
	[ -z "${NCPUS}" ] || return

	has_class "GNU" && {
		export NCPUS=$(${NPROC})
		set_class ${NCPUS}cpus
	}

	has_class "Linux" && {
		eval $(${LSCPU} | ${AWK} -F: '
		{ sub(/^ */,"",$2) }
		/Byte Order/ {
			sub(/ /,"_",$2);
			print "export BYTE_ORDER=\"" $2 "\";"
		}
		/CPU op-mode/ {
			sub(/,/,"",$2);
			print "export OP_MODES=\"" $2 "\";"
		}
		/CPU(s):/ { print "export NCPUS=" $2 ";" }
		/Virtualization/ { print "export CPU_VIRT=\"" $2 "\";" }')

		set_class ${NCPUS}cpus ${CPU_VIRT} ${BYTE_ORDER} ${OP_MODES}
	}

	has_class "FreeBSD" && {
		export NCPUS=$(${SYSCTL} kern.smp.cpus | cut -d\  -f2)
		set_class ${NCPUS}cpus
	}
}

# vim: set ts=4 sw=4: