Monitoring 2.0 for Elastix 1.6

Discussion in 'General' started by randallflagg, Dec 1, 2010.

  1. randallflagg

    Joined:
    Oct 13, 2010
    Messages:
    16
    Likes Received:
    0
    IN HERE ( THIS POST ) IS ANOTHER VERSION OF THIS MODULE THAT SHOULD WORK FINE


    Hello to everyone.
    I wanted to share with you guys what I was working on in latelly.
    Since the actual Monitoring Module in the Elastix 1.6 sucks bad for any developer who wanted to add something, here, I made some modifications to the Monitoring Module from the Elastix 2.0 to work in the 1.6.
    (Why 1.6? Because is the more stable one of all the Elastix)

    First, DON'T TRY THIS JUST LIKE THAT WITHOUT BACKING UP YOUR ORIGINAL VERSION OF MONITORING MODULE..

    I downloaded the Monitoring 2.0 (from now on MON2.0) module and replace the actual one. Obviously that didn't worked, but after adding and tweaking the necessary stuffs, It worked!.
    First and very important, the module has at the begining (index.php) a
    Code:
    //error_reporting(E_ALL);
    //ini_set('display_errors', '1');
    in any case, just uncomment that and see what could your problem be if you have some.

    The major modifications are in: index.php and libs/paloSantoMonitoring.class.php.
    In paloSantoMonitoring.class I had to add some functions that are native in the Elastix 2.0 in order for this module to work.
    Code:
    /**
     * Función para construir un DSN para conectarse a varias bases de datos 
     * frecuentemente utilizadas en Elastix. Para cada base de datos reconocida, se
     * busca la clave en /etc/elastix.conf o en /etc/amportal.conf según corresponda.
     *
     * @param   string  $sNombreUsuario     Nombre de usuario para interrogar
     * @param   string  $sNombreDB          Nombre de base de datos para DNS
     * @param   string  $ruta_base          Ruta base para inclusión de librerías
     *
     * @return  mixed   NULL si no se reconoce usuario, o el DNS con clave resuelta
     */
    function generarDSNSistema($sNombreUsuario, $sNombreDB, $ruta_base='')
    {
        require_once $ruta_base.'libs/paloSantoConfig.class.php';
        switch ($sNombreUsuario) {
        case 'root':
            $sClave = obtenerClaveConocidaMySQL($sNombreUsuario);
            if (is_null($sClave)) return NULL;
            return 'mysql://root:'.$sClave.'@localhost/'.$sNombreDB;
        case 'asteriskuser':
            $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*");
            $listaParam = $pConfig->leer_configuracion(FALSE);
            return $listaParam['AMPDBENGINE']['valor']."://".
                   $listaParam['AMPDBUSER']['valor']. ":".
                   $listaParam['AMPDBPASS']['valor']. "@".
                   $listaParam['AMPDBHOST']['valor']. "/".$sNombreDB;
        }
        return NULL;
    }
    
    
    /**
    * Funcion que sirve para obtener los valores de los parametros de los campos en los
    * formularios, Esta funcion verifiva si el parametro viene por POST y si no lo encuentra
    * trata de buscar por GET para poder retornar algun valor, si el parametro ha consultar no
    * no esta en request retorna null.
    *
    * Ejemplo: $nombre = getParameter('nombre');
    */
    function getParameter($parameter)
    {
        if(isset($_POST[$parameter]))
            return $_POST[$parameter];
        else if(isset($_GET[$parameter]))
            return $_GET[$parameter];
        else
            return null;
    }
    Now, a problem I had is the recorded files, so I added a function that I know I should be better and improved, but for now I don't know how.
    NOTICE: This function is NOT YET WORKING for predictive calls, so it may bring you trouble from time to time.
    Code:
    /**
    * Funcion que sirve para obtener los archivos de descarga. 
    * Se forma la url gracias al uniqueid de los usuarios macheandolos contra la base de datos de asterisk misma.
    *
    *
    **/
    
    function getRecordedFile($uniqueid){
    		$qr = "Select calldate, channel from cdr where uniqueid='$uniqueid'";
    		//echo $qr;
            $result = $this->_DB->getFirstRowQuery($qr,true);
    		if($result==FALSE){
    			return 'horno';
    		}else{	
    		// Formamos el nombre del archivo para descarga. Este NO sirve para predictivo.
    		
    			if (substr($result['channel'],0,5)=='SIP/l')
    			{
    				$file='';
    			}else{
    				$file='OUT'.substr($result['channel'],4,3).'-';	
    			}
    			$file .= date("Ymd-Gis", strtotime($result['calldate']));
    			$file .= '-'.$uniqueid.'.wav';
    		}
    		//$file = strtotime($result[0]);
    		return $file;
    	}
    }
    
    Since my elastix is in spanish, when I do predictive call he add a "SIP/linea" to the field Channel, so thats the only thing I'm checking there in order to create a name of the file "OUT" or not. This could change in various ways, so yes, this could bring you trouble. (Some help could be awesome!).

    Other thing changed in this Class is everything refering to the "userfield" in the asteriskcdrdb.cdr. Since in Elastix 1.6 I had this field empty always, I changed que query that checks everyhing onto it.

    In the INDEX.php I took out somethings that I didn't needed, but they are just commented, so you could uncomment them and have it again, like the search by type or SIP.
    Again, I took out the "delete call" from the grid, since I don't understand why could someone would want to erase ever a call from elastix.
    Also made the whole module filter full for every user. (If you don't want an user to go throw this, just go to the admin panel and take that user the permission.)

    I'm actually looking for help for this module, since I want to be able to have a good search for predictive calls.
    Hope it helps!
    http://forum.elastix.org/old_files/monitoring2_0_para_ELASTIX1_6.zip

    IN HERE ( THIS POST ) IS ANOTHER VERSION OF THIS MODULE THAT SHOULD WORK FINE
     
  2. bmacias

    Joined:
    Sep 27, 2007
    Messages:
    205
    Likes Received:
    0
    Hola,

    Gracias por meter mano en el codigo elastix . Me parece muy buena iniciativa. En un post a otro tema comence a escribir algo similar, ya note que has visto los ultimos desarrollos del módulo, ahora quisiera conocer mas de tus ideas sobre mejorar la búsqueda de las llamadas predictivo.

    Saludos.

    Bruno Macias
    Coordinador, Desarrollo Elastix.
     
  3. randallflagg

    Joined:
    Oct 13, 2010
    Messages:
    16
    Likes Received:
    0
    Wow, gracias por contestar! =)

    Bueno, el problema que encuentro para las llamadas predictivas es que cuando se usan estas no me lista el numero de destino, sino que el numero de cola. Eso no me sirve tanto que digamos para saber a quien se le llamo en si, y es medio dificl saber con quien se hablo sin comparar los uniqueids.

    Mi idea es poder ver el numero a quien se llamo y tal vez en "tipo" podamos decir que es predictivo con el numero de cola. En este post puse como hacer la query para estirar de otra base de datos a quien se llamo ( Ver link )

    Obvio, para este modulo tengo que ver de pulirlo mucho, como para conseguir mucho mejor la url de las grabaciones.
     
  4. bmacias

    Joined:
    Sep 27, 2007
    Messages:
    205
    Likes Received:
    0
    Hmm,

    Interesante, la forma de obtener los datos del cliente o al que se llamo de otra base. Pudiera ser algo configurable, donde desde un formulario html, se ingrese los parametros de la base y tabla especifica y relacionar el campo del cliente. Seria algo mas generico.

    Bueno es una idea, pero voy a seguir pensado.
     
  5. randallflagg

    Joined:
    Oct 13, 2010
    Messages:
    16
    Likes Received:
    0
    Well, today I'm uploading a new version of the monitoring 2.0(mod) for Elastix 1.6.
    Again DON'T TRY THIS IF YOU'RE NOT SURE OF WHAT YOU'RE DOING. ALWAYS. ALWAYS, ALWAYS MAKE A BACK UP OF YOUR OLDER VERSION BEFORE USING THIS ONE. ALWAYS.

    So, in my previous version I make this module work with the elastix 1.6. Now I have it working really fine, but carefull, there's allot of tunning up to do, so if you don't know how to access the mysql, or how a trigger works, then maybe this could be very advance for you.

    REQUIREMENTS FOR THE MODULE
    Filter by Agent, Origin and Destination of the Call for regular and predictives calls.

    PROBLEM
    Predictives call have no real information to be displayed. Destination call shows the name of the Queue, the number o name of the agent is in another colum of the database and "type" of call isn't working.

    SOLUTION
    (See attached module)

    HOW TO INSTALL MODULE AND MAKE IT WORK
    Step 1: Unzip all the files in your hard drive. You'll see the many files, three of them are a .sql files.
    Step 2: Login to the mysql. If you're in console, use this.
    Code:
    [root@elastix2 ~]# mysql -u root --password=eLaStIx.2oo7
    Step 3: logged in in your mysql, select the database 'asteriskcdrdb'
    Code:
    mysql> use asteriskcdrdb;
    Step 4: run all 3 files in your database (you can copy them in the console and run them). Two .sql work to do mass updates to registries in the cdr table of asteriskcdrdb, the other is a trigger. (More explanation of what all of this does, at the end).
    Step 5: Replace the monitoring module with the new one (the one you unzip). Monitoring is placed in /var/www/html/modules/monitoring.

    Then, everything should work fine. BUT! Remember that my module is in spanish and I just use some stuff in spanish. For example "Queue" is "Cola" for me. (just in case)

    WHAT THIS MODULE DOES
    Remember at all time that the most important information we have for calls is the field "uniqueid" in the asteriskcdrdb database.
    First problem I encountered was the files to listen or download. In the previous version if you try to download any file, this won't work at all. This time I got a simple way to go around this problem and is using the Centos (unix in this case) for my advantage.

    Since the previous way of doing was maybe going to change in some instalations, I decided to use the unix command "locate", and since all the recorded files have the uniqueid in the name of it, then I had my solution, make a search of a file with the locate of linux and retrieve the name of it and use it to build the url in an easer way.
    *Sometimes some files, dunno why, don't have a recorded file. Don't know why.

    That been solved, I went to the filtering part. I couldn't filter agents nor destinations calls for predictive calls because this one give me (in the case of the destination call) the name of the Queue and (in the case of the agent) something that I can use as a report or a search.

    First of all I did that the information I needed was printed well, meaning that in the destinations call for a predictive call I get the real number to whom that agent called.
    I tried using the class of monitoring I have in the class, but when I do a more complex query it just dies. Everything retunrs false and nothing works. (I was trying to do a Sub Select of another database)
    So I ended up NOT using any class for that, but a regular function, which had again the conection parameters and stuff. I know this is VERY wrong, but I couldn't find any solution for SubSelects.

    Anyhow, in the end I ended not using all of this, and with a friend ended up using triggers in the mysql.
    Everytime the asteriskcdrdb.cdr make an insert, the trigger will modify some info replacing the 'cdr.dst' row with the one in the call_center.calls.phone (so in the dst calls I always got the real destination number) and the channel with dstchannel info only for calls that are predictives.

    Turns out that the database call_center in the table calls has the information of to whom the call really went, but the only way to know (or match) with the asteriskcdrdb was through the uniqueid, which are the same in both.
    If you look at the trigger you'll see that I go to the call_center database to retrieve that information. Again, I don't know why some unique ids only exist in the asteriskcdrdb and not in the call_center (but almost never happends).

    In the case of the channel, I put (in case of predictive calls) the dstchannel info in channel, cause thats the only row that have the name or number of the agent who made the call.

    Then theres the masive update .sql that does the same thing that this triggers does, but for the old data. Nothing really fancy, but it works.

    That's it.
    What I don't undertand is why the Asterisk or the Elastix put some messup information in the asteriskcdrdb. There's now precise information there and is really hard to work with it, but anyhow, I hope this works. For me it works really good! http://forum.elastix.org/old_files/Monitoring20_for_Elastix16_MOD.zip
     
  6. elas_cc

    Joined:
    Jun 11, 2010
    Messages:
    3
    Likes Received:
    0
    Hi,
    I would like to add in the "Monitoring List" items with "Dst. Channel", which is available in the 'CDR Report. I created a new column. In the "CDR Report" to be "Dst. Channel" corresponds to the
    Code:
    $ arrTmp [5] = $ cdr [4];
    Code:
    5 => array ('name' => $ arrLang ["Dst. Channel"],
               "property"=> "")
    Code:
    $ cdr [4]
    find a file paloSantoCDR.class.php (line 89)
    Code:
    $ query = "SELECT calldate, src, dst, channel, dstchannel, disposition, UniqueID, duration, billsec, accountcode FROM cdr";
    How to display a parameter dstchannel in module 'Monitoring List "?
     

Share This Page