TIPS Generate daily report for inbound calls

Bill Clarke

New Member
Joined
Dec 26, 2018
Messages
4
Reaction score
0
I need to set up a daily email including all inbound calls, there destination or extension transferred to, and if the call was answered or went to VM. Is this possible?
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,206
Reaction score
5,229
Here's the script that we run from /etc/crontab every day:
Code:
#!/bin/bash
mysql -u root -ppassw0rd asteriskcdrdb -e 'SELECT calldate, clid FROM cdr WHERE DATE(calldate) = SUBDATE(CURDATE(), 1) AND did <> ""'
 

Bill Clarke

New Member
Joined
Dec 26, 2018
Messages
4
Reaction score
0
Here's the script that we run from /etc/crontab every day:
Code:
#!/bin/bash
mysql -u root -ppassw0rd asteriskcdrdb -e 'SELECT calldate, clid FROM cdr WHERE DATE(calldate) = SUBDATE(CURDATE(), 1) AND did <> ""'


Ok what fields do I need to alter each day
 

Bill Clarke

New Member
Joined
Dec 26, 2018
Messages
4
Reaction score
0
Here's the script that we run from /etc/crontab every day:
Code:
#!/bin/bash
mysql -u root -ppassw0rd asteriskcdrdb -e 'SELECT calldate, clid FROM cdr WHERE DATE(calldate) = SUBDATE(CURDATE(), 1) AND did <> ""'


Can I get an example pls.
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,206
Reaction score
5,229
Don't alter anything. It will retrieve calls from the previous day.
 
Last edited:

dmcgrandle

New Member
Joined
Apr 1, 2019
Messages
1
Reaction score
0
Here is what I got working. I created a new file 'daily-report' in /root like this:

Code:
#!/bin/bash
(
echo "From: PBX <[email protected]>";
echo "To: Admin <[email protected]>";
echo "Subject: Yesterday's Call Report";
echo "MIME-Version: 1.0";
echo "Content-Type: text/html";
echo "Content-Disposition: inline";
echo "<html>"
echo "<body>"
echo "<pre style=\"font: monospace\">"
mysql -u root -ppassw0rd asteriskcdrdb -t -e 'SELECT calldate AS Timestamp, clid AS CallerID, did as DID, dst AS Destination, disposition AS Disposition, duration AS Duration FROM cdr WHERE DATE(calldate) = SUBDATE(CURDATE(), 1) AND did <> ""'
echo "</pre>";
echo "</body>";
echo "</html>";
) | sendmail -t

Then I added the following to /etc/crontab to make it run every night at 12:40am:

Code:
40 0 * * * root /root/daily-report > /dev/null 2>&1

I hope this helps someone. Note - it will send a blank email if there were no calls the previous day.
 

krzykat

Telecom Strategist
Joined
Aug 2, 2008
Messages
3,149
Reaction score
1,238
Don't alter anything. It will retrieve calls from the previous day.

Ward, this is great, but it will not give accurate results for number of inbound calls if you don't have a 1-1 relationship to where the call goes. For example, if you have a ring group, it will show multiple records for one inbound call. Is there a way to limit this to one record per uniqueid so that a more representative answer is given?
 

krzykat

Telecom Strategist
Joined
Aug 2, 2008
Messages
3,149
Reaction score
1,238
I think this will get it:


mysql -u root -ppassw0rd asteriskcdrdb -e 'SELECT calldate, clid FROM cdr WHERE DATE(calldate) = SUBDATE(CURDATE(), 1) AND did <> "" GROUP BY uniqueid'
 

Members online

Forum statistics

Threads
25,825
Messages
167,856
Members
19,250
Latest member
mark-curtis
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top