<div dir="ltr">Here is an example,<div><br></div><div>today at 9:20 i did a rotate command, after renaming the files, you see that some files are not used so havent been changed since 9:20, but the remaining files are still used until now (10:06 AM). So basically the command had no effet (i launched the command two times </div>
<div><br></div><div><div>-rw-r--r--  1 root kamailio  1076449 déc.  11 10:06 T201312110910_129.CFT</div><div>-rw-r--r--  1 root kamailio  1068691 déc.  11 10:06 T201312110910_130.CFT</div><div>-rw-r--r--  1 root kamailio  1111025 déc.  11 10:06 T201312110910_131.CFT</div>
<div>-rw-r--r--  1 root kamailio  1074966 déc.  11 10:06 T201312110910_132.CFT</div><div>-rw-r--r--  1 root kamailio   124820 déc.  11 10:06 T201312110910_133.CFT</div><div>-rw-r--r--  1 root kamailio   117718 déc.  11 10:06 T201312110910_134.CFT</div>
<div>-rw-r--r--  1 root kamailio   116345 déc.  11 10:06 T201312110910_135.CFT</div><div>-rw-r--r--  1 root kamailio   118139 déc.  11 10:06 T201312110910_136.CFT</div><div>-rw-r--r--  1 root kamailio 41280528 déc.  11 09:20 T201312110910_137.CFT</div>
<div>-rw-r--r--  1 root kamailio 41434975 déc.  11 09:20 T201312110910_138.CFT</div><div>-rw-r--r--  1 root kamailio 41174132 déc.  11 09:20 T201312110910_139.CFT</div><div>-rw-r--r--  1 root kamailio 41293613 déc.  11 09:20 T201312110910_140.CFT</div>
<div>-rw-r--r--  1 root kamailio   232929 déc.  11 10:05 T201312110910_1.CFT</div></div><div><br></div><div><br></div><div>Here is the output of the command for instance</div><div><div>root@corex-mc1s:~# kamcmd -v flatstore.rotate</div>
<div>.</div></div><div><br></div><div>and a tail on syslog just after</div><div><br></div><div><div>Dec 11 09:11:42 corex-mc1s /usr/local/sbin/kamailio[35749]: NOTICE: acc [acc.c:315]: acc_log_request(): ACC: transaction answered: timestamp=1386753102;method=CANCEL;from_tag=3595741897-586103;to_tag=;call_id=<a href="mailto:87111681-3595741897-586099@FRASBC02.archway.net">87111681-3595741897-586099@FRASBC02.archway.net</a>;code=200;reason=OK;src_user=989170458901;src_domain=XX.XX.XX.XX;src_ip=XX.XX.XX.XX;dst_ouser=2478293784983583;dst_user=2478293784983583;dst_domain=XX.XX.XX.XX;duration=</div>
<div>Dec 11 09:11:42 corex-mc1s /usr/local/sbin/kamailio[35751]: NOTICE: acc [acc_cdr.c:268]: log_write_cdr(): start_time=1386753097.600; end_time=1386753097.600; duration=0</div><div>Dec 11 09:11:42 corex-mc1s /usr/local/sbin/kamailio[35751]: NOTICE: acc [acc.c:315]: acc_log_request(): ACC: transaction answered: timestamp=1386753102;method=INVITE;from_tag=3595741897-586103;to_tag=SXBZNDUtytBNS;call_id=<a href="mailto:87111681-3595741897-586099@FRASBC02.archway.net">87111681-3595741897-586099@FRASBC02.archway.net</a>;code=487;reason=Request Terminated;src_user=989170458901;src_domain=xxxxxxx;src_ip=xxxxxxx;dst_ouser=2478293784983583;dst_user=999729#93784983583;dst_domain=xxxxxx;duration=</div>
<div>Dec 11 09:11:42 corex-mc1s /usr/local/sbin/kamailio[35748]: NOTICE: acc [acc.c:315]: acc_log_request(): ACC: transaction answered: timestamp=1386753102;method=CANCEL;from_tag=yaaUymFcg7tjK;to_tag=;call_id=17214e1e-dce7-1231-9d9c-d4ae52bdede5;code=200;reason=OK;src_user=989170458901;src_domain=xxxxx;src_ip=XX.XX.XX.XX;dst_ouser=999639#93784983583;dst_user=999639#93784983583;dst_domain=xxxx;duration=</div>
<div>Dec 11 09:11:42 corex-mc1s /usr/local/sbin/kamailio[35749]: ERROR: <script>: ACK FORWARDED STATELESLY</div><div>Dec 11 09:11:42 corex-mc1s /usr/local/sbin/kamailio[35750]: NOTICE: acc [acc_cdr.c:268]: log_write_cdr(): start_time=1386753101.829; end_time=1386753101.829; duration=0</div>
<div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Dec 11, 2013 at 9:41 AM, Daniel-Constantin Mierla <span dir="ltr"><<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Hello,<div class="im"><br>
    <br>
    <div>On 11/12/13 10:03, Abdelkader Allam
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">Hello Daniel,
        <div><br>
        </div>
        <div>I am using Debian Squeeze and I am moving the file before
          the rotate.</div>
        <div><br>
        </div>
        <div>Unfortunately i had not time to debug kamailio's code to
          find the issue, i read quickly some part of the db_flatstore
          module but i need to figure out how to debug and understand
          how kamcmd passes commands to each kamailio process instance..
          Sometimes when calling the rotate command some process do
          close the fd and reopen it, but not all processes and it
          doesn't work all the time.</div>
      </div>
    </blockquote>
    <br></div>
    the files are closed/reopened when there is a new record to write,
    it is not done immediately on rotate mi/rpc command. The rotate
    command itself just sets the current timestamp as timeline after
    which the rotate has to be done. When a new record is to be written,
    each process tests if timestamp at that moment is less than rotate
    timeline and if yes, then closes and reopens the log file.<br>
    <br>
    Cheers,<br>
    Daniel<div><div class="h5"><br>
     <br>
    <blockquote type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Thanks a lot for your support and time Daniel</div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Wed, Dec 11, 2013 at 7:54 AM,
          Daniel-Constantin Mierla <span dir="ltr"><<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>></span> wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000"> Hello,<br>
              <br>
              what operating system are you using?<br>
              <br>
              Looking at the code, it closes the old fd and reopens the
              file by name. So that should do it ok. Are you moving the
              files before or after rotate command?<br>
              <br>
              Perhaps worth adding support for renaming the file inside
              kamailio rotate command. <br>
              <br>
              Cheers,<br>
              Daniel
              <div>
                <div><br>
                  <br>
                  <div>On 04/12/13 15:24, Abdelkader Allam wrote:<br>
                  </div>
                  <blockquote type="cite">
                    <div dir="ltr">Hello I am doing it manually with a
                      script which does the renaming (basically it is a
                      unix mv)
                      <div><br>
                      </div>
                      <div>
                        <div>from glob import glob</div>
                        <div>from time import time,sleep</div>
                        <div>kamcdrroot="/var/log/kamailio/"</div>
                        <div>from datetime import datetime</div>
                        <div>from os import system</div>
                        <div><br>
                        </div>
                        <div>def mv(fname1,fname2):</div>
                        <div>    return system("mv %s %s" %
                          (fname1,fname2))</div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div> #while True:</div>
                        <div>if True:</div>
                        <div>    timestamp=time()</div>
                        <div>   
                          prefix=datetime.utcfromtimestamp(timestamp).strftime("T%Y%m%d%H%M")</div>
                        <div>    cdrfiles=glob(kamcdrroot+"*.log")</div>
                        <div>     cdrlist=[]</div>
                        <div>    for cdrfile in cdrfiles:</div>
                        <div>       
newname=kamcdrroot+prefix+cdrfile[cdrfile.rfind("_"):cdrfile.rfind(".")]+".CDT"</div>
                        <div>        cdrlist.append(newname)</div>
                        <div>        mv(cdrfile,newname)</div>
                        <div>    print system("kamcmd flatstore.rotate")</div>
                        <div>    sleep(30)</div>
                        <div>    for cdrfile in cdrlist:</div>
                        <div>        mv(cdrfile,cdrfile[:-1]+"R")</div>
                      </div>
                      <div><br>
                      </div>
                      <div>so basically the result is the following (i
                        did a few kamailio restart):</div>
                      <div><br>
                      </div>
                      <div>
                        <div>root@corex-mc1s:/var/log/kamailio# ls -la</div>
                        <div>total 328020</div>
                        <div>drwxrwxrwx  2 root root         4096 déc.  
                          4 13:17 .</div>
                        <div>drwxr-xr-x 14 root root         4096 déc.  
                          4 13:15 ..</div>
                        <div>-rw-r--r--  1 root root        23218 déc.  
                          4 14:23 acc_134.log</div>
                        <div>-rw-r--r--  1 root root        21196 déc.  
                          4 14:23 acc_135.log</div>
                        <div>-rw-r--r--  1 root root        24509 déc.  
                          4 14:23 acc_136.log</div>
                        <div>-rw-r--r--  1 root kamailio 14093392 déc.  
                          4 12:29 T201312041208_129.CDR</div>
                        <div>-rw-r--r--  1 root kamailio 14201702 déc.  
                          4 12:29 T201312041208_130.CDR</div>
                        <div>-rw-r--r--  1 root kamailio 13882004 déc.  
                          4 12:29 T201312041208_131.CDR</div>
                        <div>-rw-r--r--  1 root kamailio 13955029 déc.  
                          4 12:29 T201312041208_132.CDR</div>
                        <div>-rw-r--r--  1 root kamailio  4656028 déc.  
                          4 12:29 T201312041208_133.CDR</div>
                        <div>-rw-r--r--  1 root kamailio  4587433 déc.  
                          4 12:29 T201312041208_134.CDR</div>
                        <div>-rw-r--r--  1 root kamailio  4553151 déc.  
                          4 12:29 T201312041208_135.CDR</div>
                        <div>-rw-r--r--  1 root kamailio  4528270 déc.  
                          4 12:29 T201312041208_136.CDR</div>
                        <div>-rw-r--r--  1 root kamailio 64318780 déc.  
                          4 12:05 T201312041208_137.CDR</div>
                        <div>-rw-r--r--  1 root kamailio 64275486 déc.  
                          4 12:05 T201312041208_138.CDR</div>
                        <div>-rw-r--r--  1 root kamailio 64404707 déc.  
                          4 12:05 T201312041208_139.CDR</div>
                        <div>-rw-r--r--  1 root kamailio 64222391 déc.  
                          4 12:05 T201312041208_140.CDR</div>
                        <div>-rw-r--r--  1 root kamailio   130646 déc.  
                          4 11:53 T201312041208_1.CDR</div>
                        <div>-rw-r--r--  1 root kamailio   755148 déc.  
                          4 13:14 T201312041232_129.CDR</div>
                        <div>-rw-r--r--  1 root kamailio   778238 déc.  
                          4 13:14 T201312041232_130.CDR</div>
                        <div>-rw-r--r--  1 root kamailio   749920 déc.  
                          4 13:14 T201312041232_131.CDR</div>
                        <div>-rw-r--r--  1 root kamailio   761826 déc.  
                          4 13:14 T201312041232_132.CDR</div>
                        <div>-rw-r--r--  1 root kamailio    11378 déc.  
                          4 13:13 T201312041232_133.CDR</div>
                        <div>-rw-r--r--  1 root kamailio    11847 déc.  
                          4 13:09 T201312041232_134.CDR</div>
                        <div>-rw-r--r--  1 root kamailio     8599 déc.  
                          4 13:13 T201312041232_135.CDR</div>
                        <div>-rw-r--r--  1 root kamailio    11485 déc.  
                          4 13:13 T201312041232_136.CDR</div>
                        <div>-rw-r--r--  1 root root        97523 déc.  
                          4 14:24 T201312041316_129.CDR</div>
                        <div>-rw-r--r--  1 root root        93268 déc.  
                          4 14:23 T201312041316_130.CDR</div>
                        <div>-rw-r--r--  1 root root        91166 déc.  
                          4 14:23 T201312041316_131.CDR</div>
                        <div>-rw-r--r--  1 root root        94052 déc.  
                          4 14:23 T201312041316_132.CDR</div>
                        <div>-rw-r--r--  1 root root        27300 déc.  
                          4 14:23 T201312041316_133.CDR</div>
                        <div>-rw-r--r--  1 root root          770 déc.  
                          4 13:15 T201312041316_134.CDR</div>
                        <div>-rw-r--r--  1 root root          378 déc.  
                          4 13:15 T201312041316_135.CDR</div>
                        <div>-rw-r--r--  1 root root          765 déc.  
                          4 13:15 T201312041316_136.CDR</div>
                        <div>-rw-r--r--  1 root root         8361 déc.  
                          4 14:23 T201312041316_1.CDR</div>
                      </div>
                    </div>
                    <div class="gmail_extra"><br>
                      <br>
                      <div class="gmail_quote">On Wed, Dec 4, 2013 at
                        2:07 PM, Daniel-Constantin Mierla <span dir="ltr"><<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>></span>
                        wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                          <div bgcolor="#FFFFFF" text="#000000"> Hello,<br>
                            <br>
                            how you do the files rotation? The readme is
                            saying that has to be done via an external
                            application. Nothing has change in this
                            regard for many years.<br>
                            <br>
                            Cheers,<br>
                            Daniel
                            <div>
                              <div><br>
                                <br>
                                <div>On 12/4/13 2:31 PM, Abdelkader
                                  Allam wrote:<br>
                                </div>
                              </div>
                            </div>
                            <blockquote type="cite">
                              <div>
                                <div>
                                  <div dir="ltr">
                                    <div dir="ltr" style="font-family:arial,sans-serif;font-size:13px">
                                      <div>Hello Guys,</div>
                                      <div><br>
                                      </div>
                                      <div>I am using Kamailio 4.1.0. I
                                        am trying to get Kamailio to
                                        rotate the cdr log through
                                        command kamcmd flatstore.rotate
                                         but it keeps sending log to the
                                        renamed files, </div>
                                      <div><br>
                                      </div>
                                      <div><br>
                                      </div>
                                      <div>I use the following parameter
                                        (i tried to set flush to 1 and
                                        0, same result, i have also
                                        tried in debug and normal mode)</div>
                                      <div><br>
                                      </div>
                                      <div>#!define WITH_ACCFILE</div>
                                      <div><br>
                                      </div>
                                      <div><br>
                                      </div>
                                      <div>
                                        <div># ----- acc params -----</div>
                                        <div>/* what special events
                                          should be accounted ? */</div>
                                        <div>modparam("acc",
                                          "early_media", 1)</div>
                                        <div>modparam("acc",
                                          "report_ack", 1)</div>
                                        <div>modparam("acc",
                                          "report_cancels", 1)</div>
                                        <div>/* by default ww do not
                                          adjust the direct of the
                                          sequential requests.</div>
                                        <div>   if you enable this
                                          parameter, be sure the enable
                                          "append_fromtag"</div>
                                        <div>   in "rr" module */</div>
                                        <div>modparam("acc",
                                          "detect_direction", 0)</div>
                                        <div>/* account triggers (flags)
                                          */</div>
                                        <div>modparam("acc", "log_flag",
                                          FLT_ACC)</div>
                                        <div> modparam("acc",
                                          "log_missed_flag",
                                          FLT_ACCMISSED)</div>
                                        <div>modparam("acc",
                                          "log_extra", </div>
                                        <div><span style="white-space:pre-wrap">
                                          </span>"src_user=$fU;src_domain=$fd;src_ip=$si;"</div>
                                        <div><span style="white-space:pre-wrap">
                                          </span>"dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")</div>
                                        <div>modparam("acc",
                                          "failed_transaction_flag",
                                          FLT_ACCFAILED)</div>
                                        <div>/* enhanced DB accounting
                                          */</div>
                                        <div>modparam("acc", "db_flag",
                                          FLT_ACC)</div>
                                        <div>modparam("acc",
                                          "db_missed_flag",
                                          FLT_ACCMISSED)</div>
                                        <div>#!ifdef WITH_ACCFILE</div>
                                        <div>modparam("acc", "db_url",
                                          "flatstore:/var/log/kamailio") </div>
                                        <div>modparam("db_flatstore",
                                          "flush", 1)</div>
                                        <div>modparam("acc",
                                          "cdr_enable", 1)</div>
                                        <div>#modparam("acc",
                                          "cdr_flag", 3)</div>
                                        <div>modparam("acc",
                                          "db_extra","ds=$DLG_lifetime")</div>
                                        <div>modparam("acc",
                                          "log_extra",</div>
                                        <div>"src_user=$fU;src_domain=$fd;src_ip=$si;"</div>
                                        <div>"dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;"</div>
                                        <div>"duration=$DLG_lifetime")</div>
                                        <div>modparam("acc", "db_extra",</div>
                                        <div>"src_user=$fU;src_domain=$fd;src_ip=$si;" </div>
                                        <div>"dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;"</div>
                                        <div>"duration=$avp(i:256)")</div>
                                        <div><br>
                                        </div>
                                        <div>#!endif</div>
                                      </div>
                                    </div>
                                    <br style="font-family:arial,sans-serif;font-size:13px">
                                  </div>
                                  <br>
                                  <fieldset></fieldset>
                                  <br>
                                </div>
                              </div>
                              <pre>_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><span><font color="#888888">
</font></span></pre>
                              <span><font color="#888888"> </font></span></blockquote>
                            <span><font color="#888888"> <br>
                                <pre cols="72">-- 
Daniel-Constantin Mierla - <a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
<a href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a></pre>
                              </font></span></div>
                          <br>
_______________________________________________<br>
                          SIP Express Router (SER) and Kamailio
                          (OpenSER) - sr-users mailing list<br>
                          <a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a><br>
                          <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
                          <br>
                        </blockquote>
                      </div>
                      <br>
                    </div>
                  </blockquote>
                  <br>
                  <pre cols="72">-- 
Daniel-Constantin Mierla - <a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
<a href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a></pre>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <pre cols="72">-- 
Daniel-Constantin Mierla - <a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
<a href="http://twitter.com/#!/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a></pre>
  </div></div></div>

</blockquote></div><br></div>