rubyでsyslog監視1

rubyの勉強です。syslogを監視して、決めたキーワードの時にメッセージを送る。

[root@ns ruby_test 22:53:58]# cat read_msg.rb
pattern = Regexp.new("apache")
filename = "/var/log/messages"
file = open(filename)

while text = file.gets do
if pattern =~ text
print text
end
end
file.close

まずはキーワードを表示させる部分です。