Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
# Create a new graph object. @received_packets_graph = RRDGraph.new("received_packages_total") # Generate a new RRD. (This will just be skipped if there is already a RRD with that name) @received_packets_graph.create_rrd "--start NOW DS:packets:COUNTER:600:U:U RRA:AVERAGE:0.5:1:288" @packets = Packetstatistic.find :all, :conditions => [ "timestamp > ?", @received_packets_graph.get_last_rrd_update ], :order => "timestamp ASC" @packets.each do |p| @received_packets_graph.insert "#{p.timestamp}:#{p.packets}" end @graph_name = @received_packets_graph.get_name_of_graph # Build some options for the graph image. yesterday = (Time.now - 86400).to_i lines = [ "DEF:packets=" + @received_packets_graph.get_path_of_rrd + ":packets:AVERAGE CDEF:real=packets,10,\* AREA:real#eb7f00:'Received packets'" ] title = "Receiver Hamburg: AIS Pakete/Minute - " + Time.now.to_s width = "725" height = "100" options = "-Y -X 1" colors = { "SHADEA" => "#555555", "SHADEB" => "#555555", "FONT" => "#FFFFFF", "BACK" => "#555555", "CANVAS" => "#555555", "GRID" => "#FFFFFF", "MGRID" => "#FFFFFF", "AXIS" => "#FFFFFF", "ARROW" => "#CCCCCC" } @received_packets_graph.update_image yesterday, Time.now.to_i, lines, title, width, height, colors, options # We can now display the graph's image with the show_graph helper.
This paste will be private.
From the Design Piracy series on my blog: