Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
erlang library for reading Solaris kstat data
C C++ Erlang Makefile
Branch: master

README.md

ekstat

ekstat is a interface to the solaris libkstat, it started out as a port of node-kstat and later was rewritten using parts of the C version of the kstat command line utility.

exports

The interface is rather simple it has 4 functions:

open/0

Simply returns a new kstat handle.

{ok, Handle} = ekstat:open().

update/1

Creates a new snapshot for the handle.

{ok, NumberOfInstancesUpdated} = ekstat:update(Handle).

clear/1

Clears the snapshot for the handle.

{ok, NumberOfInstancesCleared} = ekstat:clear(Handle).

read/1,2,3,4,5,6

read(Handle) -> Result
read(Handle, Class) -> Result
read(Handle, Class, Module) -> Result
read(Handle, Class, Module, Instance) -> Result
read(Handle, Class, Module, Instance, Name) -> Result
read(Handle, Class, Module, Instance, Name, Statistic) -> Result

  kstat_pattern = '_' | integer() | string()

  Handle = ekstat:kstat_handle()
  Class = kstat_pattern()
  Module = kstat_pattern()
  Instance = kstat_pattern()
  Name = kstat_pattern()
  Statistic = kstat_pattern()

  kstat_statistic = {Key::string(), Value::integer()} | {Key::string(), Value::string()}

  Result = [{Class::string(), Module::string(), Instance::integer(), Name::string(), [kstat_statistic()]}]

Reads data from the snapshot (possibly selectively) and returns it:

Class = "misc",
Module = "unix",
Instance = 1,
Name = "callout",
Statistic = "callout_timeouts",
Data = ekstat:read(Handle, Class, Module, Instance, Name, Statistic).
Data = [{"misc","unix",1,"callout",[{"callout_timeouts",21286}]}].

Atom '_' and list "*" are special types that will match anything in that column.

Simple glob matching can be done with *, for example:

Data = ekstat:read(H, '_', '_', '_', '_', "freem*").
Data = [{"pages","unix",0,"system_pages",[{"freemem",296009}]},
 {"vm","unix",0,"vminfo",[{"freemem",257625338}]}].

Regular expressions are also supported in each column, for example:

Data = ekstat:read(H, '_', '_', '_', '_', "/freemem|updates/").
Data = [{"misc","unix",0,"pset",[{"updates",78926}]},
 {"misc","unix",0,"sysinfo",[{"updates",790}]},
 {"pages","unix",0,"system_pages",[{"freemem",296009}]},
 {"vm","unix",0,"vminfo",
  [{"freemem",257625338},{"updates",790}]}].

Invalid regular expressions will return an error:

Error = ekstat:read(Handle, "/*/").
Error = {error,{kstat,"repetition-operator operand invalid"}}.
Something went wrong with that request. Please try again.