(mt):Get range stats

  • This page was last modified on February 17, 2011, at 14:16.
The (mt) Community Wiki is a collaborative project. Any (mt) Media Temple customer or employee may contribute. Not all articles and/or content have been tested for accuracy by (mt) Media Temple.

For officially moderated and tested articles, be sure to visit our KnowledgeBase.

From (mt) Community Wiki

Contents

This method provides a way to retrieve the resource usage levels for a specific (mt) Media Temple server over a specific range of time.

Request Info

The following URL and HTTP method should be used:

HTTP Method URL
GET



https://api.mediatemple.net/api/v1/stats/{serviceId}

See also Get predefined range stats.


The following parameters must be provided in the URL:

Parameter Type Description
serviceIdintThe service id.

The following query parameters can be provided in the URL:

Parameter Type Description
startintThe beginning of the range in epoch seconds.
endintThe end of the range in epoch seconds.
resolutionintThe interval of data points in seconds to request. The closest actual data point collection interval will be returned, which may result in fewer or greater data points than expected. DEFAULT=15
precisionintThe numeric precision to use in returned data. Digits to the right of the decimal. DEFAULT=2

Response Info

The response will return an HTTP status code to indicate the general category of success or failure to the client. More specific error codes and messages will be contained in the response data itself, if provided. For more information on response codes and parsing response data, see Parsing API responses.

Sample Request

To get the stats for service 1000 over a 60 second interval beginning at 1284439817 and ending 1284439877 in JSON format, do the following:

curl -D log.txt -s -X "GET" "https://api.mediatemple.net/api/v1/stats/555.json?start=1284439817&end=1284439877&apikey=a5h34sf62..."

Sample Response

Here is an example of the returned result:

{
"statsList" : {
"timeStamp" : 1284439830,
"resolution" : 15,
"serviceId" : 555,
"stats" : [ {
"timeStamp" : 1284439830,
"cpu" : 47.43482,
"memory" : 40.658417,
"load1Min" : 13.552806,
"load5Min" : 20.329208,
"load15Min" : 27.105612,
"processes" : 39,
"diskSpace" : 33.882015,
"kbytesIn" : 54.211224,
"kbytesOut" : 60.987625,
"packetsIn" : 67.76403,
"packetsOut" : 74.540436,
"state" : 1
}, {
"timeStamp" : 1284439845,
"cpu" : 22.831272,
"memory" : 19.56966,
"load1Min" : 6.52322,
"load5Min" : 9.784831,
"load15Min" : 13.046441,
"processes" : 39,
"diskSpace" : 16.30805,
"kbytesIn" : 26.092882,
"kbytesOut" : 29.354492,
"packetsIn" : 32.6161,
"packetsOut" : 35.877712,
"state" : 1
}, {
"timeStamp" : 1284439860,
"cpu" : 63.22567,
"memory" : 54.19343,
"load1Min" : 18.064478,
"load5Min" : 27.096716,
"load15Min" : 36.128956,
"processes" : 6,
"diskSpace" : 45.161194,
"kbytesIn" : 72.25791,
"kbytesOut" : 81.290146,
"packetsIn" : 90.32239,
"packetsOut" : 99.35462,
"state" : 1
}, {
"timeStamp" : 1284439875,
"cpu" : 43.377197,
"memory" : 37.180454,
"load1Min" : 12.393485,
"load5Min" : 18.590227,
"load15Min" : 24.786968,
"processes" : 4,
"diskSpace" : 30.983711,
"kbytesIn" : 49.57394,
"kbytesOut" : 55.77068,
"packetsIn" : 61.967422,
"packetsOut" : 68.16417,
"state" : 1
} ]
}
}

There are 4 entries (1284439830, 1284439845, 1284439860, 1284439875) for a 60 second window with a default interval of 15 seconds. The time range we asked for was 1284439817 through 1284439877 and there are exactly 4 data points recorded in that range, inclusive of the start and end range times.

If the range was adjusted to 1284439815 through 1284439875, a 60 second window with a default interval of 15 seconds, 5 data points would be returned. Since data points are collected every 15 seconds from the top of the minute and the range is inclusive, we get an extra data point for time 1284439815 in addition to the data points above.

Sample Request

To get the stats for service 1000 at exactly 1284439830 in JSON format, do the following:

curl -D log.txt -s -X "GET" --user "user:password" "http://api.mediatemple.net/api/v1/stats/555.json?start=1284439830&end=1284439830"

Sample Response 2

Here is an example of the returned result:

{
"statsList" : {
"timeStamp" : 1284439830,
"resolution" : 15,
"serviceId" : 555,
"stats" : [ {
"timeStamp" : 1284439830,
"cpu" : 47.43482,
"memory" : 40.658417,
"load1Min" : 13.552806,
"load5Min" : 20.329208,
"load15Min" : 27.105612,
"processes" : 39,
"diskSpace" : 33.882015,
"kbytesIn" : 54.211224,
"kbytesOut" : 60.987625,
"packetsIn" : 67.76403,
"packetsOut" : 74.540436,
"state" : 1
}]
}
}

If you specify both the start and end ranges as a single time (e.g. 1284439830), you would get back the single data point that falls exactly at that time. This is only true if the specified time matches an existing data point.

Response Fields

The fields in the result represent the following:

Field Description
timeStampThe time these stats were recorded.
cpuThe percentage of CPU being consumed.
memoryThe percentage of memory currently allocated.
load1MinThe system load average for the past minute.
load5MinThe system load average for the past 5 minutes.
load15MinThe system load average for the past 15 minutes.
processesThe number of processes currently running.
diskSpaceThe percentage of disk space currently used.
kbytesInThe kilobytes in per second.
kbytesOutThe kilobytes out per second.
packetsInThe packets in per second.
packetsOutThe packets our per second.
stateThe server state (0=off, 1=running).