public class JavaSystemInfo extends Object implements SystemInfo
SystemInfo used in the case when there is no native
library available that can be used to obtain low-level system information. This implementation cannot provide all the
types of information that a true NativeSystemInfo implementation can - in the cases where this implementation
cannot provide the requested information, the UnsupportedOperationException exception will be thrown.| Modifier and Type | Method and Description |
|---|---|
ProcessExecutionResults |
executeProcess(ProcessExecution processExecution)
Spawns a new process using the Java Runtime API.
|
List<NetworkAdapterInfo> |
getAllNetworkAdapters()
Returns partially filled
NetworkAdapterInfo objects - only the data available via the Java API
(particularly the NetworkInterface class) will be available in the returned objects. |
List<ProcessInfo> |
getAllProcesses()
Throws
UnsupportedOperationException since the Java API cannot obtain information about currently running
processes. |
List<ServiceInfo> |
getAllServices()
Throws
UnsupportedOperationException since the Java API cannot obtain information about installed
services. |
CpuInformation |
getCpu(int cpuIndex)
Throws
UnsupportedOperationException since the Java API cannot obtain information about CPUs. |
org.hyperic.sigar.DirUsage |
getDirectoryUsage(String path) |
FileSystemInfo |
getFileSystem(String directory)
Throws
UnsupportedOperationException since the Java API cannot obtain information about file systems. |
List<FileSystemInfo> |
getFileSystems()
Throws
UnsupportedOperationException since the Java API cannot obtain information about file systems. |
String |
getHostname()
This returns the canonical hostname as it is known via the Java API
InetAddress.getLocalHost(). |
org.hyperic.sigar.Mem |
getMemoryInfo()
Throws
UnsupportedOperationException since the Java API cannot obtain information about low level memory
details. |
NetworkAdapterStats |
getNetworkAdapterStats(String interfaceName)
Returns network adapter measurements for the named network adapter interface.
|
List<org.hyperic.sigar.NetConnection> |
getNetworkConnections(String addressName,
int port)
Returns information on all known network connections from the given address/port.
|
NetworkStats |
getNetworkStats(String addressName,
int port)
Returns network stats for connections that match the given address and port.
|
int |
getNumberOfCpus()
Throws
UnsupportedOperationException since the Java API cannot obtain information about the number of
CPUs. |
String |
getOperatingSystemName()
Returns the value of the Java system property
os.name. |
OperatingSystemType |
getOperatingSystemType()
Returns
OperatingSystemType.JAVA unless the type can be determined via the Java "os.name" property. |
String |
getOperatingSystemVersion()
Returns the value of the Java system property
os.version. |
List<ProcessInfo> |
getProcesses(String processInfoQuery)
Throws
UnsupportedOperationException since the Java API cannot obtain information about processes. |
org.hyperic.sigar.Swap |
getSwapInfo()
Throws
UnsupportedOperationException since the Java API cannot obtain information about low level swap
details. |
String |
getSystemArchitecture()
Returns the architecture of the underlying hardware
|
ProcessInfo |
getThisProcess()
Throws
UnsupportedOperationException since the Java API cannot obtain information about currently running
processes. |
boolean |
isNative()
Returns
false - this implementation relies solely on the Java API to get all the system information
it can. |
String |
readLineFromConsole(boolean noEcho)
Reads from
System.in. |
void |
writeLineToConsole(String line)
Writes to
System.out. |
public boolean isNative()
false - this implementation relies solely on the Java API to get all the system information
it can.isNative in interface SystemInfotrue if there is a low-level native API available for the JVM's platformSystemInfo.isNative()public OperatingSystemType getOperatingSystemType()
OperatingSystemType.JAVA unless the type can be determined via the Java "os.name" property. The
caller can call getOperatingSystemName() to try to determine the real operating system type if this
method cannot.getOperatingSystemType in interface SystemInfoSystemInfo.getOperatingSystemType()public String getOperatingSystemName()
os.name.getOperatingSystemName in interface SystemInfoSystemInfo.getOperatingSystemName()public String getOperatingSystemVersion()
os.version.getOperatingSystemVersion in interface SystemInfoSystemInfo.getOperatingSystemVersion()public String getHostname()
InetAddress.getLocalHost().getHostname in interface SystemInfoSystemInfo.getHostname()public List<NetworkAdapterInfo> getAllNetworkAdapters() throws SystemInfoException
NetworkAdapterInfo objects - only the data available via the Java API
(particularly the NetworkInterface class) will be available in the returned objects.getAllNetworkAdapters in interface SystemInfoSystemInfoExceptionSystemInfo.getAllServices()public List<ServiceInfo> getAllServices() throws UnsupportedOperationException
UnsupportedOperationException since the Java API cannot obtain information about installed
services.getAllServices in interface SystemInfoUnsupportedOperationExceptionSystemInfo.getAllServices()public List<ProcessInfo> getAllProcesses() throws UnsupportedOperationException
UnsupportedOperationException since the Java API cannot obtain information about currently running
processes.getAllProcesses in interface SystemInfoUnsupportedOperationExceptionSystemInfo.getAllProcesses()public List<ProcessInfo> getProcesses(String processInfoQuery)
UnsupportedOperationException since the Java API cannot obtain information about processes.getProcesses in interface SystemInfoprocessInfoQuery - the PIQL query stringSystemInfo.getProcesses(String)public ProcessInfo getThisProcess()
UnsupportedOperationException since the Java API cannot obtain information about currently running
processes.getThisProcess in interface SystemInfoSystemInfo.getThisProcess()public ProcessExecutionResults executeProcess(ProcessExecution processExecution)
executeProcess in interface SystemInfoprocessExecution - the settings on how to execute the processSystemInfo.executeProcess(ProcessExecution)public int getNumberOfCpus()
UnsupportedOperationException since the Java API cannot obtain information about the number of
CPUs.getNumberOfCpus in interface SystemInfoSystemInfo.getNumberOfCpus()public org.hyperic.sigar.Mem getMemoryInfo()
UnsupportedOperationException since the Java API cannot obtain information about low level memory
details.getMemoryInfo in interface SystemInfoSystemInfo.getMemoryInfo()public org.hyperic.sigar.Swap getSwapInfo()
UnsupportedOperationException since the Java API cannot obtain information about low level swap
details.getSwapInfo in interface SystemInfoSystemInfo.getSwapInfo()public String readLineFromConsole(boolean noEcho) throws IOException
System.in.readLineFromConsole in interface SystemInfonoEcho - if true, the implementation should try to not echo the input to the consoleIOException - if failed to read console inputSystemInfo.readLineFromConsole(boolean)public void writeLineToConsole(String line) throws IOException
System.out.writeLineToConsole in interface SystemInfoIOExceptionSystemInfo.writeLineToConsole(String)public CpuInformation getCpu(int cpuIndex)
UnsupportedOperationException since the Java API cannot obtain information about CPUs.getCpu in interface SystemInfocpuIndex - identifies the CPU whose information is to be returned; on a single-CPU system, the index must
be 0.SystemInfo.getCpu(int)public List<FileSystemInfo> getFileSystems()
UnsupportedOperationException since the Java API cannot obtain information about file systems.getFileSystems in interface SystemInfoSystemInfo.getFileSystems()public FileSystemInfo getFileSystem(String directory)
UnsupportedOperationException since the Java API cannot obtain information about file systems.getFileSystem in interface SystemInfodirectory - the file or directory whose mounted file system should be returnedSystemInfo.getFileSystem(String)public org.hyperic.sigar.DirUsage getDirectoryUsage(String path)
getDirectoryUsage in interface SystemInfopublic NetworkAdapterStats getNetworkAdapterStats(String interfaceName)
SystemInfogetNetworkAdapterStats in interface SystemInfopublic NetworkStats getNetworkStats(String addressName, int port)
SystemInfoSystemInfo.getNetworkConnections(String, int) for the semantics of the parameters.getNetworkStats in interface SystemInfoSystemInfo.getNetworkConnections(String, int)public List<org.hyperic.sigar.NetConnection> getNetworkConnections(String addressName, int port)
SystemInfonull, connections from all local addresses will be returned.
If port is 0, then connections on all local ports will be returned.getNetworkConnections in interface SystemInfoaddressName - if not null, the returned connections are from this local address onlyport - if not 0, the returned connections are from this local port onlypublic String getSystemArchitecture()
SystemInfogetSystemArchitecture in interface SystemInfoCopyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.