implement function to get memory usage
put in sampling loop
closing the file is necessary
add some env vars to control frequency and output
add more output and error checking, also some comments
Merge pull request #1 from whyrusleeping/master

Implemented a few things