Created
February 19, 2009 04:16
-
-
Save mmb/66728 to your computer and use it in GitHub Desktop.
sparkline showing the number of lines in a file
This file contains 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/bin/ruby | |
# sparkline showing the number of lines in a file | |
# run from cron at regular intervals | |
require 'rubygems' | |
require 'sparklines' | |
file_to_count = '/tmp/growing_file' | |
count_file = "#{file_to_count}.linecount" | |
graph = '/tmp/growing_file.png' | |
open(count_file, 'a') do |cf| | |
open(file_to_count) { |ftc| cf.write("#{ftc.readlines.size}\n") } | |
end | |
open(count_file) do |f| | |
data = f.readlines.map { |li| li.to_i } | |
Sparklines.plot_to_file(graph, data, :line_color => :red) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment