Get Os-Level System Information

Get OS-level system information

You can get some limited memory information from the Runtime class. It really isn't exactly what you are looking for, but I thought I would provide it for the sake of completeness. Here is a small example. Edit: You can also get disk usage information from the java.io.File class. The disk space usage stuff requires Java 1.6 or higher.

public class Main {
public static void main(String[] args) {
/* Total number of processors or cores available to the JVM */
System.out.println("Available processors (cores): " +
Runtime.getRuntime().availableProcessors());

/* Total amount of free memory available to the JVM */
System.out.println("Free memory (bytes): " +
Runtime.getRuntime().freeMemory());

/* This will return Long.MAX_VALUE if there is no preset limit */
long maxMemory = Runtime.getRuntime().maxMemory();
/* Maximum amount of memory the JVM will attempt to use */
System.out.println("Maximum memory (bytes): " +
(maxMemory == Long.MAX_VALUE ? "no limit" : maxMemory));

/* Total memory currently available to the JVM */
System.out.println("Total memory available to JVM (bytes): " +
Runtime.getRuntime().totalMemory());

/* Get a list of all filesystem roots on this system */
File[] roots = File.listRoots();

/* For each filesystem root, print some info */
for (File root : roots) {
System.out.println("File system root: " + root.getAbsolutePath());
System.out.println("Total space (bytes): " + root.getTotalSpace());
System.out.println("Free space (bytes): " + root.getFreeSpace());
System.out.println("Usable space (bytes): " + root.getUsableSpace());
}
}
}

How to get OS level information using Java?

If you know which OS native library you need to get the information you desire then call it using JNI.

How can I get system/hardware info via Java?

  1. Using Java to get os level system Information will get you started in right direction.
  2. Finding Operating System Information

Using Python (Bash?) to get OS-level system information (CPU Speed)

Take a look at the SIGAR library which has an extensive API for collecting system data cross-platform. It also has libraries available in many languages (Python, Java, Erlang, Ruby, etc).

How to get the system information in Electron?

Check out this page https://nodejs.org/api/os.html. It is nodejs documentation, but since electron and node are very much the same thing it will work.

var os = require('os');

is what you are looking for though.

Get pc (system) information on windows machine

WMI is what you're looking for.

http://www.codeproject.com/KB/cs/EverythingInWmi02.aspx

Let me add the link to Part 3 too, which concentrates on hardware via WMI

http://www.codeproject.com/KB/cs/EverythingInWmi03.aspx

MSDN is also a great resource for WMI scopes...

http://msdn.microsoft.com/en-us/library/aa394554(v=vs.85).aspx

How to get the system info with Python?

some of these could be obtained from the platform module:

>>> import platform
>>> platform.machine()
'x86'
>>> platform.version()
'5.1.2600'
>>> platform.platform()
'Windows-XP-5.1.2600-SP2'
>>> platform.uname()
('Windows', 'name', 'XP', '5.1.2600', 'x86', 'x86 Family 6 Model 15 Stepping 6, GenuineIntel')
>>> platform.system()
'Windows'
>>> platform.processor()
'x86 Family 6 Model 15 Stepping 6, GenuineIntel'


Related Topics



Leave a reply



Submit