X-Git-Url: http://47.100.26.94:8080/?a=blobdiff_plain;f=bin%2Fcpve_log.pl;fp=bin%2Fcpve_log.pl;h=cb8979df765faa9411459d52d01e56eb7269a43e;hb=13a31c5cdbb0bc24b8cd51776d32d73561294622;hp=0000000000000000000000000000000000000000;hpb=0ac7e1ca2a56397b76df4d4970c8326d3f11518d;p=dotfiles.git diff --git a/bin/cpve_log.pl b/bin/cpve_log.pl new file mode 100755 index 0000000..cb8979d --- /dev/null +++ b/bin/cpve_log.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl -w +# +use strict; +use warnings; +use v5.10; ## say + +#my $log_file = @ARGV[0]; +# +# TODO: +# 1. append cpve version to the file name of full log +# 2. output critical error of CPVE/PME such as "camera" camera error +# 3. split the full log as sub logs against the call time +# 4. plot the RTP stats + +my $k_start_call = 'originateCall|answercall'; +#my $k_start_call = 'originateCall'; + +# create jabber_full.log to add jabber.log, jabber.log.1, jabber.log.2 +my $out_dir = `pwd` . '/out/'; +my @logs = glob "jabber.log*"; +my $full_logs = "$out_dir/jabber_full.log"; + +#my $cpve_version; + +#foreach (@logs) { say; } +#say @logs; +#print @logs; + +#print for (reverse @logs); + +##open LOGS, ">>$full_logs" or die "$!"; +##for (reverse @logs){ +## open SUB_LOG, "<", $_ or die "$!"; +## print LOGS while() ; +## close SUB_LOG; +##} +##close LOGS; +## +##for (reverse @logs){ +## !system "cat $_ >> $full_logs" or die "$!"; +##} + +## merge log files +!system "cat $_ >> $full_logs" or die "$!" for reverse @logs; + +my $version= + +print "===== write done ====\n"; +## split file with each call +my $call = "call0.log"; + +open CALL, ">> $call" or die "$!"; +open LOG, "<", $full_logs or die "$!"; +my $index = 0; +while(){ +## print CALL $_; +## last if /originateCall/; + if ($_ =~ /originateCall/ ){ + close + $index = $index+1; + open LOG, ">>" "call$index" or die "$!"; + print LOG $_; + } +}