Commit 7add1045 authored by Olav Kvittem's avatar Olav Kvittem

bug fixing, flexibility in configuration of scenarios


git-svn-id: file:///home/svn/sipshaman/trunk@17 9383e1fa-a92b-456e-b4ec-45f0d4f7abeb
parent f8bde81d
......@@ -7,6 +7,7 @@ use XML::Simple;
use Data::Dumper;
use Socket;
use IO::Select;
use DateTime;
require "newgetopt.pl";
@opts=( 'f', 'die=s', 'timeout=s', 'bb=s', 'remote', 'debug', 'dump', 'v', 'h', 'help' );
......@@ -79,6 +80,52 @@ foreach $tasklog(@ARGV){
}
$machine=~s/\./,/g;
#
# checking call success
my $log='';
my $stime=$time; # default time from tasklog, but prefer from call-log csv
my $sdate=$date;
if ($opt_remote){
if ($n > 0){
$status=100;
$message="Call received successfully";
} else {
$status=0;
$message="No calls received\n";
}
&bb_report("C-$function", $machine, &bb_color($call_limit,$bb_color,$status), $message);
} else {
open (CSV, "/usr/bin/sipp-print -f 'CurrentTime|ElapsedTime(C)|OutgoingCall(C)|SuccessfulCall(C)|FailedCall(C)|Retransmissions(C)|ResponseTime1(C)|ResponseTime1StDev(C)|CallLength(C)|CallLengthStDev(C)' *${pid}_.csv|");
while(<CSV>){
$log.=$_;
if (/^[\d-]+[\d:]+\s+\d+/){ # date time unixt
($sdate,$etime,$unixtime,$elapsed, $callsout, $success, $failed, $rest)=split;
if ($success>0){
my ($hh, $ss)=split(/:/, $elapsed);
my $esec=3600*$hh+60*$mm+$ss;
my $dt=DateTime->from_epoch(epoch => $unixtime);
$dt->subtract(seconds => $esec);
$stime=$dt->hms;
$sdate=$dt->ymd;
$calls=$success+$failed;
$status=100*$success/$calls; # success rate in %
$message=sprintf "$sdate $stime - %d percent success (%d/%d)\n%s",$status,$success,$calls,$log;
} else {
$status=0;
$message="No successfull calls :\n $log";
}
&bb_report("C-$function", $machine, &bb_color($call_limit,$bb_color,$status), $message);
}
}
close CSV;
}
#
# checking call rtp quality
my $mossum=0, $n=0;
my @f=`ls rtp_*${pid}_*.pcap* 2>/dev/null`;
my $qstream_rep='';
......@@ -86,7 +133,7 @@ foreach $tasklog(@ARGV){
if($#f >=0){ # yess some files
chomp(@f);
my $rtp_files= join(' ', @f);
$cmd="/usr/bin/qstream -v -rtp -rtt '$rtt' -id $src -xml $tmp $rtp_files";
$cmd="/usr/bin/qstream -v -name '${id}:$function' -rtp -rtt '$rtt' -id $src -xml $tmp $rtp_files";
my $T=`date +%T`; chomp($T);
$qstream_rep=sprintf "%s $pid $port $mport $service@$server $function $machine ping",$T;
open QSTREAM, "$cmd|";
......@@ -114,44 +161,12 @@ foreach $tasklog(@ARGV){
if ($n >0){
my $mean_mos=$mossum/$n;
&bb_report("M-$function", $machine, &bb_color($mos_limit,$bb_color,$min_mos),
sprintf "$date $time - %.1f \n%s\n",$min_mos,$qstream_rep);
sprintf "$sdate $stime - %.1f \n%s\n",$min_mos,$qstream_rep);
} else {
&bb_report("M-$function", $machine, &bb_color($mos_limit,$bb_color,0), "No RTP files");
}
my $log='';
# checking call success
if ($opt_remote){
if ($n > 0){
$status=100;
$message="Call received successfully";
} else {
$status=0;
$message="No calls received\n";
}
&bb_report("C-$function", $machine, &bb_color($call_limit,$bb_color,$status), $message);
} else {
open (CSV, "/usr/bin/sipp-print -f 'OutgoingCall(C)|SuccessfulCall(C)|FailedCall(C)|Retransmissions(C)|ResponseTime1(C)|ResponseTime1StDev(C)|CallLength(C)|CallLengthStDev(C)' *${pid}_.csv|");
while(<CSV>){
$log.=$_;
if (/^\s+\d+\s+\d+\s+/){
my ($callsout, $success, $failed, $rest)=split;
if ($success>0){
$calls=$success+$failed;
$status=100*$success/$calls; # success rate in %
$message=sprintf "$date $time - %d percent success (%d/%d)\n%s",$status,$success,$calls,$log;
} else {
$status=0;
$message="No successfull calls :\n $log";
}
&bb_report("C-$function", $machine, &bb_color($call_limit,$bb_color,$status), $message);
}
}
close CSV;
}
}
......@@ -162,7 +177,7 @@ foreach $tasklog(@ARGV){
unlink ($tmp);
unlink $tmp;
exit(0);
sub bb_color {
......
......@@ -5,12 +5,12 @@
# and exits withinafter an hour
interf=`/sbin/ifconfig eth0| perl -ne 'print $1 if /inet addr:(\d+\.\d+\.\d+\.\d+)/'`
proxy=$interf
iaddr=`/sbin/ifconfig eth0| perl -ne 'print $1 if /inet addr:(\d+\.\d+\.\d+\.\d+)/'`
proxy=$iaddr
if test .$1 = .-h; then
echo Usage__: $0 "[-cf] <config-file> [proxy [announed-interface]]"
echo Default: $0 $proxy $interf
echo Usage__: $0 "[-cf <config-file>] [proxy [announed-interface]]"
echo Default: $0 $proxy $iaddr
exit 1
fi
......@@ -26,12 +26,12 @@ if test $# -gt 0; then
shift
fi
if test $# -gt 0; then
interf=$1
iaddr=$1
shift
fi
while test 1=1 ; do
ps axw | grep -q "$BIN/[s]ipp $proxy" -
ps -ef | egrep -q "$BIN/[s]ipp .*-p $SIP_PORT" -
if test $? = 1 ; then # not found
y=`date +%Y`
......@@ -52,12 +52,13 @@ fi
cd $hdir
port=$SIP_PORT
mport=16388
mport=$MEDIA_PORT
idle_time=$((60-`date +%M`-1)) # end just before every hour if now response
$BIN/sipp $proxy:$PROXY_PORT -s sipp -i $interf -p $port -mp $mport -l 1 -m 1 -sf $CONF/sipp-responder.xml -trace_stat -trace_logs -trace_err -trace_msg -rp 600000 -r 1 -bg -nofork 2>> sipp.err >> sipp.log &
$BIN/sipp $proxy:$SIP_PROXY_PORT -s sipp -i $iaddr -p $port -mp $mport -recv_timeout $idle_time -l 1 -m 1 -sf $CONF/$RESPONDER_SCENARIO -trace_stat -trace_logs -trace_err -trace_msg -rp 600000 -r 1 -bg -nofork 2>> sipp.err >> sipp.log &
pid=$!
echo $y-$m-$d `date +%T` $pid $port $mport sipp@$interf $REPORT_TAG `hostname --fqdn` 0 >> task.log
echo $y-$m-$d `date +%T` $pid $port $mport sipp@$iaddr $REPORT_TAG `hostname --fqdn` 0 >> task.log
t2=`date +%s`
dt=$(($t2-$t1))
if test $dt -lt 5; then #
......
#!/bin/sh
# start responder if not running
. /etc/sipshaman/sipshaman.cf
#!/bin/bash
# start sipp-responder if not running
ps axw | grep -q "sh .*/usr/bin/sipp-responde[r]" -
if test $? -eq 1; then # not found and ok to run
$BIN/sipp-responder&
# usage $0 config-file...
if test $# -le 0; then
set /etc/sipshaman/sipshaman.cf
fi
for cf in $*; do
ps axw | grep -q "sh .*/usr/bin/sipp-responde[r].*$cf" -
if test $? -eq 1; then # not found and ok to run
$BIN/sipp-responder -cf $cf&
fi
done
\ No newline at end of file
#!/bin/bash
# start a test series of sipp-calls with specs from a config file
# log data about the tests so that files can be combined to edible reports
# by qstream-sipp-check
if test .$1 = .-cf ; then
source $2
shift;shift
......@@ -22,7 +26,7 @@ test -d $ddir || mkdir $ddir
hdir=$ddir/$h
test -d $hdir || mkdir $hdir
cd $hdir
cd $hdir || exit -1 # better not to do anything
port=$SIP_PORT # sip service port start
......@@ -44,7 +48,7 @@ while read server service outproxy function machine calls; do
echo $server | egrep -q '^\s*#'
if test $? = 1 ; then # no comment
/usr/bin/sipp $server -s $service -i $addr -sf $CONF/sipp-client-media.xml -p $port -mp $mport -m $calls -rp 200000 -l 1 -trace_stat -fd 99999 -trace_logs -trace_msg -trace_err -bg -nofork -rsa $outproxy 2>> sipp.err >> sipp.log &
/usr/bin/sipp $server -s $service -i $addr -sf $CONF/$CLIENT_SCENARIO -p $port -mp $mport -m $calls -rp 200000 -l 1 -trace_stat -fd 99999 -trace_logs -trace_msg -trace_err -bg -nofork -rsa $outproxy 2>> sipp.err >> sipp.log &
pid=$!
adr=$service@$server
server_ip=`echo $server| sed -e 's/:.*//'`
......
# sipshaman example file to put i /etc/cron.d
#
# register the sipp user
# 1 * * * * root sipp-register
#
# run sipp tests
# */10 * * * * root sipp-test < /etc/sipshaman/poll.cf
#
# start a sipp responder every hour
# */1 * * * * root sipp-start-responder > /dev/null
# 59 * * * * root sleep 50;killall sipp-responder bin/sipp
# 0 * * * * root sipp-bb
#
# report to big brother
# 1 * * * * root sipp-bb
#
# clean up old pcap files
# 3 3 * * * root find /var/log/sipshaman/ -name rtp_\*.pcap -mtime +7 -delete
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE scenario SYSTEM "sipp.dtd">
<!-- This program is free software; you can redistribute it and/or -->
<!-- modify it under the terms of the GNU General Public License as -->
<!-- published by the Free Software Foundation; either version 2 of the -->
<!-- License, or (at your option) any later version. -->
<!-- -->
<!-- This program is distributed in the hope that it will be useful, -->
<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
<!-- GNU General Public License for more details. -->
<!-- -->
<!-- You should have received a copy of the GNU General Public License -->
<!-- along with this program; if not, write to the -->
<!-- Free Software Foundation, Inc., -->
<!-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -->
<!-- -->
<!-- Sipp default 'uas' scenario. -->
<!-- -->
<scenario name="Basic UAS responder">
<!-- By adding rrs="true" (Record Route Sets), the route sets -->
<!-- are saved and used for following messages sent. Useful to test -->
<!-- against stateful SIP proxies/B2BUAs. -->
<nop> <action>
<assignstr assign_to="my_media_port" value="[auto_media_port]"/>
</action> </nop>
<recv request="INVITE" crlf="true" rrs="true">
<action>
<ereg regexp="c=IN IP4 (([0-9]{1,3}\.){3}[0-9]{1,3})" search_in="body" check_it="true" assign_to="re,sdp_ip" />
</action>
</recv>
<Reference variables="re" />
<!-- The '[last_*]' keyword is replaced automatically by the -->
<!-- specified header if it was present in the last message received -->
<!-- (except if it was a retransmission). If the header was not -->
<!-- present or if no message has been received, the '[last_*]' -->
<!-- keyword is discarded, and all bytes until the end of the line -->
<!-- are also discarded. -->
<!-- -->
<!-- If the specified header was present several times in the -->
<!-- message, all occurences are concatenated (CRLF seperated) -->
<!-- to be used in place of the '[last_*]' keyword. -->
<!-- outgoing proxy
<nop> <action>
<assignstr assign_to="proxy_ip" value="[local_ip]"/>
<assignstr assign_to="proxy_port" value="5060"/>
</action> </nop>
-->
<!--jl: [routes]-->
<send>
<![CDATA[
SIP/2.0 180 Ringing
[last_Via:]
[last_Record-route]
[last_From:]
[last_To:];tag=[pid]SIPpTag01[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
Content-Length: 0
]]>
</send>
<send retrans="1000">
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
[last_Record-route]
[last_From:]
[last_To:];tag=[pid]SIPpTag01[call_number]
[last_Call-ID:]
[last_CSeq:]
Contact: <sip:[service]@[local_ip]:[local_port];transport=[transport]>
User-Agent: sipp@akademia
Content-Type: application/sdp
Content-Length: [len]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [$my_media_port] RTP/AVP 0
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
]]>
</send>
<recv request="ACK"
optional="false"
rtd="true"
crlf="true">
</recv>
<!-- Play a pre-recorded PCAP file (RTP stream) -->
<nop>
<action>
<exec command="tcpdump-vent 10 -i lo -q -s 0 -w rtp_[$sdp_ip]_[pid]_[call_number].pcap src host [$sdp_ip] and dst port [$my_media_port]"/>
<exec play_pcap_audio="/etc/sipshaman/pcap/g711a.pcap"/>
</action>
</nop>
<recv request="BYE" timeout="100000" ontimeout="bye">
</recv>
<send>
<![CDATA[
SIP/2.0 200 OK
[last_Via:]
Contact: <sip:[local_ip]:[local_port];transport=[transport]>
[last_To:]
[last_From:]
[last_Call-ID:]
[last_CSeq:]
User-Agent: sipp@akademia
Content-Length: 0
]]>
</send>
<nop next="end"/>
<label id="bye"/>
<send retrans="500">
<![CDATA[
BYE [next_url] SIP/2.0
[last_Via:]
Max-Forwards: 70
[last_Record-route]
Contact: sip:sipp@[local_ip]:[local_port]
To: SIPP test <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag09[call_number]
Call-ID: [call_id]
CSeq: 2 BYE
User-Agent: sipp@sip-services
Content-Length: 0
]]>
</send>
<recv response="200" crlf="true">
</recv>
<label id="end"/>
<!-- Keep the call open for a while in case the 200 is lost to be -->
<!-- able to retransmit it if we receive the BYE again. -->
<timewait milliseconds="4000"/>
<!-- definition of the response time repartition table (unit is ms) -->
<ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
<!-- definition of the call length repartition table (unit is ms) -->
<CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
</scenario>
......@@ -91,6 +91,7 @@
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [$my_media_port] RTP/AVP 0
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
]]>
......
......@@ -13,8 +13,15 @@ NOC=sip-monitoring@uninett.no
SIPP_USER=sipp
# SIP port for REGISTER
REGISTER_PORT=6050
# Outgoing Proxy (default is first interface address)
# SIP_PROXY
SIP_PROXY_PORT=5062
# SIP port sipp testing
SIP_PORT=5065
# SIP RTP media port start
MEDIA_PORT=16400
# REPORT_TAG
REPORT_TAG=iPBX
# scenario_file to use for
RESPONDER_SCENARIO=sipp-responder.xml
CLIENT_SCENARIO=sipp-client-media.xml
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment