Class: MailRelayLog

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/out_mailrelay.rb

Instance Method Summary collapse

Constructor Details

#initialize(from, to, msgid) ⇒ MailRelayLog

Returns a new instance of MailRelayLog.



154
155
156
157
158
159
160
161
# File 'lib/fluent/plugin/out_mailrelay.rb', line 154

def initialize(from, to, msgid)
  @relay = []
  @status = :init
  @from = from
  @to = to
  @msgid = msgid
  @delay_sum = 0
end

Instance Method Details

#merge(mta, relay_to, stat, dsn, delay, arrived_at_mta) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/fluent/plugin/out_mailrelay.rb', line 180

def merge(mta, relay_to, stat, dsn, delay, arrived_at_mta)
  @relay.push({
                'mta' => mta,
                'relay_to' => relay_to,
                'stat' => stat,
                'dsn' => dsn,
                'delay' => delay,
                'arrived_at_mta' => arrived_at_mta
              })
  dtime = Time.parse(delay)
  if stat =='sent' or stat == 'bounced'
      @delay_sum += (dtime.hour * 60 * 60) + (dtime.min * 60) + (dtime.sec)
  end
end

#recordObject



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/fluent/plugin/out_mailrelay.rb', line 163

def record
  return {
    'from' => @from,
    'to' => @to,
    'msgid' => @msgid,
    'delay_sec_sum' => @delay_sum,
    'relay' => @relay.each {|relay|
      {
        'relay' => relay['relay'],
        'stat' => relay['stat'],
        'dsn' => relay['dsn'],
        'delay' => relay['delay'],
      }
    }
  }
end