Class KstatUtil


  • @ThreadSafe
    public final class KstatUtil
    extends java.lang.Object
    Provides access to kstat information on Solaris
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  KstatUtil.KstatChain
      A copy of the Kstat chain, encapsulating a kstat_ctl_t object.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.concurrent.locks.Lock CHAIN  
      private static com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl kstatCtl  
      private static org.slf4j.Logger LOG  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private KstatUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long dataLookupLong​(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp, java.lang.String name)
      Convenience method for LibKstat.kstat_data_lookup(com.sun.jna.platform.unix.solaris.LibKstat.Kstat, java.lang.String) with numeric return values.
      static java.lang.String dataLookupString​(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp, java.lang.String name)
      Convenience method for LibKstat.kstat_data_lookup(com.sun.jna.platform.unix.solaris.LibKstat.Kstat, java.lang.String) with String return values.
      static KstatUtil.KstatChain openChain()
      Lock the Kstat chain for use by this object until it's closed.
      static java.lang.Object[] queryKstat2​(java.lang.String mapStr, java.lang.String... names)
      Query Kstat2 with a single map
      static java.util.List<java.lang.Object[]> queryKstat2List​(java.lang.String beforeStr, java.lang.String afterStr, java.lang.String... names)
      Query Kstat2 iterating over maps using a wildcard indicating a 0-indexed list, such as a cpu.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

        private static final org.slf4j.Logger LOG
      • CHAIN

        private static final java.util.concurrent.locks.Lock CHAIN
      • kstatCtl

        private static com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl kstatCtl
    • Constructor Detail

      • KstatUtil

        private KstatUtil()
    • Method Detail

      • openChain

        public static KstatUtil.KstatChain openChain()
        Lock the Kstat chain for use by this object until it's closed.
        Returns:
        A locked copy of the chain. It should be unlocked/released when you are done with it with KstatUtil.KstatChain.close().
      • dataLookupString

        public static java.lang.String dataLookupString​(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp,
                                                        java.lang.String name)
        Convenience method for LibKstat.kstat_data_lookup(com.sun.jna.platform.unix.solaris.LibKstat.Kstat, java.lang.String) 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 search
        name - The key for the name-value pair, or name of the timer as applicable
        Returns:
        The value as a String.
      • dataLookupLong

        public static long dataLookupLong​(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp,
                                          java.lang.String name)
        Convenience method for LibKstat.kstat_data_lookup(com.sun.jna.platform.unix.solaris.LibKstat.Kstat, java.lang.String) 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 search
        name - 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.
      • queryKstat2

        public static java.lang.Object[] queryKstat2​(java.lang.String mapStr,
                                                     java.lang.String... names)
        Query Kstat2 with a single map
        Parameters:
        mapStr - The map to query
        names - Names of data to query
        Returns:
        An object array with the data corresponding to the names
      • queryKstat2List

        public static java.util.List<java.lang.Object[]> queryKstat2List​(java.lang.String beforeStr,
                                                                         java.lang.String afterStr,
                                                                         java.lang.String... names)
        Query Kstat2 iterating over maps using a wildcard indicating a 0-indexed list, such as a cpu.
        Parameters:
        beforeStr - The part of the string before the wildcard
        afterStr - The part of the string after the wildcard
        names - Names of data to query
        Returns:
        A list of object arrays with the data corresponding to the names