Switch psrinfo with kstat which is less error prone when parsing.

This commit is contained in:
Pedro Algarvio 2013-01-27 19:40:42 +00:00
parent abdb063f54
commit 37688981c4

View file

@ -226,11 +226,11 @@ exec 2>$LOGPIPE
__gather_hardware_info() {
if [ -f /proc/cpuinfo ]; then
CPU_VENDOR_ID=$(cat /proc/cpuinfo | grep -E 'vendor_id|Processor' | head -n 1 | awk '{print $3}' | cut -d '-' -f1 )
elif [ -f /usr/sbin/psrinfo ]; then
elif [ -f /usr/bin/kstat ]; then
# SmartOS.
# Solaris!?
# This has only been tested for a GenuineIntel CPU
CPU_VENDOR_ID=$( /usr/sbin/psrinfo -pv 0 | tail -n 2 | head -n 1 | cut -d ' ' -f6 | sed 's/[^A-Za-z0-9]//g' )
CPU_VENDOR_ID=$(/usr/bin/kstat -p cpu_info:0:cpu_info0:vendor_id | awk '{print $2}')
else
CPU_VENDOR_ID=$( sysctl -n hw.model )
fi