Wednesday, February 12, 2014

Log URL performance in xively

If you need to create a report on performance of your web site, you can use some free services for that purpose. By example, you can use xively service.

I have created a simple script which can be used to measure response time for a given URL and then submit that time to the xively feed, so later you can see that in nice graphical format. Here is the code:

#!/bin/bash
# This script executes query and captures response time 

# Results are captured in xively feed

submit_request() {
    local $url=$1
    local channelname=$2
    TTT=`curl -s -w "%{time_total}\n" -o /dev/null "$url"`;
    curl --request PUT -o /dev/null --data '{"current_value":"'$TTT'"}' --header "X-ApiKey:$HEADER" $FEED/$channelname

    echo "Result=$TTT."
    return $?
}


HEADER="9KD27abwecBXIVELYHEADER"
FEED="https://api.xively.com/v2/feeds/XYZ/datastreams"
URLPATH="http://websiteURL"




submit_request "$url" "channelname"

No comments:

Post a Comment