WebTuna REST API – simple PHP example
The PHP code below is a simple example of how to query the WebTuna REST API to get metric data programmatically. In this example it looks at the last 300 seconds (5 mins) of data and requests /rest/v1/activity/summary where type=page as described here.
This returns JSON object with a single set of aggregated values for things like average response time and number of hits. The JSON response will look something like this.
[ { "unused" : "", "users" : 33, "hits" : 128, "sum_responsestart" : 54805.0, "sum_responsetime" : 497962.0, "avg_responsetime" : 3890, "min_responsetime" : 7, "max_responsetime" : 19989, "stddev_responsetime" : 4415, "sum_elements" : 6786.0, "min_elements" : 4, "max_elements" : 95, "sum_pagesize" : 0.0, "apdex" : 0.8700000047683716 } ]
In this example we are just choosing the avg_responsetime and printing it to the screen.
#!/usr/bin/php
More information on the use of the REST API can be found here http://docs.webtuna.com/display/WEBTUNA12/REST+API