Package com.iizix.os

Class OSSystemInfo<INFO>

  • public class OSSystemInfo<INFO>
    extends java.lang.Object
    Package to retrieve system information from the OS.
    Christopher Mindus
    • Field Detail


        public static final long DEFAULT_INTERVAL
        The default history gatherer interval: 30 seconds.
        See Also:
        Constant Field Values
    • Constructor Detail

      • OSSystemInfo

        public OSSystemInfo​(IAdditonalInformation<INFO> informationProvider)
        The constructor.
        informationProvider - The additional information provider to be stored with the history data, or null for none.
    • Method Detail

      • getBasic

        public static OSSystemInfo.Basic getBasic()
        Gets the basic information.

        If a security manager prohibits access to the OS information, a warning message is logged in the console.

        The basic information, or null if the OS management bean failed loading or a security manager restricts access to the OS information.
      • getSystemLoadAverage

        public static double getSystemLoadAverage()
        Gets the average load during the last minute.
        The load between 0.0 to 1.0, negative if not available.
      • getAvailableProcessors

        public static int getAvailableProcessors()
        Gets the number of processors available to the Java virtual machine. Note that this value may change during the JVM lifetime.
        The number of processors, never smaller than 1.
      • getDetails

        public static OSSystemInfo.Details getDetails()
        Gets detailed information of the OS and process memory/swap space usage and CPU load.
        The details instance or null if not supported.
      • startHistory

        public boolean startHistory​(long interval)
        Starts the history gatherer. This clears the history. If the gathering information is not available, a warning message is logged, otherwise an information message is logged about the start.
        interval - In milliseconds.
        true for OK, false if already started or history not available due to security restrictions.
      • setMaxHistorySize

        public void setMaxHistorySize​(int maxSize)
        Sets the maximum number of entries in the history.
        maxSize - The maximum size, between 100 and 100_000.
        java.lang.IllegalArgumentException - If range is invalid.
      • getHistoryInterval

        public long getHistoryInterval()
        Gets the interval used for gathering of history entries.
        Interval in milliseconds, zero if never started.
      • isGatheringHistory

        public boolean isGatheringHistory()
        Checks if history is being gathered.
        true if timer is running, false otherwise.
      • stopHistory

        public boolean stopHistory()
        Stops the history gatherer.
        true for OK, false if already stopped or never started.
      • getHistory

        public OSSystemInfo.HistoryEntry<INFO>[] getHistory​(long start)
        Gets the history entries gathered between a date up to the last available entry. The history entries are gathered at specific interval defined at start of history.
        start - The start time for the events in milliseconds since the Epoch, or zero for all history entries.
        The entries, possibly empty array.