Sha256: 38f3629d7ed4817f9ed29335ff97e8a53899d0f436d340a0ef623ced7b264500
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
#!/usr/bin/env ruby require 'optparse' options = {} OptionParser.new do |opts| opts.banner = "Usage: mrtg2xy [options] file" opts.on("-v", "--[no-]verbose", "Run verbosely") do |v| options[:verbose] = v end opts.on("-t", "--time-frame [day|week|month|year]", "Time Frame") do |tf| options[:timeframe] = tf end opts.on("-f", "--factor [factor]", "Factor") do |factor| options[:factor] = factor end end.parse! # p options # p ARGV # puts "Aliases:" # puts zway.aliases file = ARGV.last if file.nil? puts "No file specified." exit end # puts options mrtg_data = File.open( file ).read lines = mrtg_data.split( "\n" ) lines.shift #Get rid of the useless first line if options[:timeframe] == "day" data = lines[0..604] elsif options[:timeframe] == "week" data = lines[605..1204] elsif options[:timeframe] == "month" data = lines[1205..1804] elsif options[:timeframe] == "year" data = lines[1804..2535] end data.each do |line| vals = line.split( " " ) x = vals[0].to_f y = vals[1].to_f unless options[:factor].nil? y = y * options[:factor].to_f end puts "#{x} #{y}" end # day: 0, 604 # week: 605, 1204 # month: 1205, 1804 # year: 1804, 2535 # ts = 0 # mrtg_data.split( "\n" ).each_with_index do |line, index| # new_ts = line.split( " " ).first.to_i # puts "#{index} : #{ts - new_ts}" # ts = new_ts # end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mrtg2xy-1.0.3 | exe/mrtg2xy |