header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

We have a new sponsor!  Introducting Pragma Systems.  See the home page for details.

Timespan SMTP Received headers
Last Post 16 Feb 2009 07:43 PM by mjolnir. 0 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
mjolnirUser is Offline
New Member
New Member
Posts:19
Avatar

--
16 Feb 2009 07:43 PM  
Reads an SMTP header, and shows the MTA's it passed through, in chronological order, and calculates and displays the latency between each MTA.

$hdr_txt = gc ./hdr.txt
$rec_hdr_regex = [regex]"^Received\:\sfrom\s+(.+)\s+(.+)\s+by(.+)\s+(.+)\swith\s+(.+)\;\s+(.+\d{4})"

$from_hdr = $hdr_txt | select-string "^From\:\s.+$"
$rec_block = $hdr_txt[0..$($from_hdr.linenumber -2)]
$rec_lines = $rec_block | select-string "^Received\:\sfrom"
$sent_hdr = $hdr_txt | select-string "^Date\:\s.+$"
$sent_hdr.line -match "^Date\:\s(.+)$" > $nul
$sent_ts = [datetime]$matches[1]

foreach ($rec_line in $rec_lines[1..$($rec_lines.count -1)]){
$rec_block[$rec_line.linenumber -1] = "~" + $rec_line.line
}

$rec_hdrs = $([string]$rec_block).split("~")

Write-host "`nMessage sent $($sent_ts)`n"
$i = $rec_hdrs.count -1
$last_ts = $sent_ts

while ($i -ge 0) {
$rec_hdrs[$i] -match $rec_hdr_regex >$nul
$rec_ts = [datetime]$matches[6]
$latency = $rec_ts - $last_ts
$last_ts = $rec_ts
write-host "latency is $($latency.totalseconds) seconds`n"
write-host $matches[1] $matches[2]
 $i--
}

Write-host "`nMessage received $($last_ts)"
write-host "Total time is $($($last_ts - $sent_ts).seconds) seconds.`n"
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 footer
footer