Skip to content

Instantly share code, notes, and snippets.

@dodizzle
Created October 11, 2011 23:03
Show Gist options
  • Select an option

  • Save dodizzle/1279740 to your computer and use it in GitHub Desktop.

Select an option

Save dodizzle/1279740 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
require 'gelf'
def send_gelf(ip,method,uri,code,size,referral)
line = ip + " " + method + " " + uri + " " + code + " " + size + " " + referral
n = GELF::Notifier.new("graylog2.posterdev.com", 12201)
n.notify!(:host => "prod-nginx", :level => 1, :short_message => line, :_ip => ip, :_method => method, :_uri => uri, :_code => code, :_size => size, :_referral => referral)
end
ARGF.each do |line|
x = line.split(/\s+/)
send_gelf(x[0],x[7],x[8],x[10],x[11],x[12])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment