Skip to content

Instantly share code, notes, and snippets.

@dowens
Created June 2, 2010 20:15
Show Gist options
  • Save dowens/422931 to your computer and use it in GitHub Desktop.
Save dowens/422931 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Rulog - Ruby Syslog Server
# Captures syslog events and spits them out to Growl.app
# Useful for on-spot debugging of a device with remote syslog support
# Blocking IO
# Run as root
require 'socket'
require 'rubygems'
require 'ruby-growl'
port = 514
ip = "0.0.0.0"
BasicSocket.do_not_reverse_lookup = true
g = Growl.new "127.0.0.1", "ruby-growl",
["ruby-growl Notification"], nil, "password"
# Create socket and bind to address
server = UDPSocket.new
server.bind(ip, port)
puts "Listening on: #{ip}:#{port}"
loop do
data, addr = server.recvfrom(1024)
g.notify "ruby-growl Notification", "Ruby-growl", "#{data}"
puts "From addr: #{addr.join(',')} msg: #{data}"
end
# Never reached
server.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment