Trendrr

Dustin's Blog

3/27/08 12:38 PM

RESTful api usage - Continued

As Trendrr usage continues to rise, I have been monitoring the memory usage of JBoss (the app server that Trendrr is run on) closely.  I typically just ssh to the server and use top or ps to check the memory and cpu usage.  I realized that this would be a perfect way to use the Trendrr api.  It only took a slight modification of my original cpu usage script and we are good to go.


#do a sample every ten minutes
sampleSeconds=600
#your api key would go here
apiKey={removed}

echo $memUsage

while [ 1 ]
do
    memUsage=`ps aux | grep -m 1 program.name=run.sh | nawk '{print $4}'`
    apiUrl="http://www.trendrr.com/api/simple?key=$apiKey&value=$memUsage"
    wget $apiUrl
    # Need to delete the file that wget saved.
    rm simple?*
    # Sleep until we take the next sample
    sleep $sampleSeconds
done


You must be logged in to comment

Scratch Pad