56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/fluent/plugin/in_sendmail.rb', line 56
def receive_lines(lines)
es = Fluent::MultiEventStream.new
lines.each {|line|
begin
line.chomp!
record = parse_line(line)
if record.nil?
next
end
type = record["type"]
mta = record["mta"]
qid = record["qid"]
time = record["time"]
deliveryid = mta + qid
type = record["type"]
record.delete("type")
case type
when "from"
if @delivers.has_key?(deliveryid)
$log.warn "duplicate sender line found. " + line.dump
else
@delivers[deliveryid] = SendmailLog.new(time, record)
end
when "to"
if @delivers.has_key?(deliveryid)
case record["status_canonical"]
when "sent", "sent_local", "bounced"
sent(es, deliveryid, time, record)
when "deferred"
queued(es, deliveryid, time, record)
when "other"
$log.warn "cannot find this kind of delivery status: " + line.dump
end
else
end
end
rescue
$log.warn line.dump, :error=>$!.to_s
raise
end
}
unless es.empty?
begin
Fluent::Engine.emit_stream(@tag, es)
rescue
raise
end
end
end
|