Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   pmda    ( 3 )

введение в библиотеку поддержки агента домена Performance Metrics (introduction to the Performance Metrics Domain Agent support library)

INSTANCES AND INSTANCE DOMAINS

Three structures are declared in /usr/include/pcp/pmda.h which provide a framework for declaring the metrics and instances supported by the PMDA.

Every instance requires a unique integer identifier and a unique name, as defined by the structure pmdaInstid:

/* * Instance description: index and name */

typedef struct { int i_inst; /* internal instance identifier */ char *i_name; /* external instance identifier */ } pmdaInstid;

An instance domain requires its own unique identification (pmInDom), the number of instances the domain represents, and a pointer to an array of instance descriptions. This is defined in the structure pmdaIndom:

/* * Instance domain description: unique instance id, * number of instances in this domain, and the list of * instances (not null terminated). */

typedef struct { pmInDom it_indom; /* indom, filled in */ int it_numinst; /* number of instances */ pmdaInstid *it_set; /* instance identifiers */ } pmdaIndom;

The simple PMDA has one instance domain for simple.color with three instances (red, green and blue), and a second instance domain for simple.now with instances which can be specified at run-time. These instance domains are defined as:

static pmdaInstid _color[] = { { 0, "red" }, { 1, "green" }, { 2, "blue" } }; static pmdaInstid *_timenow = NULL;

static pmdaIndom indomtab[] = { #define COLOR_INDOM 0 { COLOR_INDOM, 3, _color }, #define NOW_INDOM 1 { NOW_INDOM, 0, NULL }, };

The preprocessor macros COLOR_INDOM and NOW_INDOM are used in the metric description table to identify the instance domains of individual metrics. These correspond to the serial value in the instance domain pmInDom structure (the domain field is set by pmdaInit(3) at run-time). The serial value must be unique for each instance domain within the PMDA.

The indom table shown above which is usually passed to pmdaInit(3) does not need to be created if one wants to write one's own Fetch and Instance functions. See pmdaInit(3) for more details.