System Information and Secondary Loops – Java Resources

Found these two good blog posts by Aristides Villareal, about secondary loops and CPU Monitoring.

Hidden Java 7 Features – Secondary Loop


Hidden Java 7 Features – CPU Load Monitoring


I just read these and haven’t thought up any good examples to code myself yet.  The CPU Load Monitoring article is about the features of the library.  Java has an built-in OperatingSystemMXBean package but it’s missing a couple of features compared to the other library.  I’ve never used the java.lang version but here is simple script I made to see what the generic built in library could offer.


	public static void main( String[] args ){
		OperatingSystemMXBean osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
		System.out.println("Hostname: " + osBean.getName() );
		System.out.println("OS Version: " + osBean.getVersion() );
		System.out.println("CPU Architure: " + osBean.getArch() );
		System.out.println("Available Processors: " + osBean.getAvailableProcessors() );
		System.out.println("System Load Average: " + osBean.getSystemLoadAverage() ); // Might be -1 if on a windows machine

Sample Output:
Hostname: Windows 7
OS Version: 6.1
CPU Architure: amd64
Available Processors: 8
System Load Average: -1.0


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s