How-To: Send out CDRs (via email)

Hi SangomaOS Team:

I did see a rather old post from 2016 about this, but I want to ask to see if something more current is available.

Do you know an easy-enough way for us to

Setup the CDR module to EMAIL out the CDR for one of the phone numbers the PBX has as an inbound route?

This would be easier than opening up the PBX (for) staff to login and view the CDR module because most staff are remote from the premise based PBX.

Is there a commercial module which would allow a daily email of a custom CDR for just one of the inbound route phone numbers?

Thanks for your tips.

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.

image

image

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.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.