Package com.iizix.os
Class OSSystemInfo<INFO>
java.lang.Object
com.iizix.os.OSSystemInfo<INFO>
Package to retrieve system information from the OS.
- Author:
- Christopher Mindus
- Nested Class SummaryNested ClassesModifier and TypeClassDescription- static final classBasic OS and JVM information class.- static final classDetailed information class.- static classThe history entry information.
- Field SummaryFieldsModifier and TypeFieldDescription- static final longThe default history gatherer interval: 5 seconds.
- Constructor SummaryConstructors
- Method SummaryModifier and TypeMethodDescription- static intGets the number of processors available to the Java virtual machine.- static OSSystemInfo.Basic- getBasic()Gets the basic information.- static OSSystemInfo.DetailsGets detailed information of the OS and process memory/swap space usage and CPU load.- getHistory- (long start) Gets the history entries gathered between a date up to the last available entry.- longGets the interval used for gathering of history entries.- static doubleGets the average load during the last minute.- booleanChecks 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.- booleanStops the history gatherer.
- Field Details- DEFAULT_INTERVALpublic static final long DEFAULT_INTERVALThe default history gatherer interval: 5 seconds.- See Also:
 
 
- Constructor Details- OSSystemInfoThe constructor.- Parameters:
- informationProvider- The additional information provider to be stored with the history data, or null for none.
 
 
- Method Details- getBasicGets 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.
 
- getSystemLoadAveragepublic static double getSystemLoadAverage()Gets the average load during the last minute.- Returns:
- The load between 0.0dto1.0d, negative if not available.
 
- getAvailableProcessorspublic 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.
 
- getDetailsGets detailed information of the OS and process memory/swap space usage and CPU load.- Returns:
- The details instance or null if not supported.
 
- startHistorypublic 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.
 
- setMaxHistorySizepublic void setMaxHistorySize- (int maxSize) Sets the maximum number of entries in the history.- Parameters:
- maxSize- The maximum size, between 100 and 100_000.
- Throws:
- IllegalArgumentException- If range is invalid.
 
- getHistoryIntervalpublic long getHistoryInterval()Gets the interval used for gathering of history entries.- Returns:
- Interval in milliseconds, zero if never started.
 
- isGatheringHistorypublic boolean isGatheringHistory()Checks if history is being gathered.- Returns:
- true if timer is running, false otherwise.
 
- stopHistorypublic boolean stopHistory()Stops the history gatherer.- Returns:
- true for OK, false if already stopped or never started.
 
- getHistoryGets 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.