'\"macro stdmacro .\" .\" Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. .\" .\" This program is free software; you can redistribute it and/or modify it .\" under the terms of the GNU General Public License as published by the .\" Free Software Foundation; either version 2 of the License, or (at your .\" option) any later version. .\" .\" This program is distributed in the hope that it will be useful, but .\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY .\" or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License .\" for more details. .\" .\" .TH PMDAINSTANCE 3 "PCP" "Performance Co-Pilot" .SH NAME \f3pmdaInstance\f1 \- return instance descriptions for a PMDA .SH "C SYNOPSIS" .ft 3 #include .br #include .sp .ad l .hy 0 .in +8n .ti -8n int pmdaInstance(pmInDom \fIindom\fP, int \fIinst\fP, char *\fIname\fP, pmInResult\ **\fIresult\fP, pmdaExt\ *\fIpmda\fP); .sp .in .hy .ad cc ... \-lpcp_pmda \-lpcp .ft 1 .SH DESCRIPTION .B pmdaInstance uses the standard .BR PMDA (3) data structures to return information concerning the instance domain .IR indom . .PP The .I result structure is constructed by .B pmdaInstance and will contain one or more instance names and/or identifiers as specified by the .I inst and .I name arguments. .PP If .I inst has the value .B PM_IN_NULL and .I name is a null string, .I result will contain all the instances names and identifiers in the instance domain. .PP If .I inst is .B PM_IN_NULL but .I name is the name of an instance in the instance domain .IR indom , then .I result will contain the instance identifier for instance .IR name . Note that if .I name contains no spaces, partial matching up to the first space in the instance name is performed, i.e. .RB `` 1 '' will match instance name .RB `` 1 .BR minute ''. If .I name contains an embedded space, then no partial matching is performed and .I name should match one of the instance names exactly. .PP If .I name is a null string but .I inst is an instance identifier in the instance domain .IR indom , then .I result will contain the name for instance .IR inst . The .I result structure is allocated with .BR malloc (3) and should be released by the caller with .BR free (3). .SH MULTI-DIMENSIONAL INSTANCE NAMING Further to the above description of .IR name , the set of rules describing external instance names is provided in the .BR pmdaCacheStore (3) manual page. .PP Instance domains adds another dimension (set of values) to metrics. However, this may not suffice to describe complex multi-dimensional instance domain situations. For this case the approach used by a number of PMDAs is to structure the external instance names using a delimiter (``/'' or ``::'' are most commonly used) to allow separation of the other dimensions. In this situation, instance domain labels should be used to define names for each instance name component. This allows .BR PMAPI (3) client tools to identify and refine value fetches to specific dimensions of interest. .PP For example, some of the Linux kernel cgroup (control group) metric instance domains are multi-dimensional. The instance domain represents individual values across both control groups and CPUs, making this a two-dimensional instance domain. The instance names associated with this cgroup metrics indom have been structured using the ``::'' delimiter to separate the two dimensions. The instance domain itself has been labeled accordingly, as follows. .P .ft CR .nf .B "$ pminfo \-\-desc \-\-fetch \-\-labels cgroup.cpuacct.usage_percpu" cgroup.cpuacct.usage_percpu .in +0.5i Data Type: 64-bit unsigned int InDom: 3.22 0xc00016 Semantics: counter Units: nanosec inst [0 or "/::cpu0"] value 713787 inst [1 or "/::cpu1"] value 353969 inst [2 or "/app::cpu0"] value 407816 inst [3 or "/app::cpu1"] value 202747 inst [0 or "/::cpu0"] labels {"device_type":"cpu","cgroup":"/","cpu":0} inst [1 or "/::cpu1"] labels {"device_type":"cpu","cgroup":"/","cpu":1} inst [2 or "/app::cpu0"] labels {"device_type":"cpu","cgroup":"/app","cpu":0} inst [3 or "/app::cpu1"] labels {"device_type":"cpu","cgroup":"/app","cpu":1} .in .fi .ft 1 .P .ft CR .nf .B "$ pminfo \-\-labels 3.22" InDom: 3.22 0xc00016 .in +0.5i labels {"device_type":"cpu"} .in .fi .ft 1 .P As shown above the individual instances inherit the labels from the instance domain, and the PMDA also applies additional per-instance labels describing individual cgroup and CPU names. When this model has been used by the PMDA, PMAPI clients are able to restrict their queries to the cgroup metric instances \- in the example, restricting to processor "cpu0" using the "cpu" label, perhaps, or to just the "/app" cgroup metrics using the "cgroup" label. .PP Furthermore, using this labeling scheme client tools can also correlate related instances across different instance domains. .P .ft CR .nf .B "$ pminfo \-\-desc \-\-fetch \-\-labels kernel.percpu.cpu.irq.soft" kernel.percpu.cpu.irq.soft .in +0.5i Data Type: 64-bit unsigned int InDom: 60.0 0xf000000 Semantics: counter Units: millisec inst [0 or "cpu0"] value 6770 inst [1 or "cpu1"] value 100 inst [0 or "cpu0"] labels {"device_type":"cpu"} inst [1 or "cpu1"] labels {"device_type":"cpu"} .in .fi .ft 1 .P .ft CR .nf .B "$ pminfo \-\-labels 60.0" InDom: 60.0 0xf000000 .in +0.5i labels {"device_type":"cpu"} .in .fi .ft 1 .P Although these two metrics have different instance domains (\c .I 60.0 and .I 3.22 respectively) and are sourced from different PMDAs, the "device_type" label identifies the common device to which these values relate. .SH CAVEAT The PMDA must be using .B PMDA_INTERFACE_2 or later, as specified in the call to .BR pmdaDSO (3) or .BR pmdaDaemon (3). If labeling of multi-dimensional instance names is performed, the PMDA must use .B PMDA_INTERFACE_7 or later. .PP Because of optional partial matching up to the first space in the instance name, the .B PMDA developer should ensure that if instance names are allowed to have spaces, the names are unique up to the first space. .SH DIAGNOSTICS If any errors occur during the execution of .BR pmdaInstance , the .I result structure is deallocated. If the instance domain .I indom is not supported by the PMDA, .B pmdaInstance will return .BR PM_ERR_INDOM . .PP If the .I inst or .I name does not correspond to any instances in the .I indom domain, .B pmdaInstance will return .BR PM_ERR_INST . .SH SEE ALSO .BR malloc (3), .BR PMAPI (3), .BR PMDA (3), .BR pmdaCacheStore (3), .BR pmdaLabel (3) and .BR pmGetInDom (3).