Operating System - HP-UX
1839233 Members
2599 Online
110137 Solutions
New Discussion

Finding information about the CPU programatically

 
SOLVED
Go to solution
Sonison James
Frequent Advisor

Finding information about the CPU programatically

Hello,

I would like to know the following for each CPU, programmatically

1. Type
2. Model
3. Speed

I am able to get the number of active CPUs and the speed of each CPU by using pstat_getdynamic() and pstat_getprocessor(). For CPU Type I am using sysconf(), however this does not give the model for each CPU. Also for getting the CPU Model I am using the model command, which again has the same problem.

Any information about APIs that lets me get all the information on a per CPU basis would be highly appreciated.

Thanks and Regards
Sonison James
5 REPLIES 5
Sonison James
Frequent Advisor

Re: Finding information about the CPU programatically

Hello,

I am sorry for a mistake in the posting, please read the posting as

I would like to know the following for each CPU, programmatically

1. Type
2. Model
3. Speed

I am able to get the number of active CPUs and the speed of each CPU by using pstat_getdynamic() and pstat_getprocessor(). For CPU Type I am using sysconf(), however this does not give the CPU Type for each CPU. Also for getting the CPU Model I am using the model command, which again has the same problem.

Any information about APIs that lets me get all the information on a per CPU basis would be highly appreciated

Thanks and regards
Sonison James
James Murtagh
Honored Contributor
Solution

Re: Finding information about the CPU programatically

Hi Sonison,

Although this doesn't answer your question can I just add the information must be the same for each processor, i.e. they must all be the same model, type and speed.

I think that the structures that hold the information are global (not per SPU) hence I don't believe writing code to find this will be of much use?

Regards,

James.
Donny Jekels
Respected Contributor

Re: Finding information about the CPU programatically

hold on ->
"Vision, is the art of seeing the invisible"
gil paz_2
Advisor

Re: Finding information about the CPU programatically

Hell,
You can use the att' scripts
OR:
################# CSTM #################
/usr/sbin/cstm << EOF >> /tmp/cstmmap1.tmp
map
exit
EOF
set CPU=`grep CPU /tmp/cstmmap1.tmp |awk '{print $1}'|sort -u`
foreach i ($CPU)
/usr/sbin/cstm << EOF >> /tmp/cpu1
map
sel device $i
il
SaveAs
cpu
EOF
set CACHE=`grep "Instruction Cache" /tmp/cpu |awk '{print $4}'|sort -u`
set PDC=`grep "PDC Firmware Revisi" /tmp/cpu |awk '{print $4}'|sort -u`
set CPUPATH=`grep CPU /tmp/cstmmap1.tmp |awk '{print $2}'|sort -u`
end
endif
endif
#############################
echo "Processors:`/usr/sbin/ioscan -C processor |grep processor |wc -l`" >>/tmp/cpu-info
set CPUSPEED=`echo "itick_per_usec/D" |adb -k /stand/vmunix /dev/kmem |tail -1|awk '{print $2}'`
echo "Processors Speed: "$CPUSPEED "Mhz">>/tmp/cpu-info
foreach I ($CPUPATH)
echo "The CACHE size on Processors in path" $I "is "$CACHE "[Kbyte]" >>/tmp/cpu-info
end
echo "The PDC Firmware Revisi is" "$PDC" >> /tmp/cpu-info
Sonison James
Frequent Advisor

Re: Finding information about the CPU programatically

Hello,

Thanks for the information and the scripts. Even the scripts seems to be assuming that all the CPUs have the same model and speed, so I hope that I can safely make that assumption too in my code.

Thanks and regards
Sonison James