kstat - API for kernel statistics
interface Kstat Kstatinfo info ; boolean stale ; Snapshot snapshot ; Snapshot fresh_snapshot(); interface Control update();
KSTAT(3rad) RAD Module Definitions KSTAT(3rad) NAME kstat - API for kernel statistics SYNOPSIS interface Kstat Kstatinfo info ; boolean stale ; Snapshot snapshot ; Snapshot fresh_snapshot(); interface Control update(); DESCRIPTION API com.oracle.solaris.rad.kstat This API exposes kernel statistics, or kstats, to rad(1m) clients. Two core interfaces are provided: 1. Kstat - an object that represents a kstat 2. Control - an administration object Python kstat wrapper. INTERFACES interface Kstat The Kstat interface represents a kernel statistic. Handles to this type of object can be retrieved from the RAD server using a kstat proxy object. To retrieve a specific instance, be aware of these additional keys: 1. a key named "class" paired with a kstat class 2. a key named "module" paired with a kstat module 3. a key named "instance" paired with a kstat module (integer) instance 4. a key named "name" paired with a kstat name For example, to print statistics about a particular CPU on a system: Example 1. Kstat interface (Python) import rad.client as radcli import rad.connect as radcon import rad.bindings.com.oracle.solaris.rad.kstat_1 as kbind # Create a connection con = radcon.connect_unix() # Retrieve a particular kstat pat = radcli.ADRGlobPattern({"class" : "misc", "module" : "cpu_info", "instance" : "2", "name" : "cpu_info2"}) # Get a native-looking python object that throws RAD exceptions kstat = con.get_object(kbind.Kstat(), pat) # Do something with our kstat data = kstat.fresh_snapshot().data assert data.discriminant == kbind.Kstype.NAMED for named in data.NAMED: print "%s: %s" % (named.name, getattr(named.value, str(named.value.discriminant))) Kstat Properties Kstatinfo info (read-only) -- static kstat information boolean stale (read-only) -- true if the kstat doesn't exist kstats are often associated with parts of the system that can come and go over time, and likewise will come and go. To simplify consumers, a kstat object once referenced will remain but be marked stale when the underlying kstat object goes away. Snapshot snapshot (read-only) -- a snapshot of the kstat as of the last update Read Error: (no type) -- the kstat doesn't currently exist Kstat Methods Snapshot fresh_snapshot() obtains a fresh snapshot of the kstat Result: Snapshot Error: (no type) -- the kstat doesn't currently exist interface Control The Control interface is an administrative API into the kstats subsystem. Handles to this type of object can be retrieved from the RAD server using a simple object proxy. Control Methods update() update the kstat chain Updates the kstat chain. All referenced kstats' snapshots are updated. After update, the set of available kstats may change. ENUMERATED TYPES enum Ksdtype -- a named kstat data value type CHAR (0) -- a string (of up to a fixed size) INT32 (1) -- a signed 32-bit integer UINT32 (2) -- an unsigned 32-bit integer INT64 (3) -- a signed 64-bit integer UINT64 (4) -- an unsigned 64-bit integer FLOAT (5) -- a 32-bit floating point number DOUBLE (6) -- a 64-bit floating point number STRING (7) -- an arbitrary lengthed string enum Kstype -- kstat type RAW (0) -- raw data, can be anything NAMED (1) -- name/value pairs INTR (2) -- interrupt statistics IO (3) -- I/O statistics TIMER (4) -- event timers UNKNOWN (5) STRUCTURE TYPES struct Ksvalue -- a named kstat data value This is a struct representing a named kstat data value. Use the discriminant enum to determine what type of data the value holds. Fields: Ksdtype discriminant string CHAR (nullable) integer INT32 uinteger UINT32 long INT64 ulong UINT64 float FLOAT double DOUBLE string STRING (nullable) struct Kstat_named -- a named kstat name/value pair Fields: string name -- counter name Ksvalue value -- counter value struct Kstat_intr -- interrupt statistics Counters for various types of interrupts. Fields: uinteger hard -- hardware interrupts uinteger soft -- soft interrupts uinteger watchdog -- watchdog interrupts uinteger spurious -- spurious interrupts uinteger multsvc -- multiple-service interrupts struct Kstat_timer -- a timer kstat statistic Provides basic counting and timing information. Fields: string name -- event name ulong num_events -- number of events ulong elapsed_time -- cumulative elapsed time ulong min_time -- shortest event duration ulong max_time -- longest event duration ulong start_time -- previous event start time ulong stop_time -- previous event stop time struct Kstat_io -- I/O statistics Fields: ulong nread -- number of bytes read ulong nwritten -- number of bytes written uinteger reads -- number of read operations uinteger writes -- number of write operations ulong wtime -- cumulative wait time ulong wlentime -- cumulative wait length*time product ulong wlastupdate -- last time wait queue changed ulong rtime -- cumulative run time ulong rlentime -- cumulative run length*time product ulong rlastupdate -- last time run queue changed uinteger wcnt -- count of elements in wait state uinteger rcnt -- count of elements in run state struct Ksdata -- typed kernel statistics data Use the discriminant enum to determine what type of data the structure holds. Fields: Kstype discriminant opaque RAW (nullable) Kstat_named[] NAMED (nullable) Kstat_intr INTR (nullable) Kstat_io IO (nullable) Kstat_timer[] TIMER (nullable) string UNKNOWN (nullable) struct Snapshot -- a snapshot in time of a kernel statistic Fields: ulong snaptime -- when this snapshot was taken Ksdata data -- statistic snapshot data struct Kstatinfo -- static kstat information Fields: string module -- module name string name -- kstat name string klass -- kstat class integer instance -- module's instance Kstype type -- kstat data type ulong crtime -- kstat creation time Version: (1.0) ATTRIBUTES See attributes(5) for descriptions of the following attributes: +--------------------+-------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-------------------------+ |Availability | system/management/rad/* | +--------------------+-------------------------+ |Interface Stability | Private | +--------------------+-------------------------+ SEE ALSO rad(1M) SunOS 5.11 2017-01-11 KSTAT(3rad)