1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*
* bigun PMDA ... one big value for QA
*
* Copyright (c) 2011 Ken McDonell. All Rights Reserved.
*
*/
#include <pcp/pmapi.h>
#include <pcp/impl.h>
#include <pcp/pmda.h>
static pmdaMetric metrics[] = {
{ NULL,
{ PMDA_PMID(0,0), PM_TYPE_AGGREGATE_STATIC, PM_INDOM_NULL, PM_SEM_DISCRETE,
PMDA_PMUNITS(0, 0, 0, 0, 0, 0) } }
};
#define MYSIZE (1024*1024)
static pmValueBlock *vbp;
/*
* callback provided to pmdaFetch
*/
static int
bigun_fetchCallBack(pmdaMetric *mdesc, unsigned int inst, pmAtomValue *atom)
{
if (pmid_cluster(mdesc->m_desc.pmid) != 0 ||
pmid_item(mdesc->m_desc.pmid) != 0)
return PM_ERR_PMID;
if (inst != PM_IN_NULL)
return PM_ERR_INST;
atom->vbp = vbp;
return 1;
}
/* Initialise the DSO agent */
void
bigun_init(pmdaInterface *dp)
{
int i;
int sep = __pmPathSeparator();
char helppath[MAXPATHLEN];
/*
* Note: helpfile is only available if the PMDA has been installed
* from $PCP_VAR_DIR/testsuite/pmdas/bigun ... when the PMDA install
* comes from QA run from some other directory, the helpfile may not
* be found ... fortunately nothing in QA depends on the helpfile
* being available for the bigun PMDA.
*/
snprintf(helppath, sizeof(helppath),
"%s%c" "testsuite" "%c" "pmdas" "%c" "bigun" "%c" "help",
pmGetConfig("PCP_VAR_DIR"), sep, sep, sep, sep);
pmdaDSO(dp, PMDA_INTERFACE_4, "bigun DSO", helppath);
if (dp->status != 0)
return;
pmdaSetFetchCallBack(dp, bigun_fetchCallBack);
pmdaInit(dp, NULL, 0, metrics, sizeof(metrics)/sizeof(metrics[0]));
vbp = (pmValueBlock *)malloc(PM_VAL_HDR_SIZE+MYSIZE);
if (vbp == NULL) {
fprintf(stderr, "bigun_init: malloc failed: %s\n", pmErrStr(-errno));
exit(1);
}
vbp->vtype = PM_TYPE_AGGREGATE_STATIC;
vbp->vlen = PM_VAL_HDR_SIZE+MYSIZE;
for (i = 0; i < MYSIZE; i += sizeof(int))
memcpy((void *)&vbp->vbuf[i], (void *)&i, sizeof(int));
}
|