This version is also detecting CPUs on Solaris.

This commit is contained in:
Louwrentius 2009-10-21 20:43:10 +00:00
parent 239e422354
commit 276e721c7e
1 changed files with 32 additions and 17 deletions

39
ppss.sh
View File

@ -524,11 +524,12 @@ done
display_header () { display_header () {
log info ""
log INFO "=========================================================" log INFO "========================================================="
log INFO " |P|P|S|S| " log INFO " |P|P|S|S| "
log INFO "$SCRIPT_NAME version $SCRIPT_VERSION" log INFO "$SCRIPT_NAME version $SCRIPT_VERSION"
log INFO "=========================================================" log INFO "========================================================="
log INFO "Hostname:\t$HOSTNAME" log INFO "Hostname:\t\t$HOSTNAME"
log INFO "---------------------------------------------------------" log INFO "---------------------------------------------------------"
} }
@ -575,11 +576,6 @@ init_vars () {
set_status "RUNNING" set_status "RUNNING"
if [ -z "$MAX_NO_OF_RUNNING_JOBS" ]
then
get_no_of_cpus $HYPERTHREADING
fi
if [ -e "$CPUINFO" ] if [ -e "$CPUINFO" ]
then then
CPU=`cat /proc/cpuinfo | grep 'model name' | cut -d ":" -f 2 | sed -e s/^\ //g | sort | uniq` CPU=`cat /proc/cpuinfo | grep 'model name' | cut -d ":" -f 2 | sed -e s/^\ //g | sort | uniq`
@ -589,9 +585,15 @@ init_vars () {
MODEL=`system_profiler SPHardwareDataType | grep "Processor Name" | cut -d ":" -f 2` MODEL=`system_profiler SPHardwareDataType | grep "Processor Name" | cut -d ":" -f 2`
SPEED=`system_profiler SPHardwareDataType | grep "Processor Speed" | cut -d ":" -f 2` SPEED=`system_profiler SPHardwareDataType | grep "Processor Speed" | cut -d ":" -f 2`
log INFO "CPU: $MODEL $SPEED" log INFO "CPU: $MODEL $SPEED"
else
log INFO "CPU: Cannot determine. Provide a patch for your arch!"
log INFO "Arch is $ARCH"
fi fi
if [ -z "$MAX_NO_OF_RUNNING_JOBS" ]
then
get_no_of_cpus $HYPERTHREADING
fi
does_file_exist "$JOB_LOG_DIR" does_file_exist "$JOB_LOG_DIR"
if [ ! "$?" == "0" ] if [ ! "$?" == "0" ]
@ -674,14 +676,16 @@ log () {
DATE=`date +%b\ %d\ %H:%M:%S` DATE=`date +%b\ %d\ %H:%M:%S`
PREFIX="$DATE: ${TYPE_EXP:0:$TYPE_LENGTH}" PREFIX="$DATE: ${TYPE_EXP:0:$TYPE_LENGTH}"
PREFIX_SMALL="$DATE: "
LOG_MSG="$PREFIX $MESG" LOG_MSG="$PREFIX $MESG"
ECHO_MSG="$PREFIX_SMALL $MESG"
echo -e "$LOG_MSG" >> "$LOGFILE" echo -e "$LOG_MSG" >> "$LOGFILE"
if [ "$TYPE" == "INFO" ] || [ "$TYPE" == "ERROR" ] || [ "$TYPE" == "WARN" ] if [ "$TYPE" == "INFO" ] || [ "$TYPE" == "ERROR" ] || [ "$TYPE" == "WARN" ]
then then
echo -e "$LOG_MSG" echo -e "$ECHO_MSG"
fi fi
} }
@ -901,12 +905,22 @@ get_no_of_cpus () {
NUMBER=`sysctl hw.ncpu | awk '{ print $2 }'` NUMBER=`sysctl hw.ncpu | awk '{ print $2 }'`
got_cpu_info "$?" got_cpu_info "$?"
elif [ "$ARCH" == "SunOS" ]
then
NUMBER=`psrinfo | grep on-line | wc -l`
got_cpu_info "$?"
else else
if [ -e "$CPUINFO" ]
then
NUMBER=`grep ^processor $CPUINFO | wc -l` NUMBER=`grep ^processor $CPUINFO | wc -l`
got_cpu_info "$?" got_cpu_info "$?"
fi fi
fi
if [ ! -z "$NUMBER" ]
then
log INFO "Found $NUMBER logic processors." log INFO "Found $NUMBER logic processors."
fi
elif [ "$HPT" == "no" ] elif [ "$HPT" == "no" ]
then then
@ -960,7 +974,8 @@ get_no_of_cpus () {
then then
MAX_NO_OF_RUNNING_JOBS=$NUMBER MAX_NO_OF_RUNNING_JOBS=$NUMBER
else else
log INFO "$FUNCNAME ERROR - number of CPUs not obtained." log ERROR "Number of CPUs not obtained."
log ERROR "Please specify manually with -p."
set_status "ERROR" set_status "ERROR"
exit 1 exit 1
fi fi
@ -1451,9 +1466,9 @@ start_all_workers () {
if [ "$MAX_NO_OF_RUNNING_JOBS" == "1" ] if [ "$MAX_NO_OF_RUNNING_JOBS" == "1" ]
then then
log INFO "Starting $MAX_NO_OF_RUNNING_JOBS worker." log INFO "Starting $MAX_NO_OF_RUNNING_JOBS single worker."
else else
log INFO "Starting $MAX_NO_OF_RUNNING_JOBS workers." log INFO "Starting $MAX_NO_OF_RUNNING_JOBS parallel workers."
fi fi
log INFO "---------------------------------------------------------" log INFO "---------------------------------------------------------"