Beta testers wanted for new CDR report tool (UPDATED)

UPDATE: 2011-08-22, beta2 version released.
UPDATE: 2011-08-11, beta version released.

I have found a new nice report program for Asterisk CDR. It is written by Anthony Joseph Messina, modified by Igor Okunev and it is called Asterisk CDR Viewer.

I rewrote the code into a FreePBX Module. The code is in alpha stage now, there might be some quirks in it that I have not thought about. My tests has been on a rather large CDR database that contains records dated from 2006 up to today with no strange effects.

Download the BETA FreePBX CDR Viewer Upload it via Module Admin.
You will find it in Tools section with the title CDR Viewer.
It will work with FreePBX 2.7 and up.
Note that ticking Concurrent calls and run a report will take some (considerable) time.

Give it some testing and let me know what you think.
What I like to know is Can this module replace the current report tool that FreePBX use today?

In this release only .wav files are supported, that might change in later releases.

It looks pretty neat. Did not appear to break anything on a FreePBX ISO install. I am not sure I am seeing a way to search on DID dialed as to track inbound calls. Then again that might require some other manipulation.

Can you add grouping of numbers in it (Let’s say two companies have one FreePBX server, but the CDR has to be made for two seperate group of numbers)?

Nice addition - I see on the homepage that you can add links to the recordings. The instructions on their website relates to an installation done outside of freepbx. How would I edit (or where would I find it rather) the file that relates to this when installed as a freepbx module?

And has anybody tried linking the sound files already?

Thanks for any input

cosmicwombat: DID will (most likely) be added to 2.10, but that requires a configuration change switching from cdr_mysql for CDR to res_odbc/cdr_adaptive_odbc.conf. By doing that we can add whatever field we want to CDR. This module will be updated when more testing have been done.

black187: Can you elaborate the question?

mlungu: All settings in are now read from FreePBX using the settings that already exists. However, a bug prevents that (my bad).

Hi Mikael,

Uploaded the new one - do you have any idea how I would now see the link to the call recording??

Today I finally had the time to really test on a live environment, there are a few more bugs to sort out. And that is why the module is still in alpha stage:-)

Give me a couple of days to test the link to recordings function and add code so that one can play or download it.

No problem :slight_smile: I know it’s still alpha. I just get excited a bit easily :-). Your modules are highly appreciated!

@mickecarlsson: The idea is - when you click on the CDR viewer, you can choose or make a group, which contains some extensions. And you can then view the CDR records only for the selected/made group.

@black187, oh, I see. Hmmm, let me think about that. No promises made :slight_smile:

I made small changes to support multiple regular expressions separated by a comma in the fields SRC/DST.
For example:
* src = ‘_2XXN, _562., .0075’ - src any of these numbers
* src = '
!2XXN, _562., _.0075’ - src any other than these numbers

If it is normal for you, you can add this changes to the module.

Index: include/

