writing a simple script to get total number of cpus/cores in server
Hi,
I am very new to scripting and I wanted to write a unix shell script which can give me,
1)number of cpu's in a box
2)number of cores per cpu
3)total number of cores in abox (ie multiplying 1&2)
I am also trying to figure out how to check if hyper-threading is enabled in the server and also this check to script.
intially I am looking this to run on linux then wanted to implement it on other flavours of unix.
below is my script..
Code:
#!/bin/sh
if [ ! -r /proc/cpuinfo ]; then
echo "Is this Linux? Cannot find or read /proc/cpuinfo"
exit 1
fi
echo num_cpus = `grep 'physical id' /proc/cpuinfo | sort -u | wc -l`
read num_cpu
echo num_cores_per_cpu=`grep 'core id' /proc/cpuinfo | sort -u | wc -l`
read num_cores_per_cpu
echo total_cores=`expr $num_cpus \\* num_cores_per_cpu` --this part is not working..
if [ $num_cores -eq 0 ]; then
# this box is either an old SMP or single-CPU box, so count the # of processors
echo num_cores=`grep '^processor' /proc/cpuinfo | sort -u | wc -l`
fi
#echo $num_cores_per_cpu
any help is much appreciated.
thanks,
Steve.
Moderator's Comments:
How to use code tags when posting data and code samples.
Last edited by Franklin52; 01-19-2012 at 03:24 PM..
Reason: Please use code tags for data and code samples, thank you
I'm trying to write a simple unix script that will delete files after 30 days of being created. I've never done this before but conceptually it sounds easy. Here is what I'm trying to do:
Get System Date
Get File Date
If (sysdate-filedate>30days)
rm file
All of these files are contained... (1 Reply)
I am running HPUX and using WLM (workload manager). I want to write a script to fork CPUs to basically take CPUs from other servers to show that the communication is working and CPU licensing is working. Basically, I want to build a script that will use up CPU on a server. Any ideas? (2 Replies)
I want to write a bash script to:
1. Send an email from localhost to an external gmail account. (gmail then automatically forwards the message back to a pop account on the same server.
2. Script waits 3 minutes then checks to see if the email arrived, and if not, it sends an email to... (9 Replies)
#!/bin/csh
echo hello world
this is what i got in a text file called ss1.
i type "chmod 755 ss1.txt" to make it executable.
then when i type
ss1
or
ss1.txt
it says
"ss1 command not found"
what am i doing wrong? (19 Replies)
how to find out total number of users logged in a server from uptime . i mean to say i need the total output of unix command . who gives the out put at a particular time . I need at all time from which machine who has connected , (3 Replies)
Hey all
Im looking to reduce the number of cpus available on a certain node in our cluster available for jobs using SGE.
i.e. we have one node that has 24 cpus available for jobs on SGE, i would like to reduce that to 16. Thanks (1 Reply)
We have a production setup where we have RHEL instances on VMware. We have 2 RHEL instances on VMware now each having 4 CPUs/cores each. I want to put up another RHEL instance but my query is that can we allocate only 1 CPU/core for the new instance.
I hope, my query is clear that can we... (3 Replies)
Hi,
I want to get total number of cores on my all non-global zones on Solaris 10. I got two methods and both are giving different results. Below link is a script, which tells me that total cores are 8
Mandalika's scratchpad: Oracle Solaris: Show Me the CPU, vCPU, Core Counts and the... (4 Replies)
Hello,
I have few old V210/V240, running Solaris-8. I am trying to find, number of physical CPUs, number of cores and number of virtual processors. psrinfo is giving me confusing status.
It looks like, there are 2 physical CPUs, but psrinfo -p shows me just 1
bash-2.03$ psrinfo -v
Status of... (4 Replies)
Discussion started by: ron323232
4 Replies
LEARN ABOUT FREEBSD
siba
SIBA(4) BSD Kernel Interfaces Manual SIBA(4)NAME
siba -- Sonic Inc. Silicon Backplane driver
SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file:
device siba
Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5):
siba_load="YES"
DESCRIPTION
The siba driver supports the Sonic Inc. Silicon Backplane, the interblock communications architecture that can be found in most Broadcom
wireless NICs.
A bus connects all of the Silicon Backplane's functional blocks. These functional blocks, known as cores, use the Open Core Protocol (OCP)
interface to communicate with agents attached to the Silicon Backplane.
Each NIC uses a chip from the same chip family. Each member of the family contains a different set of cores, but shares basic architectural
features such as address space definition, interrupt and error architecture, and backplane register definitions.
Each core can have an initiator agent that passes read and write requests onto the system backplane and a target agent that returns responses
to those requests. Not all cores contain both an initiator and a target agent. Initiator agents are present in cores that contain host
interfaces (PCI, PCMCIA), embedded processors (MIPS), or DMA processors associated with communications cores.
All cores other than PCMCIA have a target agent.
SEE ALSO bwn(4)HISTORY
The siba device driver first appeared in FreeBSD 8.0.
AUTHORS
The siba driver was written by Bruce M. Simpson <bms@FreeBSD.org> and Weongyo Jeong <weongyo@FreeBSD.org>.
CAVEATS
Host mode is not supported at this moment.
BSD January 8, 2010 BSD