数据分析脚本:
filepath="request.log.2017-12-01-15" File.open("#{filepath}").each do |line| begin File.open("#{filepath}").each do |line| if ! line.valid_encoding? s = line.encode("UTF-16be", :invalid=>:replace, :replace=>"?").encode('UTF-8') line = s.gsub(/dr/i,'med') end fields = line.split(" ") if fields.length <10 next end adx = fields[3] desc = fields[10] ext10 = fields[45] reqtype= ext10['reqtype'] puts "#{adx} #{desc} #{reqtype}" end rescue SystemCallError puts "warn:: #{filepath} not exits!!" end