Here is an example, 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
-rw-r--r-- 1 root kamailio 1076449 déc. 11 10:06 T201312110910_129.CFT -rw-r--r-- 1 root kamailio 1068691 déc. 11 10:06 T201312110910_130.CFT -rw-r--r-- 1 root kamailio 1111025 déc. 11 10:06 T201312110910_131.CFT -rw-r--r-- 1 root kamailio 1074966 déc. 11 10:06 T201312110910_132.CFT -rw-r--r-- 1 root kamailio 124820 déc. 11 10:06 T201312110910_133.CFT -rw-r--r-- 1 root kamailio 117718 déc. 11 10:06 T201312110910_134.CFT -rw-r--r-- 1 root kamailio 116345 déc. 11 10:06 T201312110910_135.CFT -rw-r--r-- 1 root kamailio 118139 déc. 11 10:06 T201312110910_136.CFT -rw-r--r-- 1 root kamailio 41280528 déc. 11 09:20 T201312110910_137.CFT -rw-r--r-- 1 root kamailio 41434975 déc. 11 09:20 T201312110910_138.CFT -rw-r--r-- 1 root kamailio 41174132 déc. 11 09:20 T201312110910_139.CFT -rw-r--r-- 1 root kamailio 41293613 déc. 11 09:20 T201312110910_140.CFT -rw-r--r-- 1 root kamailio 232929 déc. 11 10:05 T201312110910_1.CFT Here is the output of the command for instance root@corex-mc1s:~# kamcmd -v flatstore.rotate . and a tail on syslog just after 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= 87111681-3595741897-586...@frasbc02.archway.net ;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= 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 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= 87111681-3595741897-586...@frasbc02.archway.net;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= 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= Dec 11 09:11:42 corex-mc1s /usr/local/sbin/kamailio[35749]: ERROR: <script>: ACK FORWARDED STATELESLY 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 On Wed, Dec 11, 2013 at 9:41 AM, Daniel-Constantin Mierla <mico...@gmail.com > wrote: > Hello, > > > On 11/12/13 10:03, Abdelkader Allam wrote: > > Hello Daniel, > > I am using Debian Squeeze and I am moving the file before the rotate. > > 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. > > > 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. > > Cheers, > Daniel > > > > > Thanks a lot for your support and time Daniel > > > > > On Wed, Dec 11, 2013 at 7:54 AM, Daniel-Constantin Mierla < > mico...@gmail.com> wrote: > >> Hello, >> >> what operating system are you using? >> >> 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? >> >> Perhaps worth adding support for renaming the file inside kamailio rotate >> command. >> >> Cheers, >> Daniel >> >> >> On 04/12/13 15:24, Abdelkader Allam wrote: >> >> Hello I am doing it manually with a script which does the renaming >> (basically it is a unix mv) >> >> from glob import glob >> from time import time,sleep >> kamcdrroot="/var/log/kamailio/" >> from datetime import datetime >> from os import system >> >> def mv(fname1,fname2): >> return system("mv %s %s" % (fname1,fname2)) >> >> >> #while True: >> if True: >> timestamp=time() >> prefix=datetime.utcfromtimestamp(timestamp).strftime("T%Y%m%d%H%M") >> cdrfiles=glob(kamcdrroot+"*.log") >> cdrlist=[] >> for cdrfile in cdrfiles: >> >> newname=kamcdrroot+prefix+cdrfile[cdrfile.rfind("_"):cdrfile.rfind(".")]+".CDT" >> cdrlist.append(newname) >> mv(cdrfile,newname) >> print system("kamcmd flatstore.rotate") >> sleep(30) >> for cdrfile in cdrlist: >> mv(cdrfile,cdrfile[:-1]+"R") >> >> so basically the result is the following (i did a few kamailio restart): >> >> root@corex-mc1s:/var/log/kamailio# ls -la >> total 328020 >> drwxrwxrwx 2 root root 4096 déc. 4 13:17 . >> drwxr-xr-x 14 root root 4096 déc. 4 13:15 .. >> -rw-r--r-- 1 root root 23218 déc. 4 14:23 acc_134.log >> -rw-r--r-- 1 root root 21196 déc. 4 14:23 acc_135.log >> -rw-r--r-- 1 root root 24509 déc. 4 14:23 acc_136.log >> -rw-r--r-- 1 root kamailio 14093392 déc. 4 12:29 T201312041208_129.CDR >> -rw-r--r-- 1 root kamailio 14201702 déc. 4 12:29 T201312041208_130.CDR >> -rw-r--r-- 1 root kamailio 13882004 déc. 4 12:29 T201312041208_131.CDR >> -rw-r--r-- 1 root kamailio 13955029 déc. 4 12:29 T201312041208_132.CDR >> -rw-r--r-- 1 root kamailio 4656028 déc. 4 12:29 T201312041208_133.CDR >> -rw-r--r-- 1 root kamailio 4587433 déc. 4 12:29 T201312041208_134.CDR >> -rw-r--r-- 1 root kamailio 4553151 déc. 4 12:29 T201312041208_135.CDR >> -rw-r--r-- 1 root kamailio 4528270 déc. 4 12:29 T201312041208_136.CDR >> -rw-r--r-- 1 root kamailio 64318780 déc. 4 12:05 T201312041208_137.CDR >> -rw-r--r-- 1 root kamailio 64275486 déc. 4 12:05 T201312041208_138.CDR >> -rw-r--r-- 1 root kamailio 64404707 déc. 4 12:05 T201312041208_139.CDR >> -rw-r--r-- 1 root kamailio 64222391 déc. 4 12:05 T201312041208_140.CDR >> -rw-r--r-- 1 root kamailio 130646 déc. 4 11:53 T201312041208_1.CDR >> -rw-r--r-- 1 root kamailio 755148 déc. 4 13:14 T201312041232_129.CDR >> -rw-r--r-- 1 root kamailio 778238 déc. 4 13:14 T201312041232_130.CDR >> -rw-r--r-- 1 root kamailio 749920 déc. 4 13:14 T201312041232_131.CDR >> -rw-r--r-- 1 root kamailio 761826 déc. 4 13:14 T201312041232_132.CDR >> -rw-r--r-- 1 root kamailio 11378 déc. 4 13:13 T201312041232_133.CDR >> -rw-r--r-- 1 root kamailio 11847 déc. 4 13:09 T201312041232_134.CDR >> -rw-r--r-- 1 root kamailio 8599 déc. 4 13:13 T201312041232_135.CDR >> -rw-r--r-- 1 root kamailio 11485 déc. 4 13:13 T201312041232_136.CDR >> -rw-r--r-- 1 root root 97523 déc. 4 14:24 T201312041316_129.CDR >> -rw-r--r-- 1 root root 93268 déc. 4 14:23 T201312041316_130.CDR >> -rw-r--r-- 1 root root 91166 déc. 4 14:23 T201312041316_131.CDR >> -rw-r--r-- 1 root root 94052 déc. 4 14:23 T201312041316_132.CDR >> -rw-r--r-- 1 root root 27300 déc. 4 14:23 T201312041316_133.CDR >> -rw-r--r-- 1 root root 770 déc. 4 13:15 T201312041316_134.CDR >> -rw-r--r-- 1 root root 378 déc. 4 13:15 T201312041316_135.CDR >> -rw-r--r-- 1 root root 765 déc. 4 13:15 T201312041316_136.CDR >> -rw-r--r-- 1 root root 8361 déc. 4 14:23 T201312041316_1.CDR >> >> >> On Wed, Dec 4, 2013 at 2:07 PM, Daniel-Constantin Mierla < >> mico...@gmail.com> wrote: >> >>> Hello, >>> >>> 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. >>> >>> Cheers, >>> Daniel >>> >>> >>> On 12/4/13 2:31 PM, Abdelkader Allam wrote: >>> >>> Hello Guys, >>> >>> 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, >>> >>> >>> 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) >>> >>> #!define WITH_ACCFILE >>> >>> >>> # ----- acc params ----- >>> /* what special events should be accounted ? */ >>> modparam("acc", "early_media", 1) >>> modparam("acc", "report_ack", 1) >>> modparam("acc", "report_cancels", 1) >>> /* by default ww do not adjust the direct of the sequential requests. >>> if you enable this parameter, be sure the enable "append_fromtag" >>> in "rr" module */ >>> modparam("acc", "detect_direction", 0) >>> /* account triggers (flags) */ >>> modparam("acc", "log_flag", FLT_ACC) >>> modparam("acc", "log_missed_flag", FLT_ACCMISSED) >>> modparam("acc", "log_extra", >>> "src_user=$fU;src_domain=$fd;src_ip=$si;" >>> "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd") >>> modparam("acc", "failed_transaction_flag", FLT_ACCFAILED) >>> /* enhanced DB accounting */ >>> modparam("acc", "db_flag", FLT_ACC) >>> modparam("acc", "db_missed_flag", FLT_ACCMISSED) >>> #!ifdef WITH_ACCFILE >>> modparam("acc", "db_url", "flatstore:/var/log/kamailio") >>> modparam("db_flatstore", "flush", 1) >>> modparam("acc", "cdr_enable", 1) >>> #modparam("acc", "cdr_flag", 3) >>> modparam("acc", "db_extra","ds=$DLG_lifetime") >>> modparam("acc", "log_extra", >>> "src_user=$fU;src_domain=$fd;src_ip=$si;" >>> "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;" >>> "duration=$DLG_lifetime") >>> modparam("acc", "db_extra", >>> "src_user=$fU;src_domain=$fd;src_ip=$si;" >>> "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;" >>> "duration=$avp(i:256)") >>> >>> #!endif >>> >>> >>> >>> _______________________________________________ >>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing >>> listsr-us...@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users >>> >>> >>> -- >>> Daniel-Constantin Mierla - >>> http://www.asipto.comhttp://twitter.com/#!/miconda - >>> http://www.linkedin.com/in/miconda >>> >>> >>> _______________________________________________ >>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list >>> sr-users@lists.sip-router.org >>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users >>> >>> >> >> -- >> Daniel-Constantin Mierla - >> http://www.asipto.comhttp://twitter.com/#!/miconda - >> http://www.linkedin.com/in/miconda >> >> > > -- > Daniel-Constantin Mierla - http://www.asipto.comhttp://twitter.com/#!/miconda > - http://www.linkedin.com/in/miconda > >
_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users