Package oshi.software.os
Interface OperatingSystem
- All Known Implementing Classes:
AbstractOperatingSystem
,FreeBsdOperatingSystem
,LinuxOperatingSystem
,MacOperatingSystem
,SolarisOperatingSystem
,WindowsOperatingSystem
@ThreadSafe public interface OperatingSystem
An operating system (OS) is the software on a computer that manages the way
different programs use its hardware, and regulates the ways that a user
controls the computer.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
OperatingSystem.OSVersionInfo
static class
OperatingSystem.ProcessSort
Controls sorting of Process output -
Method Summary
Modifier and Type Method Description int
getBitness()
Gets the bitness (32 or 64) of the operating system.java.util.List<OSProcess>
getChildProcesses(int parentPid, int limit, OperatingSystem.ProcessSort sort)
Gets currently running child processes of provided parent PID, optionally limited to the top "N" for a particular sorting order.java.lang.String
getFamily()
Operating system family.FileSystem
getFileSystem()
Instantiates aFileSystem
object.InternetProtocolStats
getInternetProtocolStats()
Instantiates aInternetProtocolStats
object.java.lang.String
getManufacturer()
Manufacturer.NetworkParams
getNetworkParams()
Instantiates aNetworkParams
object.OSProcess
getProcess(int pid)
Gets information on a currently running processint
getProcessCount()
Get the number of processes currently runningjava.util.List<OSProcess>
getProcesses()
Gets currently running processes.java.util.List<OSProcess>
getProcesses(int limit, OperatingSystem.ProcessSort sort)
Gets currently running processes, optionally limited to the top "N" for a particular sorting order.java.util.List<OSProcess>
getProcesses(java.util.Collection<java.lang.Integer> pids)
Gets information on aCollection
of currently running processes.int
getProcessId()
Gets the current process IDOSService[]
getServices()
Gets the all services on the system.long
getSystemBootTime()
Get Unix time of boot.long
getSystemUptime()
Get the System up time (time since boot).int
getThreadCount()
Get the number of threads currently runningOperatingSystem.OSVersionInfo
getVersionInfo()
Operating system version information.boolean
isElevated()
Determine whether the current process has elevated permissions such as sudo / Administrator
-
Method Details
-
getFamily
java.lang.String getFamily()Operating system family.- Returns:
- String.
-
getManufacturer
java.lang.String getManufacturer()Manufacturer.- Returns:
- String.
-
getVersionInfo
OperatingSystem.OSVersionInfo getVersionInfo()Operating system version information.- Returns:
- Version information.
-
getFileSystem
FileSystem getFileSystem()Instantiates aFileSystem
object.- Returns:
- A
FileSystem
object.
-
getInternetProtocolStats
InternetProtocolStats getInternetProtocolStats()Instantiates aInternetProtocolStats
object.- Returns:
- a
InternetProtocolStats
object.
-
getProcesses
java.util.List<OSProcess> getProcesses()Gets currently running processes. No order is guaranteed.- Returns:
- An
UnmodifiableList
ofOSProcess
objects for the specified number (or all) of currently running processes, sorted as specified. The list may contain null elements or processes with a state ofOSProcess.State.INVALID
if a process terminates during iteration.
-
getProcesses
Gets currently running processes, optionally limited to the top "N" for a particular sorting order. 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 the sort isnull
, no order is guaranteed.- Parameters:
limit
- Max number of results to return, or 0 to return all resultssort
- If not null, determines sorting of results- Returns:
- An
UnmodifiableList
ofOSProcess
objects for the specified number (or all) of currently running processes, sorted as specified. The list may contain null elements or processes with a state ofOSProcess.State.INVALID
if a process terminates during iteration.
-
getProcesses
Gets information on aCollection
of currently running processes. This has potentially improved performance vs. iterating individual processes.- Parameters:
pids
- A collection of process IDs- Returns:
- An
UnmodifiableList
ofOSProcess
objects for the specified process ids if it is running
-
getProcess
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
java.util.List<OSProcess> getChildProcesses(int parentPid, int limit, OperatingSystem.ProcessSort sort)Gets currently running child processes of provided parent PID, optionally limited to the top "N" for a particular sorting order. 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 the sort isnull
, 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
UnmodifiableList
ofOSProcess
objects representing the specified number (or all) of currently running child processes of the provided PID, sorted as specified. The list may contain null elements or processes with a state ofOSProcess.State.INVALID
if a process terminates during iteration.
-
getProcessId
int getProcessId()Gets the current process ID- Returns:
- the Process ID of the current process
-
getProcessCount
int getProcessCount()Get the number of processes currently running- Returns:
- The number of processes running
-
getThreadCount
int getThreadCount()Get the number of threads currently running- Returns:
- The number of threads running
-
getBitness
int getBitness()Gets the bitness (32 or 64) of the operating system.- Returns:
- The number of bits supported by the operating system.
-
getSystemUptime
long getSystemUptime()Get the System up time (time since boot).- Returns:
- Number of seconds since boot.
-
getSystemBootTime
long getSystemBootTime()Get Unix time of boot.- Returns:
- The approximate time at which the system booted, in seconds since the Unix epoch.
-
isElevated
boolean isElevated()Determine whether the current process has elevated permissions such as sudo / Administrator- Returns:
- True if this process has elevated permissions
-
getNetworkParams
NetworkParams getNetworkParams()Instantiates aNetworkParams
object.- Returns:
- A
NetworkParams
object.
-
getServices
OSService[] getServices()Gets the all services on the system. The definition of what is a service is platform-dependent.- Returns:
- An array of
OSService
objects
-