cpu_information.sh
662 Bytes
#!/bin/dash
. ./utils.sh
include_once classes.sh
gather_cpu_info() {
[ -z "${NCPUS}" ] || return
has_class "GNU" && {
export NCPUS=$(${NPROC})
}
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 "\";" }')
}
CLASSES="${CLASSES}${NCPUS}cpus ${CPU_VIRT} ${BYTE_ORDER} ${OP_MODES} "
CLASSES="$(${ECHO} "${CLASSES}" | "${SED}" 's/ \+/ /g')"
}
# vim: set ts=4 sw=4: