cat /var/sipenv-*/log/sip.log$2 | perl -e ' $sip="'$1'"; $answ1="SIP/2.0 100 Your Re-INVITE is received"; $answ2="SIP/2.0 488 Your Re-INVITE is ignored"; $n=1; while(<>) { #03 Feb 16:37:39.932/GLOBAL/ser[76763]: SENDING message to 83.77.6.211:5060: #03 Feb 16:37:40.035/GLOBAL/ser[76765]: RECEIVED message from 84.73.184.232:64309: if(/^\d\d ... ..:..:..\.\d\d\d.*: (SENDING message to|RECEIVED message from) .*:[\r\n]*$/) { $h1=$_; $nh1=$n; } #See http://www.ietf.org/rfc/rfc3261.txt [Page 253] if(/^(SIP\/2.0|INVITE|ACK|BYE|CANCEL|REGISTER|OPTIONS|INFO|NOTIFY|SUBSCRIBE) /) { $h2=$_; $nh2=$n; } if(/^Call-ID: /) { $id=$_; $nid=$n; if($h2=~/^(BYE|SIP\/2.0 \d\d\d Your Re-INVITE is) /) { if($nid-$nh1<=25 && $nid-$nh2<=25 && $nh2==$nh1+1) { $h2=~s/[\r\n]//g; $id=~s/[\r\n]//g; $id=~s/^Call-ID: //; # $h1=~/^(\d\d) (...) (..):(..):(..)\.(\d\d\d).*: (SENDING|RECEIVED) message (to|from) (.*):[\r\n]*$/; $dd=$1; $mmm=$2; $hh=$3; $mm=$4; $ss=$5; $ms=$6; $dir=($8 eq "from")?"R":"T"; $comm=$9; $time=$hh*3600+$mm*60+$ss+$ms/1000; # $hour=$mmm." ".$dd." ".$hh.":00:00"; if($h2 eq $answ1) { $call{$id}=$time; $nansw1{$hour}++; } else { if(defined $call{$id}) { if($h2 ne $answ2) { $nlost2{$hour}++; } delete $call{$id}; } } } else { #printf "\nERROR: headers of Call-ID are not found\n"; #exit; } } } $n++; } foreach $hour (keys %nansw1) { $nlost2{$hour}+=0; printf "%s, %s, %10d, %10d, %10.3f\r\n",$hour,$sip,$nansw1{$hour},$nlost2{$hour},$nlost2{$hour}/$nansw1{$hour}*100; } ' | sort