At first I started to read the file and processing. But why I choose these path is

 Tue Oct 13 00:00:01 2015|1008|959788857688|123580|Tue Oct 13 00:00:01 2015|Tue Oct 13 00:00:01 2015|CMT|Undelivered|none|Submit|0|SMSC_PR_LC_SMSC_InvalidDestAddress|GSM|INVALID|16 Bit|140|140|no||no|no||1/2|No|NO|no|no|0|1|0|0||959790000028||8|0||0|no|no|default_billing|-1|0|no|no|1|1|1|1|0|1|0|0|||||Wed Oct 14 00:00:01 2015|SR|||IV|011809614446710010008|||0|0||0|0||0||||123580||||||||||||||||||

This is one line of my log. If you Maximise the zero element  Tue Oct 13 00:00:01 2015 the date & time is available. Like this I have files for each ten minutes.

SMSCDR_PREPAY_151013000000_10.84.0.29_AS.log (From 00:00:01 to 00:10:0 +0) SMSCDR_PREPAY_151013100000_10.84.0.29_AS.log (From 00:10:01 to 00:20:0 +0) SMSCDR_PREPAY_151013200000_10.84.0.29_AS.log SMSCDR_PREPAY_151013300000_10.84.0.29_AS.log SMSCDR_PREPAY_151013400000_10.84.0.29_AS.log SMSCDR_PREPAY_151013500000_10.84.0.29_AS.log (From 00:50:01 to 01:00:0 +0)

Like this we have POSTPAID_CDR & DELIVERY_CDR for every 10 minutes as like mentioned above

Now my requirement is

00:10:00= 0 0 00:10:01= 158 158 00:10:02= 163 321 00:10:03= 214 535 00:10:04= 123 658 00:10:05= 174 832 00:10:06= 271 1103 00:10:07= 96 1199 00:10:08= 263 1462 00:10:09= 72 1534 00:10:10= 190 1724

The first element is time. The total after "=" is total entries noted in that particular second where 10th field (Submit) & 13 th field (GSM)in all prepay, postpaid, delivery CDR's. The last one is total entries upto that second from starting of the file.

And finally I need the highest entries noted in which second & that count

For that I written code like this

my @low_sec = ("00","01","02","03","04","05","06","07","08","09"); my @high_sec = (10 .. 59); my @seconds = (@low_sec,@high_sec); my $greatest = 0; my $total = 0; foreach my $min ($minute .. $minute+9) { foreach my $sec (@seconds) { my $SMPP_count = int ((split (/\s+/,`cut -d "|" -f 1,1 +0,13 SMSCDR*$date$hour$minute*.log |grep "Submit|GSM" |grep "$hour:$m +in:$sec" |sort |uniq -c`)) [1]) + int ((split (/\s+/,`cut -d "|" -f 1 +,10,13 SMSCDR*$date$hour$minute*.log |grep "Submit|SMPP" |grep "$hour +:$min:$sec" |sort |uniq -c`)) [1]); if ($SMPP_count > $greatest) { $greatest = $SMPP_count; } $total = $total + $SMPP_count; print "$hour:$min:$sec","= $SMPP_count","\t",$total,$/ +; } } print $greatest,$/;

Is there any easier method please guide me


In reply to Re^4: using system command in regex by ravi45722
in thread using system command in regex by ravi45722

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.