Query historical performance data

I think its better to use data over livestatus:
Please take a look at the manual:

https://checkmk.com/cms_livestatus_references.html

and

https://checkmk.com/cms_livestatus.html#Introduction