You could just create a cron that exports CDRs from the last 24 hours from the database. Something like:
/usr/bin/mysql -e "select 'Timestamp', 'OutgoingCallerID', 'IncomingDID', 'Destination', 'Duration' union all select calldate as Timestamp, outbound_cnum as OutgoingCallerID, did as IncomingDID, dst as Destination, duration as Duration from cdr where calldate > date_sub(now(), interval 24 HOUR) and did='5551234567' into outfile '/tmp/report.csv' fields terminated by ',' optionally enclosed by '\"'" asteriskcdrdb
echo "$(date --date='yesterday' +'Call Report %Y/%m/%d')" | mutt -s "Call Report" -a /tmp/report.csv -- [email protected]
Just make sure you put your own email address and DID in there.
This is something I’ve wanted to try for a while too. Not sure at this point if I need to try this question somewhere else, as this isn’t even the point of this thread, but Google hasn’t helped me yet and wondered if someone could help.
I tried the command to output to CSV. When I tried to email though it says /tmp/report.csv doesn’t exist. When I re-run the SQL command, it says the file exists. When I try to list all files in /tmp, it isn’t there, and so when I try rm /tmp/report.csv, it of course fails because it can’t find it.
I was only able to re-run the SQL command when I fully rebooted (through System Admin in the GUI). But then ran into the issue again of it not being able to find /tmp/report.csv, and not being able to re-run because it already exists. Odd, but hopefully just missing something obvious.