Package oshi.software.common
Class AbstractOperatingSystem
java.lang.Object
oshi.software.common.AbstractOperatingSystem
- All Implemented Interfaces:
- OperatingSystem
- Direct Known Subclasses:
- AixOperatingSystem,- FreeBsdOperatingSystem,- LinuxOperatingSystem,- MacOperatingSystem,- OpenBsdOperatingSystem,- SolarisOperatingSystem,- WindowsOperatingSystem
Common methods for OperatingSystem implementations
- 
Nested Class SummaryNested classes/interfaces inherited from interface oshi.software.os.OperatingSystemOperatingSystem.OSVersionInfo, OperatingSystem.ProcessFiltering, OperatingSystem.ProcessSorting
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionintGets the bitness (32 or 64) of the operating system.getChildProcesses(int parentPid, Predicate<OSProcess> filter, Comparator<OSProcess> sort, int limit) Gets currently running child processes of provided parent PID, optionally filtering, sorting, and limited to the top "N".getChildrenOrDescendants(Collection<OSProcess> allProcs, int parentPid, boolean allDescendants) Utility method for subclasses to take a full process list as input and return the children or descendants of a particular process.getChildrenOrDescendants(Map<Integer, Integer> parentPidMap, int parentPid, boolean allDescendants) Utility method for subclasses to take a map of pid to parent as input and return the children or descendants of a particular process.getDescendantProcesses(int parentPid, Predicate<OSProcess> filter, Comparator<OSProcess> sort, int limit) Gets currently running processes of provided parent PID's descendants, including their children, the children's children, etc., optionally filtering, sorting, and limited to the top "N".Get the Operating System family.Get the Operating System manufacturer.getProcesses(Predicate<OSProcess> filter, Comparator<OSProcess> sort, int limit) Gets currently running processes, optionally filtering, sorting, and limited to the top "N".Get Operating System version information.protected abstract intqueryBitness(int jvmBitness) Backup OS-specific query to determine bitness if previous checks failqueryChildProcesses(int parentPid) queryDescendantProcesses(int parentPid) protected abstract Pair<String, OperatingSystem.OSVersionInfo> protected abstract StringtoString()Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface oshi.software.os.OperatingSystemgetCurrentProcess, getCurrentThread, getDesktopWindows, getFileSystem, getInstalledApplications, getInternetProtocolStats, getNetworkParams, getProcess, getProcessCount, getProcesses, getProcesses, getProcessId, getServices, getSessions, getSystemBootTime, getSystemUptime, getThreadCount, getThreadId, isElevated
- 
Field Details- 
USE_WHO_COMMANDprotected static final boolean USE_WHO_COMMAND
 
- 
- 
Constructor Details- 
AbstractOperatingSystempublic AbstractOperatingSystem()
 
- 
- 
Method Details- 
getManufacturerDescription copied from interface:OperatingSystemGet the Operating System manufacturer.- Specified by:
- getManufacturerin interface- OperatingSystem
- Returns:
- the manufacturer
 
- 
queryManufacturer
- 
getFamilyDescription copied from interface:OperatingSystemGet the Operating System family.- Specified by:
- getFamilyin interface- OperatingSystem
- Returns:
- the family
 
- 
getVersionInfoDescription copied from interface:OperatingSystemGet Operating System version information.- Specified by:
- getVersionInfoin interface- OperatingSystem
- Returns:
- version information
 
- 
queryFamilyVersionInfo
- 
getBitnesspublic int getBitness()Description copied from interface:OperatingSystemGets the bitness (32 or 64) of the operating system.- Specified by:
- getBitnessin interface- OperatingSystem
- Returns:
- The number of bits supported by the operating system.
 
- 
queryBitnessprotected abstract int queryBitness(int jvmBitness) Backup OS-specific query to determine bitness if previous checks fail- Parameters:
- jvmBitness- The bitness of the JVM
- Returns:
- The operating system bitness
 
