Created
November 15, 2012 01:39
-
-
Save brianjolly/4076102 to your computer and use it in GitHub Desktop.
memory logger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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