Package oshi.software.os.linux
Class LinuxOperatingSystem
- java.lang.Object
-
- oshi.software.common.AbstractOperatingSystem
-
- oshi.software.os.linux.LinuxOperatingSystem
-
- All Implemented Interfaces:
java.io.Serializable
,OperatingSystem
public class LinuxOperatingSystem extends AbstractOperatingSystem
Linux is a family of free operating systems most commonly used on personal computers.- Author:
- widdis[at]gmail[dot]com
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface oshi.software.os.OperatingSystem
OperatingSystem.ProcessSort
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
codeName
protected java.lang.String
versionId
-
Fields inherited from class oshi.software.common.AbstractOperatingSystem
bitness, family, manufacturer, version
-
-
Constructor Summary
Constructors Constructor Description LinuxOperatingSystem()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description OSProcess[]
getChildProcesses(int parentPid, int limit, OperatingSystem.ProcessSort sort)
Gets currently running child processes of provided PID.FileSystem
getFileSystem()
Instantiates aFileSystem
object.static long
getHz()
Gets Jiffies per second, useful for converting ticks to milliseconds and vice versa.NetworkParams
getNetworkParams()
Instantiates aNetworkParams
object.OSProcess
getProcess(int pid)
Gets information on a currently running processint
getProcessCount()
Get the number of processes currently runningOSProcess[]
getProcesses(int limit, OperatingSystem.ProcessSort sort, boolean slowFields)
Gets currently running processes.int
getProcessId()
Gets the current process IDprotected static java.lang.String
getReleaseFilename()
Looks for a collection of possible distrib-release filenamesint
getThreadCount()
Get the number of threads currently running-
Methods inherited from class oshi.software.common.AbstractOperatingSystem
getBitness, getFamily, getManufacturer, getProcesses, getProcesses, getVersion, processSort, toString
-
-
-
-
Method Detail
-
getFileSystem
public FileSystem getFileSystem()
Instantiates aFileSystem
object.- Returns:
- A
FileSystem
object.
-
getProcesses
public OSProcess[] getProcesses(int limit, OperatingSystem.ProcessSort sort, boolean slowFields)
Gets currently running processes. If a positive limit is specified, returns only that number of processes; zero will return all processes. The order may be specified by the sort parameter, for example, to return the top cpu or memory consuming processes; if null, no order is guaranteed.- Parameters:
limit
- Max number of results to return, or 0 to return all resultssort
- If not null, determines sorting of resultsslowFields
- If false, skipOSProcess
fields that are slow to retrieve (e.g., group information on Windows, open files on Unix and Linux). If true, include all fields, regardless of how long it takes to retrieve the data.- Returns:
- An array of
OSProcess
objects for the specified number (or all) of currently running processes, sorted as specified. The array may contain null elements if a process terminates during iteration.
-
getProcess
public OSProcess getProcess(int pid)
Gets information on a currently running process- Parameters:
pid
- A process ID- Returns:
- An
OSProcess
object for the specified process id if it is running; null otherwise
-
getChildProcesses
public OSProcess[] getChildProcesses(int parentPid, int limit, OperatingSystem.ProcessSort sort)
Gets currently running child processes of provided PID. If a positive limit is specified, returns only that number of processes; zero will return all processes. The order may be specified by the sort parameter, for example, to return the top cpu or memory consuming processes; if null, no order is guaranteed.- Parameters:
parentPid
- A process IDlimit
- Max number of results to return, or 0 to return all resultssort
- If not null, determines sorting of results- Returns:
- An array of
OSProcess
objects presenting the specified number (or all) of currently running child processes of the provided PID, sorted as specified. The array may contain null elements if a process terminates during iteration.
-
getProcessId
public int getProcessId()
Gets the current process ID- Returns:
- the Process ID of the current process
-
getProcessCount
public int getProcessCount()
Get the number of processes currently running- Returns:
- The number of processes running
-
getThreadCount
public int getThreadCount()
Get the number of threads currently running- Returns:
- The number of threads running
-
getNetworkParams
public NetworkParams getNetworkParams()
Instantiates aNetworkParams
object.- Returns:
- A
NetworkParams
object.
-
getReleaseFilename
protected static java.lang.String getReleaseFilename()
Looks for a collection of possible distrib-release filenames- Returns:
- The first valid matching filename
-
getHz
public static long getHz()
Gets Jiffies per second, useful for converting ticks to milliseconds and vice versa.- Returns:
- Jiffies per second.
-
-