public class NativeSystemInfo extends Object implements SystemInfo
SystemInfo implementations. You are free to subclass this implementation if
there are additional platform-specific methods that need to be exposed. Most functionality, however, can be exposed
via this native superclass implementation.
This implementation uses SIGAR. To enable debug logging in SIGAR, set the system property
sigar.nativeLogging or call Sigar.enableLogging(boolean).
| Constructor and Description |
|---|
NativeSystemInfo()
Constructor for
NativeSystemInfo with package scope so only the SystemInfoFactory can instantiate
this object. |
| Modifier and Type | Method and Description |
|---|---|
ProcessExecutionResults |
executeProcess(ProcessExecution processExecution)
Executes a process.
|
List<NetworkAdapterInfo> |
getAllNetworkAdapters()
Returns the information on all installed network adapters.
|
List<ProcessInfo> |
getAllProcesses()
Returns the information on all processes found in the process table.
|
List<ServiceInfo> |
getAllServices()
Returns the information on all installed services found in the services manager.
|
CpuInformation |
getCpu(int cpuIndex)
Returns information about a specified CPU installed on the hardware where the JVM is running.
|
org.hyperic.sigar.DirUsage |
getDirectoryUsage(String path) |
FileSystemInfo |
getFileSystem(String path)
Returns information on the mounted file system that hosts the given file or directory.
|
List<FileSystemInfo> |
getFileSystems()
Returns information on all mounted file systems.
|
String |
getHostname()
Returns the hostname that the system is known as.
|
org.hyperic.sigar.Mem |
getMemoryInfo()
Returns information about memory installed on the platform.
|
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()
Returns the number of CPUs on the hardware platform.
|
String |
getOperatingSystemName()
Returns the name of the operating system.
|
OperatingSystemType |
getOperatingSystemType()
Returns the operating system type, if known; otherwise,
OperatingSystemType.JAVA is returned (in which
case, the caller can examine the Java system property "os.name" to try to detect the type). |
String |
getOperatingSystemVersion()
Returns the version string of the operating system, as reported by the operating system.
|
List<ProcessInfo> |
getProcesses(String piq)
Returns ProcessInfo objects for all processes that match the provided PIQL query string
|
org.hyperic.sigar.Swap |
getSwapInfo()
Returns information about the virtual, swap memory installed on the platform.
|
String |
getSystemArchitecture()
Returns the architecture of the underlying hardware
|
ProcessInfo |
getThisProcess()
Returns the process information for the Java VM process this object is running in.
|
boolean |
isNative()
Always returns
true to indicate that the native library is available. |
String |
readLineFromConsole(boolean noEcho)
Reads a line of input from the console and returns that line as a string.
|
void |
writeLineToConsole(String line)
Writes a line of output to the console.
|
public NativeSystemInfo()
NativeSystemInfo with package scope so only the SystemInfoFactory can instantiate
this object.public boolean isNative()
true to indicate that the native library is available.isNative in interface SystemInfotrue if there is a low-level native API available for the JVM's platformSystemInfo.isNative()public OperatingSystemType getOperatingSystemType()
SystemInfoOperatingSystemType.JAVA is returned (in which
case, the caller can examine the Java system property "os.name" to try to detect the type).getOperatingSystemType in interface SystemInfopublic String getOperatingSystemName()
SystemInfogetOperatingSystemName in interface SystemInfopublic String getOperatingSystemVersion()
SystemInfogetOperatingSystemVersion in interface SystemInfopublic String getHostname() throws SystemInfoException
SystemInfogetHostname in interface SystemInfoSystemInfoExceptionpublic List<NetworkAdapterInfo> getAllNetworkAdapters() throws SystemInfoException
SystemInfogetAllNetworkAdapters in interface SystemInfoSystemInfoExceptionpublic 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 List<ServiceInfo> getAllServices() throws SystemInfoException
SystemInfogetAllServices in interface SystemInfoSystemInfoExceptionpublic List<ProcessInfo> getAllProcesses()
SystemInfogetAllProcesses in interface SystemInfopublic List<ProcessInfo> getProcesses(String piq)
SystemInfogetProcesses in interface SystemInfopiq - the PIQL query stringpublic ProcessInfo getThisProcess()
SystemInfogetThisProcess in interface SystemInfopublic ProcessExecutionResults executeProcess(ProcessExecution processExecution)
SystemInfoexecuteProcess in interface SystemInfoprocessExecution - the settings on how to execute the processpublic int getNumberOfCpus()
SystemInfogetNumberOfCpus in interface SystemInfopublic org.hyperic.sigar.Mem getMemoryInfo()
SystemInfogetMemoryInfo in interface SystemInfopublic org.hyperic.sigar.Swap getSwapInfo()
SystemInfogetSwapInfo in interface SystemInfopublic String readLineFromConsole(boolean noEcho) throws IOException
SystemInfotrue as the value to noEcho.
noEcho is a hint and not guaranteed to work since some implementations (like the Java-only fallback
implementation) will not be able to stop the console from echoing input.readLineFromConsole in interface SystemInfonoEcho - if true, the implementation should try to not echo the input to the consoleIOException - if failed to read console inputpublic void writeLineToConsole(String line) throws IOException
SystemInfoline.writeLineToConsole in interface SystemInfoIOExceptionpublic CpuInformation getCpu(int cpuIndex)
SystemInfogetCpu in interface SystemInfocpuIndex - identifies the CPU whose information is to be returned; on a single-CPU system, the index must
be 0.public List<FileSystemInfo> getFileSystems()
SystemInfogetFileSystems in interface SystemInfopublic FileSystemInfo getFileSystem(String path)
SystemInfogetFileSystem in interface SystemInfopath - the file or directory whose mounted file system should be returnedpublic org.hyperic.sigar.DirUsage getDirectoryUsage(String path)
getDirectoryUsage in interface SystemInfopublic String getSystemArchitecture()
SystemInfogetSystemArchitecture in interface SystemInfoCopyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.