Hi Nathan and all,
I've attached a simple script that given an archive file, walks through
each metric and does a pmFetch()/pmSetMode(c_api.PM_MODE_FORW, start, 0)
loop. The goal of the function is to return data in the following form:
return = {}
return[metric1] = {'indom1': [(ts0, ts1, .., tsN), (v0, v1, .., vN)],
....
'indomN': [(ts0, ts1, .., tsN), (v0, v1, .., vN)]}
return[metric2] = {'indom1': [(ts0, ts1, .., tsX), (v0, v1, .., vX)],
....
'indomN': [(ts0, ts1, .., tsX), (v0, v1, .., vX)]}
When I run the script against this archive [1] I end up segfaulting:
Program received signal SIGSEGV, Segmentation fault.
0x0000003d2e4213d4 in pmExtractValue (valfmt=1, ival=<optimized out>, itype=3,
oval=0x75df40, otype=3) at units.c:794
794 if (ival->value.pval->vlen != PM_VAL_HDR_SIZE +
sizeof(__uint64_t) ||
The crash is due because pmExtractValue() segfaults when the indom list
changes. While I am fixing this by using using contents.get_numval()
to loop over all the values with pmExtractValue() [as opposed to using
the length of the instances returned by pmGetInDomArchive()], I was
wondering if there is a better way in general to achieve my goal here
(retrieve all values/indoms for all metrics for all timestamps).
Maybe it makes sense to make pmExtractValue fail gracefully in any case?
Cheers,
Michele
[1]
https://github.com/mbaldessari/pcpstats/blob/master/tests/pcp-files/server1.internal/20140510.08.47.0
--
Michele Baldessari <michele@xxxxxxxxxx>
C2A5 9DA3 9961 4FFB E01B D0BC DDD4 DCCB 7515 5C6D
fetch-indom2.py
Description: Text document
|