if you use android their is a really nice data tracking app i use called traffic counter extended. It keeps up with your cell data use, wifi use, call times and sms count. It also has 2 widgets one is 2x2 the other is 1x1. I used it a lot when i was having to tether a lot.
Not sure why your code is not working though. i dont use them so i cant offer any help with that.