Skip to content

Instantly share code, notes, and snippets.

@brianjolly
Created November 15, 2012 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianjolly/4076102 to your computer and use it in GitHub Desktop.
Save brianjolly/4076102 to your computer and use it in GitHub Desktop.
memory logger
#!/usr/local/bin/ruby
log_file = "/var/log/mem_stats"
date = `date`.rstrip
mem_stats = `free -k`.split
output = ""
if Dir[log_file] == []
output << "date,\t total memory,\t used memory,\t free memory\n"
end
output << "#{date},\t #{mem_stats[7]}kb,\t #{mem_stats[8]}kb,\t #{mem_stats[9]}kb\n"
File.open(log_file, 'a') {|f| f.write(output) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment