On 08/07/15 00:35, Rohan Arora wrote:
Would it work for longer if I used a larger number, i.e. changing the 7
to an 8? ...
The man page example shows going to the end of an existing archive and
reading data backwards. There is no concept of "longer" here ... the
end of the archive is the end of the archive.
If the argument to pmSetMode is outside the bounds of the archive
(either before or, in your case, after) then the next pmFetch will
retrieve the first (or in your case, last) record in the archive.
If the archive was _growing_ and you wanted to repeatedly read the last
N records then you'd need something like
loop
pmGetArchiveEnd(&mytime)
pmSetMode(PM_MODE_BACK, mytime, 0)
loop N times
pmFetch(...)
sleep a while
Note that PM_MODE_BACK reads each physical record, and hence delta to
pmSetMode() is ignored. If you want the last N samples, say at 5 second
intervals then you probably want logical records with interpolation and
so should use
pmSetMode(PM_MODE_INTERP, mytime, -5000)
or
pmSetMode(PM_MODE_INTERP|PM_XTB_SET(PM_TIME_SEC), mytime, -5)
|