[asterisk-users] How to roll-over / move / rotate an Asterisk Master.csv call detail record (CDR) file every 15 minutes

Paul Belanger paul.belanger at polybeacon.com
Tue Dec 4 22:48:45 CST 2012


On 12-12-04 01:05 PM, Earl Ruby wrote:
> Paul:
>
> Four reasons not to use logrotate:
>
> 1. logrotate does not provide log rotation every 15 minutes.
>
Sure it does, you can invoke it using crontab, like you do for your script.

> 2. logrotate will not create unique file names unless you use a date
> format in the name (file names with a .nnn extension get reused over
> time), but since logrotate only supports YYYYMMDD, not hours, minutes,
> or seconds, once again you're limited to daily roll-overs.
> (asterisk-cdr-rollover generates file names using the format
> cdr-YYYYMMDDHHMISS.csv.)
>
Not so, logroate actually supports strftime %s, so you get the number of 
seconds since the Epoch.  Easily converted into any datetime format you 
wish.

> 3. My customers need to be able to feed CDR files into a telecom
> billing, monitoring, fraud-detecting system I work on called WebCDR.com,
> which works best if it gets a new CDR file every fifteen minutes.
>
postrotate/endscript should work for this.

> 4. If there are no calls after 15 minutes, with asterisk-cdr-rollover I
> get a zero byte file, which can trigger a "no calls" alarm, alerting me
> that something is wrong with the Asterisk switch. (The switch setup I'm
> working will always have some calls within a 15 minute block if
> everything is working correctly, although people with less-busy switches
> can always configure a larger alarm window to suit their situations.) If
> you're running a high-traffic switch, this can be a life-saver.
>
No native support, but you could invoke logic using postrotate/endscript 
from above.

> If you want a copy, go to
> https://github.com/earlruby/asterisk-cdr-rollover and click the ZIP
> button to download the script and cron job. It's free.
>
Understood.  If it works for you that is great, I was mostly trying to 
understand why you choose to rewrite logrotate :)

-- 
Paul Belanger | PolyBeacon, Inc.
Jabber: paul.belanger at polybeacon.com | IRC: pabelanger (Freenode)
Github: https://github.com/pabelanger | Twitter: 
https://twitter.com/pabelanger



More information about the asterisk-users mailing list