I try to fix this strange problem with Perl script. I tried 2 different type of loop they both doing same job but both got same strange result. The loop is checking each event make sure each day (86400 second for 1 day) has a data input if not exist will create itself with value 0. But the result first half were all going good, second half didn’t increase time with 86400 second instead with 3600 second. The issue always happen when I loading a large amount CDR (CDR which log files from network traffic).
sub RrdTimeLoop { my $self = @_; # foreach my $eventName (sort keys %VAR::CDR_EVENT_COUNT) # { # print $eventName . "\n"; # my $startTime = $VAR::CDR_FIRST_EVENT_TIME{$eventName}; # my $endTime = $VAR::CDR_LAST_EVENT_TIME{$eventName}; # print $startTime . "\n"; # print $endTime . "\n"; # # for (my $i = $startTime; $i < $endTime; $i = $i + 86400) # { # if($VAR::CDR_EVENT_COUNT{$eventName}{$i}) # { # next; # } # else # { # # $VAR::CDR_EVENT_COUNT{$eventName}{$i} = 0; # } # } # } foreach my $eventName (sort keys %VAR::CDR_EVENT_COUNT) { print $eventName . "\n"; my $startTime = $VAR::CDR_FIRST_EVENT_TIME{$eventName}; my $endTime = $VAR::CDR_LAST_EVENT_TIME{$eventName}; print $startTime . "\n"; print $endTime . "\n"; my $loopTime = $startTime; while ($loopTime < $endTime) { if ($VAR::CDR_EVENT_COUNT{$eventName}{$loopTime}) { $loopTime = $loopTime + 86400; } else { $VAR::CDR_EVENT_COUNT{$eventName}{$loopTime} = 0; $loopTime = $loopTime + 86400; } } } return 1; }
=============================================== CDR_TOTAL_901J902M905S906WAPENC906System932X: 1152712800:13063 1152799200:15380 1152885600:14867 1152972000:13009 1153058400:13958 1153144800:12740 1153231200:13670 1153317600:14504 1153404000:15835 1153490400:16723 1153576800:12946 1153663200:3425 1153749600:13786 1153836000:14842 1153922400:15662 1154008800:16623 1154095200:16439 1154181600:13298 1154268000:14772 1154354400:13811 1154440800:14447 1154527200:14818 1154613600:16036 1154700000:17369 1154786400:14217 1154872800:14774 1154959200:13703 1155045600:11091 1155132000:20775 1155218400:21350 1155304800:17332 1155391200:15304 1155477600:20050 1155564000:14044 1155650400:15466 1155736800:15228 1155823200:17039 1155909600:17334 1155996000:14747 1156082400:13846 1156168800:12145 1156255200:16038 1156341600:17133 1156428000:18627 1156514400:17642 1156600800:16155 1156687200:15882 1156773600:15419 1156860000:16304 1156946400:16968 1157032800:18795 1157119200:18025 1157205600:18084 1157292000:15204 1157378400:16383 1157464800:18042 1157551200:17261 1157637600:17203 1157724000:17220 1157810400:15859 1157896800:16099 1157983200:12820 1158069600:16116 1158156000:14816 1158242400:17131 1158328800:18768 1158415200:16738 1158501600:15524 1158588000:15763 1158674400:15979 1158760800:17012 1158847200:18542 1158933600:18606 1159020000:15407 1159106400:15264 1159192800:16871 1159279200:12338 1159365600:12044 1159452000:12384 1159538400:13173 1159624800:11149 1159711200:9564 1159797600:18737 1159884000:10039 1159970400:11128 1160056800:11687 1160143200:11663 1160229600:10283 1160316000:8808 1160402400:9675 1160488800:11577 1160575200:11560 1160661600:11950 1160748000:13208 1160834400:10888 1160920800:11170 1161007200:13173 1161093600:10904 1161180000:11921 1161266400:13416 1161352800:14055 1161439200:11579 1161525600:10508 1161612000:11038 1161698400:17644 1161784800:13199 1161871200:12495 1161957600:14027 1162044000:12132 1162126800:10963 1162130400:0 1162213200:12939 1162216800:0 1162299600:12849 1162303200:0 1162386000:13115 1162389600:0 1162472400:36835 1162476000:0 1162558800:16572 1162562400:0 1162645200:13960 1162648800:0 1162731600:20033 1162735200:0 1162818000:16053 1162821600:0 1162904400:36044 1162908000:0 1162990800:20430 1162994400:0 1163077200:16914 1163080800:0 1163163600:17179 1163167200:0 1163250000:16716 1163253600:0 1163336400:15366 1163340000:0 1163422800:15664 1163426400:0 1163509200:16109 1163512800:0 1163595600:17262 1163599200:0 1163682000:22097 1163685600:0 1163768400:18612 1163772000:0 1163854800:18173 1163858400:0 1163941200:16630 1163944800:0 1164027600:17290 1164031200:0 1164114000:18590 1164117600:0 1164200400:19905 1164204000:0 1164286800:19685 1164290400:0 1164373200:19673 1164376800:0 1164459600:17459 1164463200:0 1164546000:16934 1164549600:0 1164632400:24597 1164636000:0 1164718800:33439 1164722400:0 1164805200:18465 1164808800:0 1164891600:35423 1164895200:0 1164978000:19608 1164981600:0 1165064400:18890 1165068000:0 1165150800:31865 1165154400:0 1165237200:30261 1165240800:0 1165323600:39776 1165327200:0 1165410000:32191 1165413600:0 1165496400:23246 1165500000:0 1165582800:22949 1165586400:0 1165669200:21216 1165672800:0 1165755600:24016 1165759200:0 1165842000:35187 1165845600:0 1165928400:29515 1165932000:0 1166014800:39982 1166018400:0 1166101200:30533 1166104800:0 1166187600:22171 1166191200:0 1166274000:21785 1166277600:0 1166360400:30560 1166364000:0 1166446800:32155 1166450400:0 1166533200:20838 1166536800:0 1166619600:23556 1166623200:0 1166706000:23651 1166709600:0 1166792400:21862 1166796000:0 1166878800:24537 1166882400:0 1166965200:49693 1166968800:0 1167051600:25158 1167055200:0 1167138000:21605 1167141600:0 1167224400:25095 1167228000:0 1167310800:26650 1167314400:0 1167397200:24979 1167400800:0

In reply to loop issue by chefchanyu

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.