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 classOperatingSystem.OSVersionInfostatic classOperatingSystem.ProcessSortControls sorting of Process output -
Method Summary
Modifier and Type Method Description intgetBitness()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.StringgetFamily()Operating system family.FileSystemgetFileSystem()Instantiates aFileSystemobject.InternetProtocolStatsgetInternetProtocolStats()Instantiates aInternetProtocolStatsobject.java.lang.StringgetManufacturer()Manufacturer.NetworkParamsgetNetworkParams()Instantiates aNetworkParamsobject.OSProcessgetProcess(int pid)Gets information on a currently running processintgetProcessCount()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 aCollectionof currently running processes.intgetProcessId()Gets the current process IDOSService[]getServices()Gets the all services on the system.longgetSystemBootTime()Get Unix time of boot.longgetSystemUptime()Get the System up time (time since boot).intgetThreadCount()Get the number of threads currently runningOperatingSystem.OSVersionInfogetVersionInfo()Operating system version information.booleanisElevated()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 aFileSystemobject.- Returns:
- A
FileSystemobject.
-
getInternetProtocolStats
InternetProtocolStats getInternetProtocolStats()Instantiates aInternetProtocolStatsobject.- Returns:
- a
InternetProtocolStatsobject.
-
getProcesses
java.util.List<OSProcess> getProcesses()Gets currently running processes. No order is guaranteed.- Returns:
- An
UnmodifiableListofOSProcessobjects 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.INVALIDif 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
UnmodifiableListofOSProcessobjects 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.INVALIDif a process terminates during iteration.
-
getProcesses
Gets information on aCollectionof currently running processes. This has potentially improved performance vs. iterating individual processes.- Parameters:
pids- A collection of process IDs- Returns:
- An
UnmodifiableListofOSProcessobjects for the specified process ids if it is running
-
getProcess
Gets information on a currently running process- Parameters:
pid- A process ID- Returns:
- An
OSProcessobject 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
UnmodifiableListofOSProcessobjects 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.INVALIDif 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 aNetworkParamsobject.- Returns:
- A
NetworkParamsobject.
-
getServices
OSService[] getServices()Gets the all services on the system. The definition of what is a service is platform-dependent.- Returns:
- An array of
OSServiceobjects
-