[Kamailio-Users] perl module, "pv_sprintf: Memory exhausted!"
Christian Koch
chri.koch.vier at googlemail.com
Mon May 18 15:24:44 CEST 2009
Hi all,
we're using kamailio 1.5.1 with modules htable and perl to generate
CDRs. Using htable we save some variables which are dumped to file using
the perl module at the end of the call.
We did a small stress test with 5 calls in parallel (each call about 20
seconds) and we got after about 6 hours the following error:
ERROR:core:pv_sprintf: pv_sprintf: Memory exhausted!
No CDRs were written anymore, the perl method was not called. Everything
else seems to run fine.
After stopping the stress test doing one simple call with a softphone
worked and a CDR had been written (without restarting kamailio!).
Perhaps the perl script is buggy?
Any ideas how to fix this are greatly appreciated. We don't think
extending the PKG_MEM_POOL_SIZE will solve the problem. This is
currently 4MB and should be enough for 5 concurrent calls!?!
Thanks,
Christian Koch
The perl script:
use OpenSER;
use OpenSER::Constants;
use IO::Socket;
sub write_cdr {
my $m = shift;
#my $v = $m->getVersion();
#my $t = $m->getType();
my $index = $m->pseudoVar("\$ci");
my $endTimeStamp = $m->pseudoVar("\$Ts");
my $startTimeStamp = $endTimeStamp -
$m->pseudoVar("\$DLG_lifetime");
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($startTimeStamp);
my $startTime = sprintf("%02d.%02d.%4d;%02d:%02d:%02d", $mday,
$mon+1, $year+1900, $hour, $min, $sec);
my $fileDate = sprintf("%02d%02d%02d", $mday, $mon+1, $year%100);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($endTimeStamp);
my $endTime = sprintf("%02d.%02d.%4d;%02d:%02d:%02d", $mday,
$mon+1, $year+1900, $hour, $min, $sec);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($m->pseudoVar("\$sht(a=>".$index."::invtrytime)"));
my $InvTryingTime = sprintf("%02d.%02d.%4d;%02d:%02d:%02d",
$mday, $mon+1, $year+1900, $hour, $min, $sec);
$ReplyReason=$m->pseudoVar("\$rr");
$ReplyReason=~ s/;/_/g;
$FromDisplayName =
$m->pseudoVar("\$sht(a=>".$index."::fromdplname)");
$FromDisplayName=~ s/;/_/g;
$ToUri = $m->pseudoVar("\$sht(a=>".$index."::touri)");
$ToUri=~s/;/_/g;
$FromUri = $m->pseudoVar("\$sht(a=>".$index."::fromuri)");
$FromUri=~s/;/_/g;
$UserAgent = $m->pseudoVar("\$sht(a=>".$index."::useragent)");
$UserAgent=~s/;/_/g;
my $CDR = $startTime.";"; # 1 + 2
$CDR .= $endTime.";"; # 3 + 4
$CDR .= $m->pseudoVar("\$DLG_lifetime").";"; # 5
$CDR .= $index.";"; #6 CallID
$CDR .= $m->pseudoVar("\$sht(a=>".$index."::srcip)").";"; #
source-IP of INVITE
$CDR .= $m->pseudoVar("\$si").";"; # source-IP of BYE/CANCEL
$CDR .= $FromDisplayName.";"; # from display-name INVITE
$CDR .= $InvTryingTime.";"; # Alerting time
$CDR .= ($startTimeStamp -
$m->pseudoVar("\$sht(a=>".$index."::invtrytime)")).";"; #Alerting period
$CDR .= $m->pseudoVar("\$DLG_count").";"; # current amount of calls
$CDR .= $ToUri.";"; # ToUri from Invite
$CDR .= $FromUri.";"; # FromUri from Invite
$CDR .= $UserAgent.";"; # UserAgent from Invite
$CDR .= $m->pseudoVar("\$rm").";"; # Method (INVITE,BYE,CANCEL)
$CDR .= $m->pseudoVar("\$rs").";"; # SIP reply status
$CDR .= $ReplyReason.";"; #SIP Reply reason
open(MYOUTFILE,
">>/home/sys/log/kamailio".$fileDate.".cdr.".$m->pseudoVar("\$pp"));
print MYOUTFILE $CDR."\n";
close(MYOUTFILE);
#delete(%sourceIp->{$index});
#delete(%fromDisplayName->{$index});
#delete(%InviteTryingTimestamp->{$index});
#delete(%ToUri->{$index});
#delete(%FromUri->{$index});
#delete(%UserAgent->{$index});
return 1;
}
1;
More information about the Users
mailing list