Delay calculation between two send/receive events

The Delay on the server should be calculated on the actual server,
if the duration between Receive EventID on Server A and Send EventID on Server b (the same server) is 24 minutes , it should shows it on that specific server (Server A) not the next server...However, if there is a delay between Send EventID of Server A and Receive EventID of Server B, then it is better to show it on Server B .

if [event_id] == "SEND" or [event_id] == "RECEIVE"
{
aggregate {
task_id => "%{message_id}"
code => "
require 'time'
if event.get('event_id') == 'RECEIVE'
if ! map['AT'] and ! map['BT']
map['AT'] = event.get('date_time')
event.set('delay_sec', Time.iso8601(map['AT']).to_f - Time.iso8601(event.get('date_time')).to_f)
else
if map['BT']
map['AT'] = event.get('date_time')
if Time.iso8601(map['AT']).to_f > Time.iso8601(map['BT']).to_f
event.set('delay_sec', Time.iso8601(map['AT']).to_f - Time.iso8601(map['BT']).to_f)
else
event.set('delay_sec', Time.iso8601(map['BT']).to_f - Time.iso8601(map['AT']).to_f)
end
else
map['tempAT'] = event.get('date_time')
if Time.iso8601(map['AT']).to_f > Time.iso8601(map['tempAT']).to_f
event.set('delay_sec', Time.iso8601(map['AT']).to_f - Time.iso8601(map['tempAT']).to_f)
map['AT'] = map['tempAT']
else
event.set('delay_sec', Time.iso8601(map['tempAT']).to_f - Time.iso8601(map['AT']).to_f)
map['AT'] = map['tempAT']
end
end
end
else
if ! map['BT'] and map['AT'] and event.get('event_id') == 'SEND'
map['BT'] = event.get('date_time')
if Time.iso8601(map['BT']).to_f > Time.iso8601(map['AT']).to_f
event.set('delay_sec', Time.iso8601(map['BT']).to_f - Time.iso8601(map['AT']).to_f)
else
event.set('delay_sec', Time.iso8601(map['AT']).to_f - Time.iso8601(map['BT']).to_f)
end
else
if map['AT']
map['BT'] = event.get('date_time')
if Time.iso8601(map['BT']).to_f > Time.iso8601(map['AT']).to_f
event.set('delay_sec', Time.iso8601(map['BT']).to_f - Time.iso8601(map['AT']).to_f)
else
event.set('delay_sec', Time.iso8601(map['AT']).to_f - Time.iso8601(map['BT']).to_f)
end
else
if !map['BT']
map['BT'] = event.get('date_time')
event.set('delay_sec', Time.iso8601(map['BT']).to_f - Time.iso8601(event.get('date_time')).to_f)
else
map['tempBT'] = event.get('date_time')
if Time.iso8601(map['BT']).to_f > Time.iso8601(map['tempBT']).to_f
event.set('delay_sec', Time.iso8601(map['BT']).to_f - Time.iso8601(map['tempBT']).to_f)
map['BT'] = map['tempBT']
else
event.set('delay_sec', Time.iso8601(map['tempBT']).to_f - Time.iso8601(map['BT']).to_f)
map['BT'] = map['tempBT']
end
end
end
end
end
"
} }

This is the code i was using for calculating difference . It works for the event set
send send receive receive(SSRR)
SRSR,RSRS,RRSS....
But not for the events like RRRS , SSSR .

IS there any way to have the delay calculation for any kind of events.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.