1825789 Members
2088 Online
109687 Solutions
New Discussion

how to get cpu info

 
Basel Naamna
Occasional Contributor

how to get cpu info

How can I get cpu info from the command line,
I need to know number of cpu's and the speed of each.
i dont have root permission , (and dont have permission to /dev/kmem)
also i can't use a scripts (i need to run rexec query)

12 REPLIES 12
Pedro Cirne
Esteemed Contributor

Re: how to get cpu info

Hi,

You may check the number of CPUs by using the top command.

You can also get some information using the command model

Pedro
TwoProc
Honored Contributor

Re: how to get cpu info

I got this script from here on itrc somewhere.

#!/bin/ksh
#
# @(#) sysinfo - gives system information on HPUX machine
#
echo `hostname` "is a " `model |sed 's/9000\/800\///' |sed 's/9000\/899\///'` "with" `/usr/sbin/ioscan -k |grep -n processor |wc -l` `/home/adm/bin/cpuspeed` "Mhz processors and" `/home/adm/bin/meminfo` "of memory"

We are the people our parents warned us about --Jimmy Buffett
Mel Burslan
Honored Contributor

Re: how to get cpu info

perl -e 'local($PSTAT, $PSTAT_PROCESSOR)=(239,10);
local($struct_pst_processor)=("L30");
local($cpu_info
, $cpu_ticks);
$cpu_info = "\0" x 120;
syscall($PSTAT, $PSTAT_PROCESSOR, $cpu_info, length($cpu_info), 1, 0);
($cpu_ticks)=(unpack($struct_pst_processor
, $cpu_info))[26];
print "speed=".int($cpu_ticks/10000)."\n";'

this will give you the speed of cpu without root privileges.

if you need more info this may help you:

echo "map\nselect device 33\ninfo\nwait\nil\n" | /usr/sbin/cstm

here on this command you need to know your CPU line number on the cstm map, which was 33 for one of my 4 cpus. you can get it from the output of this command and process it yourself:

echo "map" | /usr/sbin/cstm

hope this helps
________________________________
UNIX because I majored in cryptology...
Geoff Wild
Honored Contributor

Re: how to get cpu info

Without root - very very hard....

If you are not root - then why do you need to know?

If you can pursuade the admin - ask them to install sudo, then this script:

# cat /usr/local/bin/hpmem
#!/bin/ksh
#
# Taken from the HP/UniGraphics FAQ
# You must be ROOT to execute this since it uses adb to
# examine the running kernel
#
GetKernelSymbol()
{
echo "$1/D" | \
adb $hpux /dev/kmem | \
tr "\012" " " | \
read junk junk2 kval
}
hpux=/hp-ux
rev=$(uname -r | cut -d. -f2)
if ((rev > 9)); then hpux=/stand/vmunix ;fi
/bin/uname -a
# if 11iv2 or higher - get cpu this way
ver=$(uname -r | cut -d. -f3)
if ((ver > 22)); then
kval=`echo "processor_count/D" | adb /stand/vmunix /dev/kmem |tail -1|awk -F: '{print $2}' `
else
GetKernelSymbol "processor_count"
fi
print CPU Count: $kval
GetKernelSymbol "itick_per_tick"
let speed=kval/10000
print CPU Speed: $speed MHz
if ((rev > 10)); then
print CPU HW Support: `getconf HW_CPU_SUPP_BITS`-bit
print Kernel Support: `getconf KERNEL_BITS`-bit
GetKernelSymbol "memory_installed_in_machine"
else
GetKernelSymbol "physmem"
fi
# if 11iv2 or higher - get memory this way
ver=$(uname -r | cut -d. -f3)
if ((ver > 22)); then
kernel=$(/usr/sbin/kcpath -x)
hexval=$(echo "phys_mem_pages/A" | adb $kernel /dev/kmem|tail +2|awk '{print $2}')
REAL_MEM=$(echo ${hexval}=D|adb)
mb=$(expr ${REAL_MEM} / 256)
else
let mb=kval*4/1024 # convert pages to MB
fi
print RAM Size: $mb MB
GetKernelSymbol "bufpages"
let mb=kval*4/1024 # convert pages to MB
print bufpages: $mb MB
GetKernelSymbol "maxuprc"
print maxuprc: $kval
GetKernelSymbol "maxvgs"
print maxvgs: $kval
GetKernelSymbol "maxfiles"
print maxfiles: $kval
GetKernelSymbol "max_thread_proc"
print max_thread_proc: $kval
GetKernelSymbol "nfile"
print nfile: $kval
GetKernelSymbol "nproc"
print nproc: $kval
GetKernelSymbol "ninode"
print ninode: $kval
GetKernelSymbol "vfd_cw"
print shmmax: $kval
GetKernelSymbol "shmmni"
print shmmni: $kval
GetKernelSymbol "dbc_max_pct"
print dbc_max_pct: $kval



Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Juan M Leon
Trusted Contributor

Re: how to get cpu info

If you are familiar with CSTM, you can run all the syntax from the command line with out have to enter into the utility.
you can get CPU, memory, Machine serial number, etc.
Rick Garland
Honored Contributor

Re: how to get cpu info

The info you are requesting can be readily obtained from a Sys Admin who has the root access. Without root you will be performing lots of commands that will seem to be taking you in a circle.
If you have (or can get) sudo priviledges then you will have an easier time.


To determine CPU speed;
echo itickl_per_usec/D | adb /stand/vmunix /dev/kmem


To determine number of processors in use;
echo "runningprocs/D" | adb /stand/vmunix /dev/mem


To get CPU HW support;
getconf HW_CPU_SUPP_BITS


To get kernel support;
getconf KERNEL_BITS
Brad Baron
Frequent Advisor

Re: how to get cpu info

#echo "selall;info;wait;infolog;view;done" | cstm
H.Merijn Brand (procura
Honored Contributor

Re: how to get cpu info

It's all in my FAQ [1], and you don't need root[2].

[1] http://mirrors.develooper.com/hpux/faq.html
[2] http://mirrors.develooper.com/hpux/ux

As most possibilities are already posted here, I'll just take the shortest non-root version from the FAQ to put here:

a5:/wrk 108 > perl -MUnix::Processors -le'print join"\t",$_->id,$_->state,$_->type,$_->clock for @{Unix::Processors->new()->processors}'
0 online HP PA-RISC 2.0 750
1 online HP PA-RISC 2.0 750
a5:/wrk 109 >

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Muthukumar_5
Honored Contributor

Re: how to get cpu info

You can use sam for this also (if specific use is added to access sam).

sam -> performance monitor -> system properties -> processor

If you use sysinfo or adb then it will be able to get information from adb only.

hth.
Easy to suggest when don't know about the problem!
Pete Randall
Outstanding Contributor

Re: how to get cpu info

"How to get CPU speeds and RAM without cstm or root":

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=851889


Pete

Pete
Mahesh Kumar Malik
Honored Contributor

Re: how to get cpu info

Hi Basel

1. top command will give you number of CPUs in server

2. with cstm>sel all > info > il you can get complete information on CPUs

3. You may also use third part utility "cfg2html" available from freeware

Regards
Mahesh
Ranveer
HPE Pro

Re: how to get cpu info

Hi Basel
Please find the attached script(created by some other irtcian) & change permission and run.
# ./ranveer

This will give u information.

enjoy

ranveer



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo