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/4076096 to your computer and use it in GitHub Desktop.
Save brianjolly/4076096 to your computer and use it in GitHub Desktop.
cpu logger
#!/usr/local/bin/ruby
log_file = "/var/log/cpu_stats"
date = `date`.rstrip
cpu_stats = `uptime`.split
output = ""
if Dir[log_file] == []
output << "date,\t 1min,\t 5min,\t 15min\n"
end
output << "#{date},\t #{cpu_stats[9]}\t #{cpu_stats[10]}\t #{cpu_stats[11]}\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