- 
getProcessespublic List<OSProcess> getProcesses(Predicate<OSProcess> filter, Comparator<OSProcess> sort, int limit) Description copied from interface:OperatingSystemGets currently running processes, optionally filtering, sorting, and limited to the top "N".- Specified by:
- getProcessesin interface- OperatingSystem
- Parameters:
- filter- An optional- Predicatelimiting the results to the specified filter. Some common predicates are available in- OperatingSystem.ProcessSorting. May be- nullfor no filtering.
- sort- An optional- Comparatorspecifying the sorting order. Some common comparators are available in- OperatingSystem.ProcessSorting. May be- nullfor no sorting.
- limit- Max number of results to return, or 0 to return all results
- Returns:
- A list of OSProcessobjects, optionally filtered, sorted, and limited to the specified number.The list may contain processes with a state of OSProcess.State.INVALIDif a process terminates during iteration.
 
- 
queryAllProcesses
- 
getChildProcessespublic List<OSProcess> getChildProcesses(int parentPid, Predicate<OSProcess> filter, Comparator<OSProcess> sort, int limit) Description copied from interface:OperatingSystemGets currently running child processes of provided parent PID, optionally filtering, sorting, and limited to the top "N".- Specified by:
- getChildProcessesin interface- OperatingSystem
- Parameters:
- parentPid- The Process ID whose children to list.
- filter- An optional- Predicatelimiting the results to the specified filter. Some common predicates are available in- OperatingSystem.ProcessSorting. May be- nullfor no filtering.
- sort- An optional- Comparatorspecifying the sorting order. Some common comparators are available in- OperatingSystem.ProcessSorting. May be- nullfor no sorting.
- limit- Max number of results to return, or 0 to return all results
- Returns:
- A list of OSProcessobjects representing the currently running child processes of the provided PID, optionally filtered, sorted, and limited to the specified number.The list may contain processes with a state of OSProcess.State.INVALIDif a process terminates during iteration.
 
- 
queryChildProcesses
- 
getDescendantProcessespublic List<OSProcess> getDescendantProcesses(int parentPid, Predicate<OSProcess> filter, Comparator<OSProcess> sort, int limit) Description copied from interface:OperatingSystemGets currently running processes of provided parent PID's descendants, including their children, the children's children, etc., optionally filtering, sorting, and limited to the top "N".- Specified by:
- getDescendantProcessesin interface- OperatingSystem
- Parameters:
- parentPid- The Process ID whose children to list.
- filter- An optional- Predicatelimiting the results to the specified filter. Some common predicates are available in- OperatingSystem.ProcessSorting. May be- nullfor no filtering.
- sort- An optional- Comparatorspecifying the sorting order. Some common comparators are available in- OperatingSystem.ProcessSorting. May be- nullfor no sorting.
- limit- Max number of results to return, or 0 to return all results
- Returns:
- A list of OSProcessobjects representing the currently running descendant processes of the provided PID, optionally filtered, sorted, and limited to the specified number.The list may contain processes with a state of OSProcess.State.INVALIDif a process terminates during iteration.
 
- 
queryDescendantProcesses
- 
getChildrenOrDescendantsprotected static Set<Integer> getChildrenOrDescendants(Collection<OSProcess> allProcs, int parentPid, boolean allDescendants) Utility method for subclasses to take a full process list as input and return the children or descendants of a particular process. The process itself is also returned to more efficiently extract its start time for filtering- Parameters:
- allProcs- A collection of all processes
- parentPid- The process ID whose children or descendants to return
- allDescendants- If false, only gets immediate children of this process. If true, gets all descendants.
- Returns:
- Set of children or descendants of parentPid
 
- 
getChildrenOrDescendantsprotected static Set<Integer> getChildrenOrDescendants(Map<Integer, Integer> parentPidMap, int parentPid, boolean allDescendants) Utility method for subclasses to take a map of pid to parent as input and return the children or descendants of a particular process.- Parameters:
- parentPidMap- a map of all processes with processID as key and parentProcessID as value
- parentPid- The process ID whose children or descendants to return
- allDescendants- If false, only gets immediate children of this process. If true, gets all descendants.
- Returns:
- Set of children or descendants of parentPid, including the parent
 
- 
toString
 
-