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

Changed to using select to avoid waiting longer than -die.


git-svn-id: file:///home/svn/sipshaman/trunk@29 9383e1fa-a92b-456e-b4ec-45f0d4f7abeb
parent 39474847
......@@ -36,41 +36,43 @@ $tmp="/tmp/qstream-sipp-$$.xml";
my $endooflife=0;
if ($opt_die){
$endoflife=time+$opt_die*60;
$SIG{ALRM} = sub {
printf "Ended after $opt_die minutes\n";
exit(0);
};
alarm($opt_die*60+3); # allow for 3 seconds to die voluntary
}
my $timeout= $opt_timeout || 1; # wait n seconds for file too be updated
foreach $tasklog(@ARGV){
open TASKLOG, "<$tasklog" || die "Could not open $tasklog : $!";
while( 1 ){ # read task.log
$rin = $win = $ein = '';
vec($rin,fileno(TASKLOG),1) = 1;
$ein = $rin | $win;
# while(eof(TASKLOG)){ # wait for next line to file
# exit(1) if $opt_die && (time > $endoflife);
# last if !$opt_f;
# sleep $timeout;
# next; # wait for more data
# }
while( $nfound=select($rout=$rin, $wout=$win, $eout=$ein, $timeout) ){ # read task.log
if (!$nfound){ # timeout
exit(1) if $opt_die && (time > $endoflife);
if (! ($line=<TASKLOG>)){ # could not read the line
exit(1) if $opt_die && (time > $endoflife);
last if !$opt_f;
sleep $timeout;
next;
} elsif (!eof(TASKLOG)) { # line ready
&process_line($line=<TASKLOG>);
} else { # probably eof
last;
}
}
close TASKLOG;
}
exit(0);
#--------------------------------------------------------------------------------
sub process_line {
my $line=shift;
next if $line !~ /[\d-]+ [\d:]+ \d+ \d+/; # invalid line/empty ..Format : date time port port
my ($date, $time, $pid, $sip_port, $rtp_port, $id, $function, $machine, $rtt)=split(/\s+/, $line);
......@@ -185,15 +187,12 @@ foreach $tasklog(@ARGV){
}
close TASKLOG;
}
# /usr/bin/sipp-print -id $src -q -f 'OutgoingCall(C)|SuccessfulCall(C)|FailedCall(C)|Retransmissions(C)|ResponseTime1(C)|ResponseTime1StDev(C)|CallLength(C)|CallLengthStDev(C)' *${pid}_.csv
# /usr/bin/sipp-print -id $src -q -f 'OutgoingCall(C)|SuccessfulCall(C)|FailedCall(C)|Retransmissions(C)|ResponseTime1(C)|ResponseTime1StDev(C)|CallLength(C)|CallLengthStDev(C)' *${pid}_.csv
exit(0);
#--------------------------------------------------------------------------------
sub bb_color {
my ($limit, $color, $value)=@_;
......@@ -209,14 +208,12 @@ sub bb_color {
sub bb_report {
return 0 if ! $opt_bb;
my ($bbtest, $machine, $color, $msg)=@_;
# my $cmd="/usr/lib/hobbit/client/bin/bb $bb_host 'status $machine.$bbtest $color $msg\n'>>$ENV{HOME}/cmd.log 2>&1";
my $cmd="/usr/lib/hobbit/client/bin/bb $bb_host 'status $machine.$bbtest $color $msg\n'";
# system($cmd)|| warn "Command failed : $cmd : $!";
my @cmd=("/usr/lib/hobbit/client/bin/bb", "$bb_host", "status $machine.$bbtest $color $msg\n");
system(@cmd); # || warn "Command failed : $cmd : $!";
system(@cmd) if $opt_bb; # || warn "Command failed : @cmd : $!" ;
print $cmd, "\n" if $opt_v;
}
......
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