mysql -u USER -pPASSWORD -D asteriskcdrdb -e “SELECT YEAR(calldate) as Year, MONTH(calldate) AS Month, DAY(calldate) as Day, COUNT(*) as calls, SUM(duration) as seconds, dst as DID from cdr WHERE dst REGEXP ‘^[0-9][0-9][0-9][0-9]$|^V$’ group by year, month, day, dst ;”
make sure your REGEXP covers all the “endpoints” (this example all 4 digit numbers, and voicemail) your DID’s land on, a little more work and you can map the endpoints to DID’s (inbound routes) directly from the asterisk.incoming table fields extension to destination, depending on yiour setup. (The association of extensions (DID) to answering point is not simple in FreePBX)
Not that I know of. (The association of extensions (DID) to answering point is not simple in FreePBX), further what a “call” is considered by the CDR engine equally unsimple. But anything is possible if you want to rewrite the code.
mysql -H -u USER -pPASSWORD -e "SELECT DATE_FORMAT(calldate,’%b %D, %Y - %a ‘) as Date,COUNT(*) as Calls, CEIL(SUM(duration)/60) as Minutes, extension as DID, SUBSTRING_INDEX(destination ,’,’,1) as Destination, dst as EndPoint,description as Description FROM asterisk.incoming DID LEFT JOIN asteriskcdrdb.cdr CDR ON DID.destination=CONCAT(CDR.dcontext,’,’,CDR.dst,’,1’) WHERE calldate > ADDDATE(DATE(now()), INTERVAL -1 MONTH) GROUP by YEAR(calldate), MONTH(calldate), DAY(calldate),DID " > /var/www/html/admin/DIDusage.html
With the caveat that CDR’s are ‘really messed up’ in Asterisk/FreePBX and thus the numbers may be misleading, there is a group by option in the call reports module.
We’ve added DIDs (in 2.10 or was that 2.11?) but … I noticed that grouping by DIDs is not one of the pull down options.
I suspect if you open a ticket as a reminder it would be fairly trivial to add in though it’ll be in 2.11 that it gets added. But do get the ticket in to help us remember.
Sorry, Elastix decided a couple of years ago to go their own way with their hacked up old FreePBX 2.8. You are on your own, think about moving to a mainline distro before Elastix drop FreePBX altogether in their version 3
Unless I am totally wrong, my mysql query should solidly and effectively tie all your DID calls to the endpoint they were directed to by associating asterisk.inbound to asteriskcdrdb.cdr.dst , it works for me on old Elastix Boxii I still have working.
The only reason why I’m sticking with Elastix is their callcenter applet that’s so easily integrated and various other goodies.
I have a PIAF box ready to be deployed tho - just waiting on moving everything over from the 2.8 Elastix settings to 2.9 PIAF.
Hm, not sure why mine isn’t working. I was too excited cuz the format is just simply perfect. Just shows a few things out of the full list of DIDs - http://postimage.org/image/kbthusluz/
Well. you can post what I asked for, I assume that no-one called those numbers or those asterisk.incoming DID is not covered. Sorry , I’m not a mind-reader.
Then you have run into the “not-simple” problem when you use the second derivative “timeconditions” which need another JOIN into another mysql table probably quite simple but you are on your own from here, I suggest you upgrade to a legitimate FreePBX while you wait for Philippe’s patches to be applied to that legitimacy.