Solved

processors count

Posted on 2013-05-29
7
260 Views
Last Modified: 2013-06-11
hi guys

I am trying to find out how many processors i have in my Production server. i am using this code
Runtime.getRuntime().availableProcessors();

but does that give a correct count of the number of processors?

What if i have 2 boxes in a cluster and each box has one processor, will the
above code return me correct number of processors.

thanks
0
Comment
Question by:royjayd
  • 4
  • 2
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
What hardware/software would you have that would allow clustering of processors?
0
 
LVL 16

Expert Comment

by:Valeri
Comment Utility
No. I think you mean "nodes" when you write "boxes" in the cluster?! Am I right?
If this is the case then "Runtime.getRuntime().availableProcessors();" will be executed on each one of the boxes, because each box runs it's own JVM.
Btw Runtime.getRuntime().availableProcessors(); returns number of the cores of the processor, in your case if you have 1 processor with 4 cores, the returnd value will be "4".
0
 

Author Comment

by:royjayd
Comment Utility
well the problem is i asked my system admin how many CPUs we are using in Production environment and he says 4
but my java code  
>>Runtime.getRuntime().availableProcessors();

returns 1

so i am not sure why there is a mismatch.
However one thing i am pretty sure is it is a production box and it cannot have just one cpu.
so as per my system admin 4 cpus sounds about right.

Thx.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
What OS are you using?
0
 

Author Comment

by:royjayd
Comment Utility
Linux OS on production box , no application servers.
Its just a single java program running in one single jvm.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 325 total points
Comment Utility
cat /proc/cpuinfo

Open in new window

Would be worth trying. Java uses

sysconf(_SC_NPROCESSORS_CONF)

Open in new window


http://www.gnu.org/software/libc/manual/html_node/Processor-Resources.html

You might also need to look at ulimit and quota
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
:)
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now