Page tree
Skip to end of metadata
Go to start of metadata

To view CPU usage statistics of a virtual server, run:

GET  /virtual_machines/:virtual_machine_id/cpu_usage.xml
GET  /virtual_machines/:virtual_machine_id/cpu_usage.json


Define a shorter period by setting Start and End time in the API call:
GET /virtual_machines/:virtual_machine_id/vm_stats.xml?period[startdate]=YYYY-MM-DD+hh:mm:ss&period[enddate]=YYYY-MM-DD+hh:mm:ss&period[use_local_time]=1
GET /virtual_machines/:virtual_machine_id/vm_stats.json?period[startdate]=YYYY-MM-DD+hh:mm:ss&period[enddate]=YYYY-MM-DD+hh:mm:ss&period[use_local_time]=1

XML Request example:

curl -i GET -u user:userpass --url http://onapp.test/virtual_machines/:virtual_machine_id/cpu_usage.xml

XML Request example: 

curl -i GET -u user:userpass --url http://onapp.test/virtual_machines/:virtual_machine_id/cpu_usage.json

Where you have to specify the virtual server ID.

XML Output example

<?xml version="1.0" encoding="UTF-8"?>
<cpu_hourly_stats type="array">
    <cpu_time type="integer">18</cpu_time>
    <created_at type="datetime">2015-01-06T10:00:18Z</created_at>
    <id type="integer">935848</id>
    <stat_time type="datetime">2015-01-06T10:00:00Z</stat_time>
    <updated_at type="datetime">2015-01-06T10:00:18Z</updated_at>
    <user_id type="integer">1</user_id>
    <virtual_machine_id type="integer">1701</virtual_machine_id>


cpu_time -  use the following formula to convert CPU data received in the API output:

CPU = cpu_time /10/ 3600

Where cpu_time is data from API output.

For example:  cpu_time  = 2330, then:  2330/10/3600=0.06 (6%).

We use "cpu_time" * 10 to correct store fractional values.

created_at - the timestamp in DB when this record was created

id -  the statistics ID

stat_time - the particular hour for which these statistics were generated

updated_at - the time stamp in DB when this record was updated

user_id - the ID of the VS owner

virtual_machine_id - ID of the VS


#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
  • No labels