Added support for FreeBSD cpu detection. Thanks Helix84! Also cleanup of error detection within cpu core detection code
This commit is contained in:
parent
48ff066a19
commit
9b78f852be
62
ppss.sh
62
ppss.sh
@ -281,6 +281,20 @@ function log {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function check_status {
|
||||||
|
|
||||||
|
ERROR="$1"
|
||||||
|
FUNCTION="$2"
|
||||||
|
MESSAGE="$3"
|
||||||
|
|
||||||
|
if [ ! "$ERROR" == "0" ]
|
||||||
|
then
|
||||||
|
log INFO "$FUNCTION - $MESSAGE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function get_no_of_cpus {
|
function get_no_of_cpus {
|
||||||
|
|
||||||
# Use hyperthreading or not?
|
# Use hyperthreading or not?
|
||||||
@ -292,51 +306,49 @@ function get_no_of_cpus {
|
|||||||
HPT=no
|
HPT=no
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
function got_cpu_info {
|
||||||
|
|
||||||
|
ERROR="$1"
|
||||||
|
check_status "$ERROR" "$FUNCNAME" "cannot determine number of cpu cores. Please specify a number of parallell processes manually with -p."
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if [ "$HPT" == "yes" ]
|
if [ "$HPT" == "yes" ]
|
||||||
then
|
then
|
||||||
if [ `uname` == "Linux" ]
|
if [ `uname` == "Linux" ]
|
||||||
then
|
then
|
||||||
NUMBER=`cat /proc/cpuinfo | grep processor | wc -l`
|
NUMBER=`cat /proc/cpuinfoo | grep processor | wc -l`
|
||||||
if [ ! "$?" == "0" ]
|
got_cpu_info "$?"
|
||||||
then
|
|
||||||
log INFO "$FUNCNAME - cannot determine number of cpu core. Please specify manually with -p."
|
|
||||||
fi
|
|
||||||
elif [ `uname` == "Darwin" ]
|
elif [ `uname` == "Darwin" ]
|
||||||
then
|
then
|
||||||
NUMBER=`sysctl -a hw | grep -w logicalcpu | awk '{ print $2 }'`
|
NUMBER=`sysctl -a hw | grep -w logicalcpu | awk '{ print $2 }'`
|
||||||
if [ ! "$?" == "0" ]
|
got_cpu_info "$?"
|
||||||
then
|
elif [ `uname` == "FreeBSD" ]
|
||||||
log INFO "$FUNCNAME - cannot determine number of cpu core. Please specify manually with -p."
|
then
|
||||||
fi
|
NUMBER=`sysctl hw.ncpu | awk '{ print $2 }'`
|
||||||
|
got_cpu_info "$?"
|
||||||
else
|
else
|
||||||
NUMBER=`cat /proc/cpuinfo | grep processor | wc -l`
|
NUMBER=`cat /proc/cpuinfo | grep processor | wc -l`
|
||||||
if [ ! "$?" == "0" ]
|
got_cpu_info "$?"
|
||||||
then
|
|
||||||
log INFO "$FUNCNAME - cannot determine number of cpu core. Please specify manually with -p."
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
elif [ "$HPT" == "no" ]
|
elif [ "$HPT" == "no" ]
|
||||||
then
|
then
|
||||||
if [ `uname` == "Linux" ]
|
if [ `uname` == "Linux" ]
|
||||||
then
|
then
|
||||||
NUMBER=`cat /proc/cpuinfo | grep "cpu cores" | cut -d ":" -f 2 | uniq | sed -e s/\ //g`
|
NUMBER=`cat /proc/cpuinfo | grep "cpu cores" | cut -d ":" -f 2 | uniq | sed -e s/\ //g`
|
||||||
if [ ! "$?" == "0" ]
|
got_cpu_info "$?"
|
||||||
then
|
|
||||||
log INFO "$FUNCNAME - cannot determine number of cpu core. Please specify manually with -p."
|
|
||||||
fi
|
|
||||||
elif [ `uname` == "Darwin" ]
|
elif [ `uname` == "Darwin" ]
|
||||||
then
|
then
|
||||||
NUMBER=`sysctl -a hw | grep -w physicalcpu | awk '{ print $2 }'`
|
NUMBER=`sysctl -a hw | grep -w physicalcpu | awk '{ print $2 }'`
|
||||||
if [ ! "$?" == "0" ]
|
got_cpu_info "$?"
|
||||||
then
|
elif [ `uname` == "FreeBSD" ]
|
||||||
log INFO "$FUNCNAME - cannot determine number of cpu core. Please specify manually with -p."
|
then
|
||||||
fi
|
NUMBER=`sysctl hw.ncpu | awk '{ print $2 }'`
|
||||||
|
got_cpu_info "$?"
|
||||||
else
|
else
|
||||||
NUMBER=`cat /proc/cpuinfo | grep "cpu cores" | cut -d ":" -f 2 | uniq | sed -e s/\ //g`
|
NUMBER=`cat /proc/cpuinfo | grep "cpu cores" | cut -d ":" -f 2 | uniq | sed -e s/\ //g`
|
||||||
if [ ! "$?" == "0" ]
|
got_cpu_info "$?"
|
||||||
then
|
|
||||||
log INFO "$FUNCNAME - cannot determine number of cpu core. Please specify manually with -p."
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user