Hi Michele,
----- Original Message -----
> 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
Sounds right - the latter is the union of instances across the archive,
and thats not necessarily the same thing as the instances that will be
returned in an individual fetch pmResult at any one sample.
> wondering if there is a better way in general to achieve my goal here
> (retrieve all values/indoms for all metrics for all timestamps).
This class of problem sounds suited to solving using the same model
that pmlogsummary uses. It performs sequential result scanning via
pmFetchArchive(3), with a single pmSetMode at the start to set the
initial archive offset.
As it passes through the pmResult structures, it constructs a data
structure alot like the one you describe above (written in C though).
It uses a hash of all PMIDs (key == PMID, value == "struct aveData")
wherein each PMID hash value contains a list of all instances that
grows dynamically as the archive is scanned and new instances found.
Then at the end of scanning the archive, the now in-memory PMID hash
is walked, final calculations are done, and a report printed out. In
the end, it doesn't use pmGetInDom[Archive] at all, but instead uses
pmNameInDom(3).
> Maybe it makes sense to make pmExtractValue fail gracefully in any case?
I'm not sure it can be handled there; its passed a pointer deep into
the result structure and it doesn't have enough state to know whether
its being fed bogus data (i.e. it doesn't get to see the rest of the
pmResult, so its can't really take steps to defend itself).
cheers.
--
Nathan
|