public abstract class AbstractOperatingSystem extends Object implements OperatingSystem
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractOperatingSystem.FamilyVersionInfo |
OperatingSystem.OSVersionInfo, OperatingSystem.ProcessSort
Modifier and Type | Field and Description |
---|---|
protected OperatingSystemVersion |
version |
Constructor and Description |
---|
AbstractOperatingSystem() |
Modifier and Type | Method and Description |
---|---|
int |
getBitness()
Gets the bitness (32 or 64) of the operating system.
|
String |
getFamily()
Operating system family.
|
String |
getManufacturer()
Manufacturer.
|
OSProcess |
getProcess(int pid)
Gets information on a currently running process
|
OSProcess[] |
getProcesses()
Gets currently running processes.
|
List<OSProcess> |
getProcesses(Collection<Integer> pids)
Gets information on a currently running processes.
|
List<OSProcess> |
getProcesses(Collection<Integer> pids,
boolean slowFields)
Gets information on a currently running processes.
|
OSProcess[] |
getProcesses(int limit,
OperatingSystem.ProcessSort sort)
Gets currently running processes, optionally limited to the top "N" for a
particular sorting order.
|
OSService[] |
getServices()
Gets the all services on the system.
|
OperatingSystemVersion |
getVersion()
Operating system version.
|
OperatingSystem.OSVersionInfo |
getVersionInfo()
Operating system version information.
|
boolean |
isElevated()
Determine whether the current process has elevated permissions such as sudo /
Administrator
|
protected List<OSProcess> |
processSort(List<OSProcess> processes,
int limit,
OperatingSystem.ProcessSort sort)
Sorts an array of processes using the specified sorting, returning an array
with the top limit results if positive.
|
protected abstract int |
queryBitness(int jvmBitness)
Backup OS-specific query to determine bitness if previous checks fail
|
protected abstract boolean |
queryElevated() |
protected abstract AbstractOperatingSystem.FamilyVersionInfo |
queryFamilyVersionInfo() |
protected abstract String |
queryManufacturer() |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getChildProcesses, getFileSystem, getNetworkParams, getProcess, getProcessAffinityMask, getProcessCount, getProcesses, getProcessId, getSystemBootTime, getSystemUptime, getThreadCount
protected OperatingSystemVersion version
public String getManufacturer()
OperatingSystem
getManufacturer
in interface OperatingSystem
protected abstract String queryManufacturer()
public String getFamily()
OperatingSystem
getFamily
in interface OperatingSystem
public OperatingSystem.OSVersionInfo getVersionInfo()
OperatingSystem
getVersionInfo
in interface OperatingSystem
protected abstract AbstractOperatingSystem.FamilyVersionInfo queryFamilyVersionInfo()
public OperatingSystemVersion getVersion()
OperatingSystem
getVersion
in interface OperatingSystem
public int getBitness()
OperatingSystem
getBitness
in interface OperatingSystem
protected abstract int queryBitness(int jvmBitness)
jvmBitness
- The bitness of the JVMpublic boolean isElevated()
OperatingSystem
isElevated
in interface OperatingSystem
public OSService[] getServices()
OperatingSystem
getServices
in interface OperatingSystem
OSService
objectsprotected abstract boolean queryElevated()
protected List<OSProcess> processSort(List<OSProcess> processes, int limit, OperatingSystem.ProcessSort sort)
processes
- The array to sortlimit
- The number of results to return if positive; if zero returns all
resultssort
- The sorting to use, or nullpublic OSProcess[] getProcesses()
OperatingSystem
getProcesses
in interface OperatingSystem
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. Some fields that are slow to retrieve
(e.g., commandlines and group information on Windows, open files on
Unix and Linux) will be skipped.public OSProcess[] getProcesses(int limit, OperatingSystem.ProcessSort sort)
OperatingSystem
getProcesses
in interface OperatingSystem
limit
- Max number of results to return, or 0 to return all resultssort
- If not null, determines sorting of resultsOSProcess
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. Some fields that are slow to retrieve
(e.g., group information on Windows, open files on Unix and Linux)
will be skipped.public List<OSProcess> getProcesses(Collection<Integer> pids)
OperatingSystem
getProcesses
in interface OperatingSystem
pids
- A collection of process IDsOSProcess
object for the specified
process ids if it is runningpublic List<OSProcess> getProcesses(Collection<Integer> pids, boolean slowFields)
OperatingSystem
getProcesses
in interface OperatingSystem
pids
- A collection of process IDsslowFields
- If false, skip OSProcess
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.OSProcess
object for the specified
process ids if it is runningpublic OSProcess getProcess(int pid)
OperatingSystem
getProcess
in interface OperatingSystem
pid
- A process IDOSProcess
object for the specified
process id if it is running; null otherwiseCopyright © 2010–2020 oshi. All rights reserved.