— include/ (revision 50)
+++ include/ (working copy)
@@ -170,7 +170,7 @@
$number = substr($number,1);
} elseif ( ‘_’ == substr($number,0,1) ) {
$number_chars = preg_split(’//’, substr($number,1), -1, PREG_SPLIT_NO_EMPTY);

  •   $number = '^';
  •   $number = '';
      foreach ($number_chars as $chr) {
          if ( $chr == 'X' ) {
              $number .= '[0-9]';

@@ -187,7 +187,6 @@
$_POST[ $source_data .’_mod’ ] = ‘asterisk-regexp’;

  •   $number .= '$';
    return $number;
    Index: index.php
    — index.php (revision 50)
    +++ index.php (working copy)
    @@ -116,7 +116,22 @@
    case “asterisk-regexp”:
  •           $$key = "AND $key $pre_like RLIKE '$val[0]'";
  •           $ast_dids = preg_split('/\s*,\s*/', $val[0], -1, PREG_SPLIT_NO_EMPTY);
  •           $ast_key = '';
  •           foreach ($ast_dids as $did) {
  •               if (strlen($ast_key) > 0 ) {
  •                   if ( $pre_like == ' NOT ' ) {
  •                       $ast_key .= " and ";
  •                   } else {
  •                       $ast_key .= " or ";
  •                   }
  •                   if ( '_' == substr($did,0,1) ) {
  •                       $did = substr($did,1);
  •                   }
  •               }
  •               $ast_key .= " $key $pre_like RLIKE '^$did\$'";
  •           }
  •           $$key = "AND ( $ast_key )";
          case "begins_with":

Community, please welcome Igor Okunev, the author behind Asterisk CDR Viewer.

@igor_okunev, I have updated FreePBX svn with the above changes.

For those who wants to test out the new feature, download page.cdr.php and and replace those in modules/cdr.
Run amportal chown after the files have been replace to set correct owner for the files.

The CDR Viewer is now released as beta.
Download the BETA FreePBX CDR Viewer Upload it via Module Admin.
You will find it in Tools section with the title CDR Viewer.

In this release you can play recorded calls. NOTE: Only .wav is supported at the moment.

New version seemed to install fine over earlier alpha5 version on FreePBX 2.9 system (FreePBX distro) but on a FreePBX 2.8/Elastix system, when the orange box came up the frog never appeared, nor did any text at all - it just froze at that point (I left it alone for several minutes) and it stayed that way until I closed that page and opened another. I then completely uninstalled the alpha5 version, and tried to install the new version with the same result. All indications are that the install never actually begins.

I re-uploaded alpha5 on that system and it installed without a hitch. Is the new version perhaps limited to FreePBX 2.9 and above?

No, but there are code in it that is PHP 5 only. Hmm, I need to check that before installation.
Could you check the php used in that system that failed? Do it with php -v in a shell?

Thanks for the report, I will try to install it on an Elastix system and see what happens.

Update: Now that I think of it, it must be the update.php scrip that fails, it tries to add a field in the asteriskcdrdb/cdr database/table.
I definitely needs to test that.

php -v

PHP 5.2.17 (cli) (built: Aug 9 2011 20:12:01)
Copyright © 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright © 1998-2010 Zend Technologies

Obviously that’s been updated since the original install (yesterday, in fact, because of the security issue).

I just checked and it did not succeed in adding the field. I wonder if there’s a user/password issue, perhaps?

OK, that pointed me to the solution, could you edit install.php from this:

// Update cdr database with did field
$sql = "SELECT did FROM asteriskcdrdb.cdr";
$confs = $db->getRow($sql, DB_FETCHMODE_ASSOC);

to this:

// Update cdr database with did field
global $db;
$sql = "SELECT did FROM asteriskcdrdb.cdr";
$confs = $db->getRow($sql, DB_FETCHMODE_ASSOC);

I forgot that we always include that from 2.9 and onwards.

This time the orange box came up and it said “Please wait while module actions are performed” and that was it… no frog or other text. It just sits there. Again I totally uninstalled the previous version (even deleted the cdr directory after doing that), uploaded the new version, and made the change you requested.

I decided to try an experiment and added a few debug lines:

// Update cdr database with did field
out(“debug 1”);
global $db;
out(“debug 2”);
$sql = “SELECT did FROM asteriskcdrdb.cdr”;
out(“debug 3”);
$confs = $db->getRow($sql, DB_FETCHMODE_ASSOC);
out(“debug 4”);
if (DB::IsError($confs)) { // no error… Already there

NOTHING appeared in the orange box. So for some reason, it sure looks like the install script isn’t being executed at all. Yet as I say, the older alpha version installs fine (but there is no install.php in that one, it appears)

OK, I will look at it later tonight and install it on an old 2.8 setup. Thanks for the feedback.


You were on the right track, you just needed to swipe a little more code from a similar install.php. THIS worked:

// Update cdr database with did field // global $db; global $amp_conf; if (! function_exists("out")) { function out($text) { echo $text."<br />"; } } $sql = "SELECT did FROM asteriskcdrdb.cdr"; $confs = $db->getRow($sql, DB_FETCHMODE_ASSOC);

Note that JUST adding “global $amp_conf;” did NOT do the trick, so the “out” function thing must have been the key.