Class LinuxOperatingSystem

  • All Implemented Interfaces:
    java.io.Serializable, OperatingSystem

    public class LinuxOperatingSystem
    extends AbstractOperatingSystem
    Linux is a family of free operating systems most commonly used on personal computers.
    Author:
    widdis[at]gmail[dot]com
    See Also:
    Serialized Form
    • Field Detail

      • versionId

        protected java.lang.String versionId
      • codeName

        protected java.lang.String codeName
    • Constructor Detail

      • LinuxOperatingSystem

        public LinuxOperatingSystem()
    • Method Detail

      • getProcesses

        public OSProcess[] getProcesses​(int limit,
                                        OperatingSystem.ProcessSort sort,
                                        boolean slowFields)
        Gets currently running processes. 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 null, no order is guaranteed.
        Parameters:
        limit - Max number of results to return, or 0 to return all results
        sort - If not null, determines sorting of results
        slowFields - 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.
        Returns:
        An array of 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.
      • getProcess

        public OSProcess getProcess​(int pid)
        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

        public OSProcess[] getChildProcesses​(int parentPid,
                                             int limit,
                                             OperatingSystem.ProcessSort sort)
        Gets currently running child processes of provided PID. 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 null, no order is guaranteed.
        Parameters:
        parentPid - A process ID
        limit - Max number of results to return, or 0 to return all results
        sort - If not null, determines sorting of results
        Returns:
        An array of OSProcess objects presenting the specified number (or all) of currently running child processes of the provided PID, sorted as specified. The array may contain null elements if a process terminates during iteration.
      • getProcessId

        public int getProcessId()
        Gets the current process ID
        Returns:
        the Process ID of the current process
      • getProcessCount

        public int getProcessCount()
        Get the number of processes currently running
        Returns:
        The number of processes running
      • getThreadCount

        public int getThreadCount()
        Get the number of threads currently running
        Returns:
        The number of threads running
      • getReleaseFilename

        protected static java.lang.String getReleaseFilename()
        Looks for a collection of possible distrib-release filenames
        Returns:
        The first valid matching filename
      • getHz

        public static long getHz()
        Gets Jiffies per second, useful for converting ticks to milliseconds and vice versa.
        Returns:
        Jiffies per second.