java.lang.Object
oshi.util.platform.unix.solaris.KstatUtil.KstatChain
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- KstatUtil
A copy of the Kstat chain, encapsulating a
kstat_ctl_t
object. Only one thread may actively use this
object at any time.
The chain is created once calling LibKstat.kstat_open()
and then this object is instantiated using the
KstatUtil.openChain()
method. Instantiating this object updates the chain using
LibKstat.kstat_chain_update(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl)
. The control object should be closed with close()
, which releases the
lock and allows another instance to be instantiated.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Release the lock on the chain.com.sun.jna.platform.unix.solaris.LibKstat.Kstat
Convenience method forLibKstat.kstat_lookup(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl, java.lang.String, int, java.lang.String)
.List<com.sun.jna.platform.unix.solaris.LibKstat.Kstat>
Convenience method forLibKstat.kstat_lookup(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl, java.lang.String, int, java.lang.String)
.boolean
read
(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp) Convenience method forLibKstat.kstat_read(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl, com.sun.jna.platform.unix.solaris.LibKstat.Kstat, com.sun.jna.Pointer)
which gets data from the kernel for the kstat pointed to byksp
.int
update()
Convenience method forLibKstat.kstat_chain_update(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl)
.
-
Method Details
-
read
public boolean read(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp) Convenience method forLibKstat.kstat_read(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl, com.sun.jna.platform.unix.solaris.LibKstat.Kstat, com.sun.jna.Pointer)
which gets data from the kernel for the kstat pointed to byksp
.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
-
lookup
public com.sun.jna.platform.unix.solaris.LibKstat.Kstat lookup(String module, int instance, String name) Convenience method forLibKstat.kstat_lookup(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl, java.lang.String, int, java.lang.String)
. Traverses the kstat chain, searching for a kstat with the samemodule
,instance
, andname
fields; this triplet uniquely identifies a kstat. Ifmodule
isnull
,instance
is -1, orname
isnull
, 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
-
lookupAll
public List<com.sun.jna.platform.unix.solaris.LibKstat.Kstat> lookupAll(String module, int instance, String name) Convenience method forLibKstat.kstat_lookup(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl, java.lang.String, int, java.lang.String)
. Traverses the kstat chain, searching for all kstats with the samemodule
,instance
, andname
fields; this triplet uniquely identifies a kstat. Ifmodule
isnull
,instance
is -1, orname
isnull
, 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
-
update
public int update()Convenience method forLibKstat.kstat_chain_update(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl)
. Brings this kstat header chain in sync with that of the kernel.This function compares the kernel's current kstat chain ID(KCID), which is incremented every time the kstat chain changes, to this object's KCID.
- Returns:
- the new KCID if the kstat chain has changed, 0 if it hasn't, or -1 on failure.
-
close
public void close()Release the lock on the chain.- Specified by:
close
in interfaceAutoCloseable
-