Class OSSession

java.lang.Object
oshi.software.os.OSSession

@PublicApi @Immutable public class OSSession extends Object
This class encapsulates information about users who are currently logged in to an operating system.

Sessions are obtained from OperatingSystem.getSessions(). See that method's documentation for important thread-safety notes on macOS, Linux, and Unix systems.

See Also:
  • Constructor Details

    • OSSession

      public OSSession(String userName, String terminalDevice, long loginTime, String host)
      Creates an OSSession.
      Parameters:
      userName - the user name
      terminalDevice - the terminal device
      loginTime - the login time in epoch ms
      host - the remote host
  • Method Details

    • getUserName

      public String getUserName()
      Gets the login name of the user
      Returns:
      the userName
    • getTerminalDevice

      public String getTerminalDevice()
      Gets the terminal device (such as tty, pts, etc.) the user used to log in
      Returns:
      the terminalDevice
    • getLoginTime

      public long getLoginTime()
      Gets the time the user logged in
      Returns:
      the loginTime, in milliseconds since the 1970 epoch
    • getHost

      public String getHost()
      Gets the remote host from which the user logged in
      Returns:
      the host as either an IPv4 or IPv6 representation. If the host is unspecified, may also be an empty string, depending on the platform.
    • toString

      public String toString()
      Overrides:
      toString in class Object