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
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 list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
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 miconda@gmail.comwrote:
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-users@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
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 <miconda@gmail.com mailto:miconda@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 list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -http://www.asipto.com http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> -http://www.linkedin.com/in/miconda _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
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.
Thanks a lot for your support and time Daniel
On Wed, Dec 11, 2013 at 7:54 AM, Daniel-Constantin Mierla <miconda@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 < miconda@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-users@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
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 <miconda@gmail.com mailto:miconda@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 <miconda@gmail.com <mailto:miconda@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 list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -http://www.asipto.com http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> -http://www.linkedin.com/in/miconda _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -http://www.asipto.com http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> -http://www.linkedin.com/in/miconda
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-586099@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-586099@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 <miconda@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 < miconda@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 < miconda@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-users@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
Here is another try
I made a code change to see if the kamcmd has really an effect on the module
root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# git diff diff --git a/modules/db_flatstore/flat_rpc.c b/modules/db_flatstore/flat_rpc.c index 2fe0d0f..9a51446 100644 --- a/modules/db_flatstore/flat_rpc.c +++ b/modules/db_flatstore/flat_rpc.c @@ -32,6 +32,8 @@
#include "flat_rpc.h" #include "flatstore_mod.h" +#include "../../dprint.h" +
#include <time.h>
@@ -44,6 +46,8 @@ static void rotate(rpc_t* rpc, void* c) { *flat_rotate = time(0); + LOG(L_WARN, "WARNING: flat_rotate CHANGED \n"); + }
I changed the name of the file with mv command as usual and then launched the rotate command and saw that it is actually taken into account and logged:
root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# cat /var/log/syslog|grep rotate Dec 11 10:46:53 corex-mc1s /usr/local/sbin/kamailio[4497]: WARNING: db_flatstore [flat_rpc.c:49]: rotate(): WARNING: flat_rotate CHANGED
But it had effect on only one of the process. Why aren't all processes of kamailio logging the message (here only process 4497 got the command)? It looks like only one of the process gets the command.
root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# ps auxf|grep kamailio root 4784 0.0 0.0 8052 860 pts/7 S+ 10:51 0:00 | _ grep kamailio root 4473 0.0 0.0 186708 7164 ? S 10:44 0:00 /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4474 0.0 0.0 186712 8440 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4475 0.0 0.0 186712 8376 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4476 0.0 0.0 186712 8356 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4477 0.0 0.0 186712 8332 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4478 0.0 0.0 186712 5768 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4479 0.0 0.0 186712 5652 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4480 0.0 0.0 186712 5604 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4481 0.0 0.0 186712 5672 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4482 0.0 0.0 186708 3576 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4483 0.0 0.0 186708 3576 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4484 0.0 0.0 186708 3576 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4486 0.0 0.0 186708 3572 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4488 0.0 0.0 186712 3996 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4490 0.4 0.0 186708 6760 ? S 10:44 0:01 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4493 0.0 0.0 186712 2560 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4497 0.0 0.0 186776 3048 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4498 0.0 0.0 186708 3244 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4500 0.0 0.0 186708 2892 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio
root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# ls -la /var/log/kamailio/|grep "10:" drwxrwxrwx 2 root root 4096 déc. 11 10:49 . -rw-r--r-- 1 root kamailio 194 déc. 11 10:49 acc_1.log -rw-r--r-- 1 root kamailio 9764471 déc. 9 10:30 T201312051212_131.CFT -rw-r--r-- 1 root kamailio 1305022 déc. 11 10:44 T201312110910_129.CFT -rw-r--r-- 1 root kamailio 1302007 déc. 11 10:44 T201312110910_130.CFT -rw-r--r-- 1 root kamailio 1347304 déc. 11 10:44 T201312110910_131.CFT -rw-r--r-- 1 root kamailio 1302961 déc. 11 10:44 T201312110910_132.CFT -rw-r--r-- 1 root kamailio 136259 déc. 11 10:44 T201312110910_133.CFT -rw-r--r-- 1 root kamailio 130057 déc. 11 10:44 T201312110910_134.CFT -rw-r--r-- 1 root kamailio 130622 déc. 11 10:44 T201312110910_135.CFT -rw-r--r-- 1 root kamailio 129914 déc. 11 10:44 T201312110910_136.CFT -rw-r--r-- 1 root kamailio 234889 déc. 11 10:42 T201312110910_1.CFT -rw-r--r-- 1 root kamailio 89076 déc. 11 10:50 T201312111046_129.CFT -rw-r--r-- 1 root kamailio 86649 déc. 11 10:50 T201312111046_130.CFT -rw-r--r-- 1 root kamailio 88435 déc. 11 10:50 T201312111046_131.CFT -rw-r--r-- 1 root kamailio 80389 déc. 11 10:50 T201312111046_132.CFT -rw-r--r-- 1 root kamailio 1310 déc. 11 10:50 T201312111046_133.CFT -rw-r--r-- 1 root kamailio 1522 déc. 11 10:50 T201312111046_134.CFT -rw-r--r-- 1 root kamailio 1377 déc. 11 10:48 T201312111046_135.CFT -rw-r--r-- 1 root kamailio 1160 déc. 11 10:48 T201312111046_136.CFT
On Wed, Dec 11, 2013 at 10:13 AM, Abdelkader Allam < abdelkader.allam@gmail.com> wrote:
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-586099@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-586099@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 < miconda@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 < > miconda@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 < >> miconda@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-users@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 > >
Hi Daniel
I found the bug,
On Wed, Dec 11, 2013 at 10:52 AM, Abdelkader Allam < abdelkader.allam@gmail.com> wrote:
Here is another try
I made a code change to see if the kamcmd has really an effect on the module
root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# git diff diff --git a/modules/db_flatstore/flat_rpc.c b/modules/db_flatstore/flat_rpc.c index 2fe0d0f..9a51446 100644 --- a/modules/db_flatstore/flat_rpc.c +++ b/modules/db_flatstore/flat_rpc.c @@ -32,6 +32,8 @@
#include "flat_rpc.h" #include "flatstore_mod.h" +#include "../../dprint.h"
#include <time.h>
@@ -44,6 +46,8 @@ static void rotate(rpc_t* rpc, void* c) { *flat_rotate = time(0);
LOG(L_WARN, "WARNING: flat_rotate CHANGED \n");
}
I changed the name of the file with mv command as usual and then launched the rotate command and saw that it is actually taken into account and logged:
root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# cat /var/log/syslog|grep rotate Dec 11 10:46:53 corex-mc1s /usr/local/sbin/kamailio[4497]: WARNING: db_flatstore [flat_rpc.c:49]: rotate(): WARNING: flat_rotate CHANGED
But it had effect on only one of the process. Why aren't all processes of kamailio logging the message (here only process 4497 got the command)? It looks like only one of the process gets the command.
root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# ps auxf|grep kamailio root 4784 0.0 0.0 8052 860 pts/7 S+ 10:51 0:00 | _ grep kamailio root 4473 0.0 0.0 186708 7164 ? S 10:44 0:00 /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4474 0.0 0.0 186712 8440 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4475 0.0 0.0 186712 8376 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4476 0.0 0.0 186712 8356 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4477 0.0 0.0 186712 8332 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4478 0.0 0.0 186712 5768 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4479 0.0 0.0 186712 5652 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4480 0.0 0.0 186712 5604 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4481 0.0 0.0 186712 5672 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4482 0.0 0.0 186708 3576 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4483 0.0 0.0 186708 3576 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4484 0.0 0.0 186708 3576 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4486 0.0 0.0 186708 3572 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4488 0.0 0.0 186712 3996 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4490 0.4 0.0 186708 6760 ? S 10:44 0:01 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4493 0.0 0.0 186712 2560 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4497 0.0 0.0 186776 3048 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4498 0.0 0.0 186708 3244 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4500 0.0 0.0 186708 2892 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio
root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# ls -la /var/log/kamailio/|grep "10:" drwxrwxrwx 2 root root 4096 déc. 11 10:49 . -rw-r--r-- 1 root kamailio 194 déc. 11 10:49 acc_1.log -rw-r--r-- 1 root kamailio 9764471 déc. 9 10:30 T201312051212_131.CFT -rw-r--r-- 1 root kamailio 1305022 déc. 11 10:44 T201312110910_129.CFT -rw-r--r-- 1 root kamailio 1302007 déc. 11 10:44 T201312110910_130.CFT -rw-r--r-- 1 root kamailio 1347304 déc. 11 10:44 T201312110910_131.CFT -rw-r--r-- 1 root kamailio 1302961 déc. 11 10:44 T201312110910_132.CFT -rw-r--r-- 1 root kamailio 136259 déc. 11 10:44 T201312110910_133.CFT -rw-r--r-- 1 root kamailio 130057 déc. 11 10:44 T201312110910_134.CFT -rw-r--r-- 1 root kamailio 130622 déc. 11 10:44 T201312110910_135.CFT -rw-r--r-- 1 root kamailio 129914 déc. 11 10:44 T201312110910_136.CFT -rw-r--r-- 1 root kamailio 234889 déc. 11 10:42 T201312110910_1.CFT -rw-r--r-- 1 root kamailio 89076 déc. 11 10:50 T201312111046_129.CFT -rw-r--r-- 1 root kamailio 86649 déc. 11 10:50 T201312111046_130.CFT -rw-r--r-- 1 root kamailio 88435 déc. 11 10:50 T201312111046_131.CFT -rw-r--r-- 1 root kamailio 80389 déc. 11 10:50 T201312111046_132.CFT -rw-r--r-- 1 root kamailio 1310 déc. 11 10:50 T201312111046_133.CFT -rw-r--r-- 1 root kamailio 1522 déc. 11 10:50 T201312111046_134.CFT -rw-r--r-- 1 root kamailio 1377 déc. 11 10:48 T201312111046_135.CFT -rw-r--r-- 1 root kamailio 1160 déc. 11 10:48 T201312111046_136.CFT
On Wed, Dec 11, 2013 at 10:13 AM, Abdelkader Allam < abdelkader.allam@gmail.com> wrote:
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-586099@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-586099@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 < miconda@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 < > miconda@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 < >> miconda@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-users@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 > >
Sorry email sent before i finished writing it.
So the bug is the following, the rpc modify flat_rotate which is used by old code (flat_con, flat_cmd, ..), instead of km_flat_rotate which is the one actually used by the current running code km_flat_con, km_flatstore..)
After modifying it, it works fine.
diff --git a/modules/db_flatstore/flat_rpc.c b/modules/db_flatstore/flat_rpc.c index 2fe0d0f..f7b44dd 100644 --- a/modules/db_flatstore/flat_rpc.c +++ b/modules/db_flatstore/flat_rpc.c @@ -32,7 +32,8 @@
#include "flat_rpc.h" #include "flatstore_mod.h" - +#include "km_flatstore_mod.h" +#include "../../dprint.h" #include <time.h>
/** Register a new file rotation request. @@ -44,6 +45,9 @@ static void rotate(rpc_t* rpc, void* c) { *flat_rotate = time(0); + *km_flat_rotate = time(0); + LOG(L_WARN, "WARNING: flat_rotate CHANGED \n"); + }
On Sun, Dec 15, 2013 at 2:52 PM, Abdelkader Allam < abdelkader.allam@gmail.com> wrote:
Hi Daniel
I found the bug,
On Wed, Dec 11, 2013 at 10:52 AM, Abdelkader Allam < abdelkader.allam@gmail.com> wrote:
Here is another try
I made a code change to see if the kamcmd has really an effect on the module
root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# git diff diff --git a/modules/db_flatstore/flat_rpc.c b/modules/db_flatstore/flat_rpc.c index 2fe0d0f..9a51446 100644 --- a/modules/db_flatstore/flat_rpc.c +++ b/modules/db_flatstore/flat_rpc.c @@ -32,6 +32,8 @@
#include "flat_rpc.h" #include "flatstore_mod.h" +#include "../../dprint.h"
#include <time.h>
@@ -44,6 +46,8 @@ static void rotate(rpc_t* rpc, void* c) { *flat_rotate = time(0);
LOG(L_WARN, "WARNING: flat_rotate CHANGED \n");
}
I changed the name of the file with mv command as usual and then launched the rotate command and saw that it is actually taken into account and logged:
root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# cat /var/log/syslog|grep rotate Dec 11 10:46:53 corex-mc1s /usr/local/sbin/kamailio[4497]: WARNING: db_flatstore [flat_rpc.c:49]: rotate(): WARNING: flat_rotate CHANGED
But it had effect on only one of the process. Why aren't all processes of kamailio logging the message (here only process 4497 got the command)? It looks like only one of the process gets the command.
root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# ps auxf|grep kamailio root 4784 0.0 0.0 8052 860 pts/7 S+ 10:51 0:00 | _ grep kamailio root 4473 0.0 0.0 186708 7164 ? S 10:44 0:00 /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4474 0.0 0.0 186712 8440 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4475 0.0 0.0 186712 8376 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4476 0.0 0.0 186712 8356 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4477 0.0 0.0 186712 8332 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4478 0.0 0.0 186712 5768 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4479 0.0 0.0 186712 5652 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4480 0.0 0.0 186712 5604 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4481 0.0 0.0 186712 5672 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4482 0.0 0.0 186708 3576 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4483 0.0 0.0 186708 3576 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4484 0.0 0.0 186708 3576 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4486 0.0 0.0 186708 3572 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4488 0.0 0.0 186712 3996 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4490 0.4 0.0 186708 6760 ? S 10:44 0:01 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4493 0.0 0.0 186712 2560 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4497 0.0 0.0 186776 3048 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4498 0.0 0.0 186708 3244 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4500 0.0 0.0 186708 2892 ? S 10:44 0:00 _ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio
root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# ls -la /var/log/kamailio/|grep "10:" drwxrwxrwx 2 root root 4096 déc. 11 10:49 . -rw-r--r-- 1 root kamailio 194 déc. 11 10:49 acc_1.log -rw-r--r-- 1 root kamailio 9764471 déc. 9 10:30 T201312051212_131.CFT -rw-r--r-- 1 root kamailio 1305022 déc. 11 10:44 T201312110910_129.CFT -rw-r--r-- 1 root kamailio 1302007 déc. 11 10:44 T201312110910_130.CFT -rw-r--r-- 1 root kamailio 1347304 déc. 11 10:44 T201312110910_131.CFT -rw-r--r-- 1 root kamailio 1302961 déc. 11 10:44 T201312110910_132.CFT -rw-r--r-- 1 root kamailio 136259 déc. 11 10:44 T201312110910_133.CFT -rw-r--r-- 1 root kamailio 130057 déc. 11 10:44 T201312110910_134.CFT -rw-r--r-- 1 root kamailio 130622 déc. 11 10:44 T201312110910_135.CFT -rw-r--r-- 1 root kamailio 129914 déc. 11 10:44 T201312110910_136.CFT -rw-r--r-- 1 root kamailio 234889 déc. 11 10:42 T201312110910_1.CFT -rw-r--r-- 1 root kamailio 89076 déc. 11 10:50 T201312111046_129.CFT -rw-r--r-- 1 root kamailio 86649 déc. 11 10:50 T201312111046_130.CFT -rw-r--r-- 1 root kamailio 88435 déc. 11 10:50 T201312111046_131.CFT -rw-r--r-- 1 root kamailio 80389 déc. 11 10:50 T201312111046_132.CFT -rw-r--r-- 1 root kamailio 1310 déc. 11 10:50 T201312111046_133.CFT -rw-r--r-- 1 root kamailio 1522 déc. 11 10:50 T201312111046_134.CFT -rw-r--r-- 1 root kamailio 1377 déc. 11 10:48 T201312111046_135.CFT -rw-r--r-- 1 root kamailio 1160 déc. 11 10:48 T201312111046_136.CFT
On Wed, Dec 11, 2013 at 10:13 AM, Abdelkader Allam < abdelkader.allam@gmail.com> wrote:
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-586099@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-586099@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 < miconda@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 < > miconda@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 < >> miconda@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-users@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 > >
Hello,
just saw in the sources that the command for kamailio specific DB interface rotation was rpc 'k_rotate'.
Anyhow, I enabled for rpc 'rotoate' based on your patch, in master and 4.1 branches.
Thanks, Daniel
On 15/12/13 15:56, Abdelkader Allam wrote:
Sorry email sent before i finished writing it.
So the bug is the following, the rpc modify flat_rotate which is used by old code (flat_con, flat_cmd, ..), instead of km_flat_rotate which is the one actually used by the current running code km_flat_con, km_flatstore..)
After modifying it, it works fine.
diff --git a/modules/db_flatstore/flat_rpc.c b/modules/db_flatstore/flat_rpc.c index 2fe0d0f..f7b44dd 100644 --- a/modules/db_flatstore/flat_rpc.c +++ b/modules/db_flatstore/flat_rpc.c @@ -32,7 +32,8 @@
#include "flat_rpc.h" #include "flatstore_mod.h"
+#include "km_flatstore_mod.h" +#include "../../dprint.h" #include <time.h>
/** Register a new file rotation request. @@ -44,6 +45,9 @@ static void rotate(rpc_t* rpc, void* c) { *flat_rotate = time(0);
*km_flat_rotate = time(0);
LOG(L_WARN, "WARNING: flat_rotate CHANGED \n");
}
On Sun, Dec 15, 2013 at 2:52 PM, Abdelkader Allam <abdelkader.allam@gmail.com mailto:abdelkader.allam@gmail.com> wrote:
Hi Daniel I found the bug, On Wed, Dec 11, 2013 at 10:52 AM, Abdelkader Allam <abdelkader.allam@gmail.com <mailto:abdelkader.allam@gmail.com>> wrote: Here is another try I made a code change to see if the kamcmd has really an effect on the module root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# git diff diff --git a/modules/db_flatstore/flat_rpc.c b/modules/db_flatstore/flat_rpc.c index 2fe0d0f..9a51446 100644 --- a/modules/db_flatstore/flat_rpc.c +++ b/modules/db_flatstore/flat_rpc.c @@ -32,6 +32,8 @@ #include "flat_rpc.h" #include "flatstore_mod.h" +#include "../../dprint.h" + #include <time.h> @@ -44,6 +46,8 @@ static void rotate(rpc_t* rpc, void* c) { *flat_rotate = time(0); + LOG(L_WARN, "WARNING: flat_rotate CHANGED \n"); + } I changed the name of the file with mv command as usual and then launched the rotate command and saw that it is actually taken into account and logged: root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# cat /var/log/syslog|grep rotate Dec 11 10:46:53 corex-mc1s /usr/local/sbin/kamailio[4497]: WARNING: db_flatstore [flat_rpc.c:49]: rotate(): WARNING: flat_rotate CHANGED But it had effect on only one of the process. Why aren't all processes of kamailio logging the message (here only process 4497 got the command)? It looks like only one of the process gets the command. root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# ps auxf|grep kamailio root 4784 0.0 0.0 8052 860 pts/7 S+ 10:51 0:00 | \_ grep kamailio root 4473 0.0 0.0 186708 7164 ? S 10:44 0:00 /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4474 0.0 0.0 186712 8440 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4475 0.0 0.0 186712 8376 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4476 0.0 0.0 186712 8356 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4477 0.0 0.0 186712 8332 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4478 0.0 0.0 186712 5768 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4479 0.0 0.0 186712 5652 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4480 0.0 0.0 186712 5604 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4481 0.0 0.0 186712 5672 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4482 0.0 0.0 186708 3576 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4483 0.0 0.0 186708 3576 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4484 0.0 0.0 186708 3576 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4486 0.0 0.0 186708 3572 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4488 0.0 0.0 186712 3996 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4490 0.4 0.0 186708 6760 ? S 10:44 0:01 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4493 0.0 0.0 186712 2560 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4497 0.0 0.0 186776 3048 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4498 0.0 0.0 186708 3244 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root 4500 0.0 0.0 186708 2892 ? S 10:44 0:00 \_ /usr/local/sbin/kamailio -f /usr/local/etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.pid -m 64 -M 4 -u root -g kamailio root@corex-mc1s:/usr/local/src/kamailio-4.1/kamailio# ls -la /var/log/kamailio/|grep "10:" drwxrwxrwx 2 root root 4096 déc. 11 10:49 . -rw-r--r-- 1 root kamailio 194 déc. 11 10:49 acc_1.log -rw-r--r-- 1 root kamailio 9764471 déc. 9 10:30 T201312051212_131.CFT -rw-r--r-- 1 root kamailio 1305022 déc. 11 10:44 T201312110910_129.CFT -rw-r--r-- 1 root kamailio 1302007 déc. 11 10:44 T201312110910_130.CFT -rw-r--r-- 1 root kamailio 1347304 déc. 11 10:44 T201312110910_131.CFT -rw-r--r-- 1 root kamailio 1302961 déc. 11 10:44 T201312110910_132.CFT -rw-r--r-- 1 root kamailio 136259 déc. 11 10:44 T201312110910_133.CFT -rw-r--r-- 1 root kamailio 130057 déc. 11 10:44 T201312110910_134.CFT -rw-r--r-- 1 root kamailio 130622 déc. 11 10:44 T201312110910_135.CFT -rw-r--r-- 1 root kamailio 129914 déc. 11 10:44 T201312110910_136.CFT -rw-r--r-- 1 root kamailio 234889 déc. 11 10:42 T201312110910_1.CFT -rw-r--r-- 1 root kamailio 89076 déc. 11 10:50 T201312111046_129.CFT -rw-r--r-- 1 root kamailio 86649 déc. 11 10:50 T201312111046_130.CFT -rw-r--r-- 1 root kamailio 88435 déc. 11 10:50 T201312111046_131.CFT -rw-r--r-- 1 root kamailio 80389 déc. 11 10:50 T201312111046_132.CFT -rw-r--r-- 1 root kamailio 1310 déc. 11 10:50 T201312111046_133.CFT -rw-r--r-- 1 root kamailio 1522 déc. 11 10:50 T201312111046_134.CFT -rw-r--r-- 1 root kamailio 1377 déc. 11 10:48 T201312111046_135.CFT -rw-r--r-- 1 root kamailio 1160 déc. 11 10:48 T201312111046_136.CFT On Wed, Dec 11, 2013 at 10:13 AM, Abdelkader Allam <abdelkader.allam@gmail.com <mailto:abdelkader.allam@gmail.com>> wrote: 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-586099@FRASBC02.archway.net <mailto:87111681-3595741897-586099@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-586099@FRASBC02.archway.net <mailto:87111681-3595741897-586099@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 <miconda@gmail.com <mailto:miconda@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 <miconda@gmail.com <mailto:miconda@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 <miconda@gmail.com <mailto:miconda@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 list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -http://www.asipto.com http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> -http://www.linkedin.com/in/miconda _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org <mailto:sr-users@lists.sip-router.org> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla -http://www.asipto.com http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> -http://www.linkedin.com/in/miconda
-- Daniel-Constantin Mierla -http://www.asipto.com http://twitter.com/#!/miconda <http://twitter.com/#%21/miconda> -http://www.linkedin.com/in/miconda