libpcp_mmv Application Programming Interface (API) can be called from C, C++, Perl and Python (a separate project, Parfait, services the needs of Java applications). Each language has access to the complete set of functionality offered by libpcp_mmv. In most cases, the calling conventions differ only slightly between languages - in the case of Java and Parfait, they differ significantly however.
mmv_stats_init, and ended with a call to mmv_stats_stop. These calls manipulate global state shared by the library and application. These are the only calls requiring synchonization and a single call to each is typically performed early and late in the life of the application (although they can be used to reset the library state as well, at any time). As such, the choice of synchonization primitive is left to the application, and none is currently performed by the library.
void *mmv_stats_init(const char *name, int cluster, mmv_stats_flags_t flags,
const mmv_metric_t *stats, int nstats,
const mmv_indom_t *indoms, int nindoms)mmv.acme.products.count will be created by the MMV PMDA. With the MMV_FLAG_NOPREFIX flag set, that would instead become mmv.products.count. It is recommended to not disable the prefix - doing so requires the applications to ensure naming conflicts do not arise in the MMV PMDA metric names.
__pmID_int Structure”, for all MMV PMDA metrics.
mmv_stats_init define the metrics and instance domains that exist within the application. These are somewhat analagous to the final parameters of pmdaInit(3), and are best explained using Example 4.1, “Memory Mapped Value Instance Structures” and Example 4.2, “Memory Mapped Value Metrics Structures”. As mentioned earlier, the full source code for this example instrumented application can be found in ${PCP_DEMOS_DIR}/mmv.
Example 4.1. Memory Mapped Value Instance Structures
#include <pcp/pmapi.h>
#include <pcp/mmv_stats.h>
static mmv_instances_t products[] = {
{ .internal = 0, .external = "Anvils" },
{ .internal = 1, .external = "Rockets" },
{ .internal = 2, .external = "Giant_Rubber_Bands" },
};
#define ACME_PRODUCTS_INDOM 61
#define ACME_PRODUCTS_COUNT (sizeof(products)/sizeof(products[0]))
static mmv_indom_t indoms[] = {
{ .serial = ACME_PRODUCTS_INDOM,
.count = ACME_PRODUCTS_COUNT,
.instances = products,
.shorttext = "Acme products",
.helptext = "Most popular products produced by the Acme Corporation",
},
};pmdaInstid Structure”
pmdaIndom Structure” - the major difference is the addition of oneline and long help text, the purpose of which should be self-explanatory at this stage.
__pmInDom_int Structure”
mmv.acme.products metrics, and they reflect the rates at which products are built by the machines in the factory, how long these builds take for each product, and how long each product type spends queued (while waiting for factory capacity to become available).
Example 4.2. Memory Mapped Value Metrics Structures
static mmv_metric_t metrics[] = {
{ .name = "products.count",
.item = 7,
.type = MMV_TYPE_U64,
.semantics = MMV_SEM_COUNTER,
.dimension = MMV_UNITS(0,0,1,0,0,PM_COUNT_ONE),
.indom = ACME_PRODUCTS_INDOM,
.shorttext = "Acme factory product throughput",
.helptext =
"Monotonic increasing counter of products produced in the Acme Corporation\n"
"factory since starting the Acme production application. Quality guaranteed.",
},
{ .name = "products.time",
.item = 8,
.type = MMV_TYPE_U64,
.semantics = MMV_SEM_COUNTER,
.dimension = MMV_UNITS(0,1,0,0,PM_TIME_USEC,0),
.indom = ACME_PRODUCTS_INDOM,
.shorttext = "Machine time spent producing Acme products",
.helptext =
"Machine time spent producing Acme Corporation products. Does not include\n"
"time in queues waiting for production machinery.",
},
{ .name = "products.queuetime",
.item = 10,
.type = MMV_TYPE_U64,
.semantics = MMV_SEM_COUNTER,
.dimension = MMV_UNITS(0,1,0,0,PM_TIME_USEC,0),
.indom = ACME_PRODUCTS_INDOM,
.shorttext = "Queued time while producing Acme products",
.helptext =
"Time spent in the queue waiting to build Acme Corporation products,\n"
"while some other Acme product was being built instead of this one.",
},
};
#define INDOM_COUNT (sizeof(indoms)/sizeof(indoms[0]))
#define METRIC_COUNT (sizeof(metrics)/sizeof(metrics[0]))pmDesc Structure”
pmUnits and pmDesc Structures”
__pmID_int Structure”