Hi -
As a part of the fetchgroup prototyping, this preparatory step is
ready for your look. It consists of a new PMAPI function
pmParseUnitsStr() which apprx. reverses pmUnitsStr(), so that pmUnits
may be specified in textual form. The patchset includes considerable
QA, and a bit of docs & demo code. I hope to exploit the new facility
in the fetchgroup stuff, pmwebd, python bindings, and other pcp
clients over time. There is a bonus man-page-typo fix too.
pcpfans.git fche/units-parse branch:
commit 62b0cdbd491ca31bd316307486d5bf32bdd09746
Author: Frank Ch. Eigler <fche@xxxxxxxxxx>
Date: Mon Dec 1 10:33:43 2014 -0500
demo for pmParseUnitsStr: procmemstat.c
This little demo program now takes an optional -u "STRING", which lets
a user rescale numbers to units other than 'kbytes'. The code now
also demonstrates nontrivial command line option handling patterns.
commit e25824a4cae7565935834d15f2bb8dd3a84f855f
Author: Frank Ch. Eigler <fche@xxxxxxxxxx>
Date: Sun Nov 30 21:21:13 2014 -0500
man page for new pmParseUnitsStr() function
commit 37c7f71f5583ca3c1adbcfffa7f74ea998297a0e
Author: Frank Ch. Eigler <fche@xxxxxxxxxx>
Date: Sun Nov 30 11:17:04 2014 -0500
qa for new pmParseUnitsStr() function
The tests include an exhaustive scan, round-tripping all valid
pmUnits() tuples through pmUnitsStr and back through pmParseUnitsStr.
("valid" excludes tuples with dim=0 but scale!=0. Also, due to a
parsing ambiguity with count scale-vs-dimensions, the round-tripping
check is slightly adjusted for them.)
The 670 test also exhaustively tests all new keywords, and all
forcesable code paths (as guided by gcov output). Floating point
calculations are all in double but rendered to default %g precision,
so should be accurate across platforms. (Tested on linux x86-64).
commit a3546d6bb56f5ec04b9d7801a0a078fcc3136e3f
Author: Frank Ch. Eigler <fche@xxxxxxxxxx>
Date: Sun Nov 30 11:05:04 2014 -0500
PMAPI extension: pmParseUnitsStr
We introduce a function that reverses pmUnitsStr (and then some), so
that users can specify desired metric unit/scale conversions in
somewhat free-form textual form. The API function looks like this:
int pmParseUnitsStr(const char *, pmUnits *, double *)
where the latter two arguments are the results. The first output is
what one would expect. The last parameter is a final arithmetic
multiplier, which may be simply 1.0 for a straight pmUnitsStr() format
text, or is the appropriate factor to compensate for a user asking for
conversion of a quantity to
"10 megabytes / 15 minutes"
commit 6ca0513d12033e549a8dd38ee1c71063babe0d69
Author: Frank Ch. Eigler <fche@xxxxxxxxxx>
Date: Sun Nov 30 10:56:21 2014 -0500
man pmlookupdesc.3: correct pmUnits documentation
The scaleSpace and scaleTime have been unsigned:4 bitfields since
commit 1c5cb90d01 back in 2009. Correcting the documentation to match.
|