Home » Configs » Twidge, twitter, mrtg and a little shell scripting to graph my workouts

Twidge, twitter, mrtg and a little shell scripting to graph my workouts

I decided to start working out.  Ok, you can get off the floor now. I am working out. I have a really cool, entry level elliptical, the Schwinn 420.

The only problem with the 420 is that it’s electronic console does NOT connect to the web. I decided to combat this by tweeting my workouts and having my linux box grab that data and dump it into some mrtg graphs.

First thing I did was setup a new twitter account (@johnsworkout) and follow it with my @beck_on_tech account.

Then I setup twidge, the command line twitter client, on my linux box using my @johnsworkout account.

When I workout I send a message to @johnsworkout with my weight, time on elliptical, distance and calories burned or wtdc as I remember it.

I run a script from cron every 2 hours.

# crontab -l
15 */2 * * *  /home/jbeck/scripts/workout-tweet.sh

# vi worktout-tweet.sh

TWEETDATA=`twidge lsrecent -su |grep -i johnsworkout`
if [ “$TWEETDATA” != “” ]; then
    echo $TWEETDATA > /tmp/workout.txt
    exit 1

This script looks at recent tweets from my @beck_on_tech account and filters for posts containing johnsworkout, then dumps that line to a file in /tmp. There’s also a tiny subroutine that exits if there is no data, so the file doesn’t get overwritten with emptyness.
Then MRTG handles the rest.

Below is the relevant snippets of my workout-mrtg.cfg file:

Options[weight]:gauge, nopercent, absolute, growright,noo
Target[weight]: `cat /tmp/workout.txt |awk ‘{print $3}’;cat /tmp/workout.txt |awk ‘{print $3}’`
MaxBytes[weight]: 300
Title[weight]: Weight

YLegend[weight]: Pounds

ShortLegend[weight]: lb

Options[time]:gauge, nopercent, absolute, growright,noo
Target[time]: `cat /tmp/workout.txt |awk ‘{print $4}’;cat /tmp/workout.txt |awk ‘{print $4}’`
MaxBytes[time]: 90
Title[time]: Time on elliptical
YLegend[time]: Minutes
ShortLegend[time]: min

Options[distance]:gauge, nopercent, absolute, growright,noo
Target[distance]: `cat /tmp/workout.txt |awk ‘{print $5}’;cat /tmp/workout.txt |awk ‘{print $5}’`
MaxBytes[distance]: 90
Title[distance]: Distance on elliptical

YLegend[distance]: Miles

ShortLegend[distance]: mi

Options[calories]:gauge, nopercent, absolute, growright,noo
Target[calories]: `cat /tmp/workout.txt |awk ‘{print $6}’;cat /tmp/workout.txt |awk ‘{print $6}’`
MaxBytes[calories]: 1000
Title[calories]: Calories burned

YLegend[calories]: Calories

ShortLegend[calories]: cal

As always, if you’ve got recommendations or a better way, I’m all ears

Was this helpful?
If you found my posts interesting, or I helped you figure something out, please consider tossing me a tiny gratuity for my time, research, to help offset the web hosting/development costs or to buy me a cup of coffee.

* This post may contain affiliate links. This means that I “might” receive a tiny amount of money, if you make a purchase using one of our links. It does not cost you anything extra, and helps us defray the costs of hosting and maintaining this site.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.