[pve-devel] Problem with getting current running tasks from api

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Nov 30 14:53:22 CET 2015


On 11/30/2015 02:13 PM, Eduard Ahmatgareev wrote:
> thanks, I try got log from api, and have new problem, number of lines 
> from api got only 50.
> In api:
>
>
> {
>         "n" : 9,
>          "t" : "INFO: started backup task 
> '2f24d203-0be4-4684-82b9-e76e50c7db51'"
>       },
>      skip
>       {
>          "n" : 47,
>          "t" : "INFO: status: 37% (6988955648/18874368000), sparse 15% 
> (2853744640), duration 712, 9/9 MB/s"
>       },
>       {
>          "n" : 48,
>          "t" : "INFO: status: 38% (7176519680/18874368000), sparse 15% 
> (2859991040), duration 731, 9/9 MB/s"
>       },
>       {
>          "n" : 49,
>          "t" : "INFO: status: 39% (7363756032/18874368000), sparse 15% 
> (2864693248), duration 750, 9/9 MB/s"
>       },
>       {
>          "n" : 50,
>          "t" : "INFO: status: 40% (7551451136/18874368000), sparse 15% 
> (2873110528), duration 769, 9/9 MB/s"
>       }
>    ],
>    "total" : 79
>
>
> In gui at this moment:
> INFO: started backup task '2f24d203-0be4-4684-82b9-e76e50c7db51'
> skip
> INFO: status: 68% (12840861696/18874368000), sparse 23% (4449501184), 
> duration 1308, 9/1 MB/s
> INFO: status: 69% (13028032512/18874368000), sparse 24% (4636622848), 
> duration 1327, 9/0 MB/s
> INFO: status: 70% (13215137792/18874368000), sparse 25% (4774141952), 
> duration 1346, 9/2 MB/s
> INFO: status: 71% (13402308608/18874368000), sparse 26% (4939022336), 
> duration 1365, 9/1 MB/s
>
>
>
> api return only 50 lines, how can I get all lines ruuning task via api?
>
>

If you got the task UPID and use that to get the task status you 
normally get only 50 lines from the start of the task, you have two 
parameters to control that behaviour.
First  the 'limit' parameter, this denotes how many lines you get (and 
is default to 50)
Second the 'start' parameter which denotes from which point you get 
those 50 (or whatever value limit is set)
And note that you always get a value which says how many lines in the 
log are, this is called 'total' and in your example it's 79.

So for example you could use this api call from within the pvesh tool to 
get 80 lines starting from the 21st line (line 21 - 101):

 > get 
nodes/tre/tasks/UPID:tre:000011B9:0002F736:565C4399:qmmove:103:root at pam:/log 
--limit 80 --start 20

For your case you have a few possible solutions, or use a big enough 
limit number (for example 200) or make a "intelligent" algorithm which
queries only the newest lines with the start, limit parameters and the 
information from total.


regards,
Thomas




More information about the pve-devel mailing list