Package oshi.util.platform.unix.solaris
Class KstatUtil
- java.lang.Object
-
- oshi.util.platform.unix.solaris.KstatUtil
-
public class KstatUtil extends java.lang.Object
Provides access to kstat information on Solaris- Author:
- widdis[at]gmail[dot]com
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
kstatDataLookupLong(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp, java.lang.String name)
Convenience method for kstat_data_lookup() with numeric return values.static java.lang.String
kstatDataLookupString(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp, java.lang.String name)
Convenience method for kstat_data_lookup() with String return values.static com.sun.jna.platform.unix.solaris.LibKstat.Kstat
kstatLookup(java.lang.String module, int instance, java.lang.String name)
Convenience method for kstat_lookup().static java.util.List<com.sun.jna.platform.unix.solaris.LibKstat.Kstat>
kstatLookupAll(java.lang.String module, int instance, java.lang.String name)
Convenience method for kstat_lookup().static boolean
kstatRead(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp)
Convenience method for kstat_read() which gets data from the kernel for the kstat pointed to by ksp.
-
-
-
Method Detail
-
kstatDataLookupString
public static java.lang.String kstatDataLookupString(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp, java.lang.String name)
Convenience method for kstat_data_lookup() with String return values. Searches the kstat's data section for the record with the specified name. This operation is valid only for kstat types which have named data records. Currently, only the KSTAT_TYPE_NAMED and KSTAT_TYPE_TIMER kstats have named data records.- Parameters:
ksp
- The kstat to searchname
- The key for the name-value pair, or name of the timer as applicable- Returns:
- The value as a String.
-
kstatDataLookupLong
public static long kstatDataLookupLong(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp, java.lang.String name)
Convenience method for kstat_data_lookup() with numeric return values. Searches the kstat's data section for the record with the specified name. This operation is valid only for kstat types which have named data records. Currently, only the KSTAT_TYPE_NAMED and KSTAT_TYPE_TIMER kstats have named data records.- Parameters:
ksp
- The kstat to searchname
- The key for the name-value pair, or name of the timer as applicable- Returns:
- The value as a long. If the data type is a character or string type, returns 0 and logs an error.
-
kstatRead
public static boolean kstatRead(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp)
Convenience method for kstat_read() which gets data from the kernel for the kstat pointed to by ksp. ksp.ks_data is automatically allocated (or reallocated) to be large enough to hold all of the data. ksp.ks_ndata is set to the number of data fields, ksp.ks_data_size is set to the total size of the data, and ksp.ks_snaptime is set to the high-resolution time at which the data snapshot was taken.- Parameters:
ksp
- The kstat from which to retrieve data- Returns:
- True if successful; false otherwise
-
kstatLookup
public static com.sun.jna.platform.unix.solaris.LibKstat.Kstat kstatLookup(java.lang.String module, int instance, java.lang.String name)
Convenience method for kstat_lookup(). Traverses the kstat chain, searching for a kstat with the same ks_module, ks_instance, and ks_name fields; this triplet uniquely identifies a kstat. If ks_module is NULL, ks_instance is -1, or ks_name is NULL, then those fields will be ignored in the search.- Parameters:
module
- The module, or null to ignoreinstance
- The instance, or -1 to ignorename
- The name, or null to ignore- Returns:
- The first match of the requested Kstat structure if found, or null
-
kstatLookupAll
public static java.util.List<com.sun.jna.platform.unix.solaris.LibKstat.Kstat> kstatLookupAll(java.lang.String module, int instance, java.lang.String name)
Convenience method for kstat_lookup(). Traverses the kstat chain, searching for all kstats with the same ks_module, ks_instance, and ks_name fields; this triplet uniquely identifies a kstat. If ks_module is NULL, ks_instance is -1, or ks_name is NULL, then those fields will be ignored in the search.- Parameters:
module
- The module, or null to ignoreinstance
- The instance, or -1 to ignorename
- The name, or null to ignore- Returns:
- All matches of the requested Kstat structure if found, or an empty list otherwise
-
-