Operating System - HP-UX
1753538 Members
4848 Online
108795 Solutions
New Discussion юеВ

Script to determine number and size of CPU's

 
SOLVED
Go to solution
Penni Nussbaum
Frequent Advisor

Script to determine number and size of CPU's

I need to write a script (assuming Glance and stm is not installed on the server) to determine the number and size of the CPU's. I could get the size of the CPU from the model type, but how would I detremine the number of CPU's?
8 REPLIES 8
someone_4
Honored Contributor
Solution

Re: Script to determine number and size of CPU's

Hi .. Hope this helps

##Number of processors

sar -Mu 1 1|awk 'END {print NR-5}'


ioscan -kfnC processor


###To obtain the processor speed (MHz):

echo itick_per_usec/D|adb -k stand/vmunix /dev/kmem|awk 'NR==2 {print}'

or

echo itick_per_usec/D | /usr/bin/adb -k /stand/vmunix /dev/kmem



##total of memory

#!/bin/ksh
if [ `uname -r` = "B.11.00" ]
then
echo "phys_mem_pages/D" | adb /stand/vmunix /dev/kmem|grep phys|tail -1|awk '{print $2/256 " MB"}'
else
echo "physmem/D" | adb /stand/vmunix /dev/kmem|grep phys|tail -1|awk '{print "Memory size = " $2 / 256 " Megabytes"}'
fi
Bill McNAMARA_1
Honored Contributor

Re: Script to determine number and size of CPU's

ioscan -fnkC processor | grep proc | wc -l

for number..

model is a good start to guess cpu speed without stm..
alternatively try /opt/ignite/bin/print_manifest

Later,
Bill
It works for me (tm)
Steven Mertens
Trusted Contributor

Re: Script to determine number and size of CPU's

hi ,

maybe you could try the following
echo runningprocs/D | adb -k /stand/vmunix /dev/mem

regards

Steven
V. V. Ravi Kumar_1
Respected Contributor

Re: Script to determine number and size of CPU's

hi,

if u have ignite installed
to get the no. of cpus
issue
/opt/ignite/bin/print_manifest |grep Processors

regds
Never Say No
Dave Chamberlin
Trusted Contributor

Re: Script to determine number and size of CPU's

If you have top - you could run top -d 1 (assumming you dont need to extract the values).
MANOJ SRIVASTAVA
Honored Contributor

Re: Script to determine number and size of CPU's

Many ways


dmesg | grep Proc | wc -l

sam---> performance moniotor-->System properties

print _manifest


Manoj Srivastava
Pete Randall
Outstanding Contributor

Re: Script to determine number and size of CPU's

Here's pretty much everything you ever wanted to know:
echo `hostname` "is a " `model |sed 's/9000\/800\///' |sed 's/9000\/899\///'` "w
ith" `ioscan -k |grep -n processor |wc -l` `/nfs/yukon/apps/hols/bin/ts/cpuspeed
` "Mhz processors and" `/nfs/yukon/apps/hols/bin/ts/memory` "KB of memory"

Pete

Pete
Pete Randall
Outstanding Contributor

Re: Script to determine number and size of CPU's

My apologies, that didn't paste very well. It ought to look something like this:
echo `hostname` "is a " `model |sed 's/9000\/800\///' |sed 's/9000\/899\///'` "with" `ioscan -k |grep -n processor |wc -l` `cpuspeed`
` "Mhz processors and" `memory` "KB of memory"

cpuspeed:
HPUX=/stand/vmunix

MHZ=$(echo itick_per_tick/D | adb -k $HPUX /dev/kmem | tail -1 | awk '{print $2/10000}')
echo $MHZ

memory:
HPUX=/stand/vmunix
MAJORREV=$(uname -r | cut -f2 -d .)
if [ $MAJORREV -ge "11.0" ]
then
MYSYMBOL="phys_mem_pages"
else
MYSYMBOL="physmem"
fi

MYMEM=$(echo "${MYSYMBOL}/D" | adb $HPUX /dev/kmem | grep "${MYSYMBOL}: *." | awk '{print $2*4/1024}')
echo $MYMEM


At least I hope this is going to be more readable.

Pete

Pete