Package com.iizix.os
Class OSSystemInfo<INFO>
- java.lang.Object
- com.iizix.os.OSSystemInfo<INFO>
 
- public class OSSystemInfo<INFO> extends java.lang.ObjectPackage to retrieve system information from the OS.- Author:
- Christopher Mindus
 
- Nested Class Summary- Nested Classes - Modifier and Type - Class - Description - static class- OSSystemInfo.BasicBasic OS and JVM information class.- static class- OSSystemInfo.DetailsDetailed information class.- static class- OSSystemInfo.HistoryEntry<INFO>The history entry information.
 - Field Summary- Fields - Modifier and Type - Field - Description - static long- DEFAULT_INTERVALThe default history gatherer interval: 30 seconds.
 - Constructor Summary- Constructors - Constructor - Description - OSSystemInfo(IAdditonalInformation<INFO> informationProvider)The constructor.
 - Method Summary- All Methods Static Methods Instance Methods Concrete Methods - Modifier and Type - Method - Description - static int- getAvailableProcessors()Gets the number of processors available to the Java virtual machine.- static OSSystemInfo.Basic- getBasic()Gets the basic information.- static OSSystemInfo.Details- getDetails()Gets detailed information of the OS and process memory/swap space usage and CPU load.- OSSystemInfo.HistoryEntry<INFO>[]- getHistory(long start)Gets the history entries gathered between a date up to the last available entry.- long- getHistoryInterval()Gets the interval used for gathering of history entries.- static double- getSystemLoadAverage()Gets the average load during the last minute.- boolean- isGatheringHistory()Checks if history is being gathered.- void- setMaxHistorySize(int maxSize)Sets the maximum number of entries in the history.- boolean- startHistory(long interval)Starts the history gatherer.- boolean- stopHistory()Stops the history gatherer.
 
- Field Detail- DEFAULT_INTERVAL- 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.- Parameters:
- 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. - Returns:
- 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.- Returns:
- 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.- Returns:
- 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.- Returns:
- 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.- Parameters:
- interval- In milliseconds.
- Returns:
- 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.- Parameters:
- maxSize- The maximum size, between 100 and 100_000.
- Throws:
- java.lang.IllegalArgumentException- If range is invalid.
 
 - getHistoryInterval- public long getHistoryInterval() Gets the interval used for gathering of history entries.- Returns:
- Interval in milliseconds, zero if never started.
 
 - isGatheringHistory- public boolean isGatheringHistory() Checks if history is being gathered.- Returns:
- true if timer is running, false otherwise.
 
 - stopHistory- public boolean stopHistory() Stops the history gatherer.- Returns:
- 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.- Parameters:
- start- The start time for the events in milliseconds since the Epoch, or zero for all history entries.
- Returns:
- The entries, possibly empty array.