1MMV_STATS_INIT(3) Library Functions Manual MMV_STATS_INIT(3)
2
3
4
6 mmv_stats_init, mmv_stats2_init - create and initialize Memory Mapped
7 Value file
8
10 #include <pcp/pmapi.h>
11 #include <pcp/mmv_stats.h>
12
13 void *mmv_stats_init(const char *name, int cluster,
14 mmv_stats_flags_t flags, const mmv_metric_t *stats, int nstats,
15 mmv_indom_t *indoms, int nindoms);
16 void *mmv_stats2_init(const char *name, int cluster,
17 mmv_stats_flags_t flags, const mmv_metric2_t *stats2,
18 int nstats2, mmv_indom2_t *indoms2, int nindoms2);
19
20 cc ... -lpcp_mmv -lpcp
21
23 mmv_stats_init creates and initializes the content of the MMV(5) file,
24 returning a handle that is used in subsequent MMV API calls.
25
26 mmv_stats2_init is equivalent to mmv_stats_init except that it provides
27 an option for longer metric and instance names.
28
29 mmv_stats_stop performs an orderly shutdown of the mapping handle re‐
30 turned by an earlier initialization call.
31
32 The file is created in the $PCP_TMP_DIR/mmv directory, name argument is
33 expected to be a basename of the file, not the full path. The metadata
34 content of the file does not change after the file has been created.
35
36 The old file is removed unconditionally unless there was an error.
37
38 cluster is the preferred MMV PMDA cluster ID to be used for the metrics
39 originating from this call to mmv_stats_init. The flags provide addi‐
40 tional control over the behaviour of the MMV PMDA - e.g. use of
41 MMV_FLAG_PROCESS will ensure values are only exported when the instru‐
42 mented application is running - this is verified on each request for
43 new values.
44
45 stats is the array of mmv_metric_t elements of length nstats. Each ele‐
46 ment of the array describes one PCP metric.
47
48 typedef struct {
49 char name[MMV_NAMEMAX]; /* Name of the metric */
50 __uint32_t item; /* Item component of PMID */
51 mmv_metric_type_t type; /* Type of the metric */
52 mmv_metric_sem_t semantics; /* Semantics of the metric */
53 pmUnits dimension; /* Dimensions (TIME,SPACE,etc) */
54 __uint32_t indom; /* Instance domain identifier */
55 char *shorttext; /* Optional, one-line help */
56 char *helptext; /* Optional, full help text */
57 } mmv_metric_t;
58
59 stats2 is the array of mmv_metric2_t elements of length nstats2. Each
60 element of the array describes one PCP metric, the only difference to
61 stats is the lifting of the restriction on name length (previously
62 MMV_NAMEMAX, which is 64 bytes).
63
64 typedef struct {
65 char *name; /* Name of the metric */
66 __uint32_t item; /* Item component of PMID */
67 mmv_metric_type_t type; /* Type of the metric */
68 mmv_metric_sem_t semantics; /* Semantics of the metric */
69 pmUnits dimension; /* Dimensions (TIME,SPACE,etc) */
70 __uint32_t indom; /* Instance domain identifier */
71 char *shorttext; /* Optional, one-line help */
72 char *helptext; /* Optional, full help text */
73 } mmv_metric_t;
74
75 If indom is not zero and not PM_INDOM_NULL, then the metric has multi‐
76 ple values and there must be a corresponding indom entry in the indom
77 list (uniquely identified by serial number).
78
79 The stats and stats2 arrays cannot contain any elements which have no
80 name - this is considered an error and no metrics will be exported in
81 this case.
82
83 indoms is the array of mmv_indom_t elements of length nindoms. Each el‐
84 ement of the array describes one PCP instance domain.
85
86 typedef struct {
87 __int32_t internal;
88 char external[MMV_NAMEMAX];
89 } mmv_instances_t;
90
91 typedef struct {
92 __uint32_t serial; /* Unique serial number */
93 __uint32_t count; /* Number of instances */
94 mmv_instances_t *instances; /* Internal/external IDs */
95 char *shorttext; /* Short help text */
96 char *helptext; /* Long help text */
97 } mmv_indom_t;
98
99 indoms2 is the array of mmv_indom2_t elements of length nindoms2. Each
100 element of the array describes one PCP instance domain, and the only
101 difference to indoms is the lifting of the restriction on external in‐
102 stance name lengths (previously MMV_NAMEMAX, which is 64 bytes).
103
104 typedef struct {
105 __int32_t internal;
106 char *external;
107 } mmv_instances2_t;
108
109 typedef struct {
110 __uint32_t serial; /* Unique serial number */
111 __uint32_t count; /* Number of instances */
112 mmv_instances2_t *instances; /* Internal/external IDs */
113 char *shorttext; /* Short help text */
114 char *helptext; /* Long help text */
115 } mmv_indom2_t;
116
118 These functions return the address of the memory mapped region on suc‐
119 cess. On failure, NULL is returned and errno is set to a value suit‐
120 able for decoding with strerror(3).
121
123 mmv_inc_value(3), mmv_lookup_value_desc(3), strerror(3) and mmv(5).
124
125
126
127Performance Co-Pilot MMV_STATS_INIT(3)