PMMERGELABELS - Online Linux Manual PageSection : 3
Updated : PCP
Source : Performance Co-Pilot
NAMEpmMergeLabels, pmMergeLabelSets − merge sets of performance metric labels
C SYNOPSIS#include <pcp/pmapi.h> int pmMergeLabels(char **sets, int nsets, char *buffer, int length); int pmMergeLabelSets(pmLabelSet **sets, int nsets, char *buffer, int length, int (*filter)(const pmLabel *, const char *, void *), void *arg); cc ... −lpcp
PYTHON SYNOPSISfrom pcp import pmapi
buffer = pmapi.pmContext().pmMergeLabels(sets)
buffer = pmapi.pmContext().pmMergeLabelSets(sets, filter)
DESCRIPTION
pmMergeLabels takes multiple ( nsets) performance metric label sets and merges them into a single result buffer of length bytes. Both the input sets and the result buffer are name:value pairs in the "JSONB" format described on pmLookupLabels(3). The pmMergeLabelSets interface serves the same purpose, but allows for indexed sets of labels to be merged. The format of the pmLabelSet data structure is described in detail in pmLookupLabels(3). Although names may repeat across the provided label sets, duplicate names are not allowed in the final buffer. Any label names occuring in more than one of the input label sets are reduced to one using the rules described in the "PRECEDENCE" section of pmLookupLabels. The position of each element in the sets array is significant in terms of the precedence rules − earlier positions are taken to be of lower precedence to later positions. Values must be primitive JSON entities (e.g. numbers, strings), one-dimensional arrays or maps (i.e. simple associative arrays). In addition to using indexed label sets the pmMergeLabelSets interface provides an optional filter callback function. If non-NULL, this function will be called for each label that would be added to the output buffer, allowing finer-grained control over the final merged set. This mechanism can be used to filter individual labels based on their name, value, and/or flags. If the filter function returns zero (false), then the given label is filtered from the resulting set. Any non-zero return value indicates that the label should be included in the buffer.
PYTHON EXAMPLEimport sys
import json
from pcp import pmapi
import cpmapi as c_api
def merge_callback(label, jsondata, data=None):
d = json.loads(jsondata)
labelsD.update(d)
return 0
ctx = pmapi.pmContext()
for metric in sys.argv[1:]:
pmid = ctx.pmLookupName(metric)[0]
lset = ctx.pmLookupLabels(pmid)
labelsD = {}
ctx.pmMergeLabelSets(lset, merge_callback)
print("== %s ===" % metric)
for n,v in labelsD.items():
print(" %s = %s" % (n,v))
ctx.pmFreeLabelSets(lset)
.ft 2
DIAGNOSTICS
On success, both pmMergeLabels and pmMergeLabelSets returns the number of bytes written into the supplied buffer. Failure to parse the input strings, failure to allocate memory, or any internal inconsistencies found will result in a negative return code.
SEE ALSOpminfo(1), PMAPI(3) and pmLookupLabels(3). 0
Johanes Gumabo
Data Size : 10,410 byte
man-p___mMergeLabels.3Build : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 3 / 170,960
Visitor ID : :
Visitor IP : 3.22.41.80 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (rof_ft|15|p___mMergeLabels.3|139|2|.ft 2
)