pcp
[Top] [All Lists]

Re: [pcp] Help with Python API

To: Rohan Arora <rarora2012@xxxxxxxxx>, pcp@xxxxxxxxxxx
Subject: Re: [pcp] Help with Python API
From: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Date: Wed, 08 Jul 2015 07:32:02 +1000
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <CANbxzdWWozajgdEWpzX-MbndB=4EeLM-8p3QZRytJHhw+rrakQ@xxxxxxxxxxxxxx>
References: <CANbxzdXmsRFyF_J_7c93uBuKWJHZikoRs6xmSPQC91rALtZbNA@xxxxxxxxxxxxxx> <CANbxzdXGZosHkKZXrcvJMoaPb=2YOY7_Rhw6cs2y-vp0Jhj8Vg@xxxxxxxxxxxxxx> <CANbxzdXVmBE1qRoHQQTy9VvbAt4rqppwEL-xizSUH7cKOswNzQ@xxxxxxxxxxxxxx> <CANbxzdV7Vndvczvo9OLgc8CpQ20wBK=YUD6v87ewVBa6yrTXKQ@xxxxxxxxxxxxxx> <CANbxzdXcqg=sRYa0JwETB+RHChw42uAeZE-n+bABUjV-FD9TDg@xxxxxxxxxxxxxx> <587447889.27462536.1435530714712.JavaMail.zimbra@xxxxxxxxxx> <CANbxzdX_4yDiOBqU954wjfbKOFOXnB8SJ_uiRsKEBdUk-hxF1w@xxxxxxxxxxxxxx> <CANbxzdUHygK=0NuO7L3pV+FERXa-LRL59=sumY5TznT0xzonxg@xxxxxxxxxxxxxx> <337532723.28653925.1435618315696.JavaMail.zimbra@xxxxxxxxxx> <CANbxzdVqbstVAue-GKW5moDkkKJKeg5pvtRdg1eHNET_7dHxeQ@xxxxxxxxxxxxxx> <559466FE.8090107@xxxxxxxxxxxxxxxx> <CANbxzdXqUj3i-MR2xF_NrTkYV11MMLBCX0B-+Btt45JQa77NQA@xxxxxxxxxxxxxx> <CANbxzdUn0Q8BkJUm-KAuTGxQAhQTz0CmSLdXEHKLT8UVKuBx4A@xxxxxxxxxxxxxx> <559AF629.5090609@xxxxxxxxxxxxxxxx> <CANbxzdWWozajgdEWpzX-MbndB=4EeLM-8p3QZRytJHhw+rrakQ@xxxxxxxxxxxxxx>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
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)

<Prev in Thread] Current Thread [Next in Thread>