Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.

Link a questa pagina di confronto

Entrambe le parti precedenti la revisioneRevisione precedente
Prossima revisione
Revisione precedente
registrazione_chiamate [2009/02/03 11:42] marcoregistrazione_chiamate [2014/07/03 14:57] (versione attuale) – modifica esterna 127.0.0.1
Linea 8: Linea 8:
  
 ==== Moduli Perl ==== ==== Moduli Perl ====
-Una volta installato IndigoPerl entrate nella root e aprite il collegamento al "Perl GUI Package Manager" e controllate la presenza dei seguenti moduli:+Una volta installato IndigoPerl entrate nella root /http://127.0.0.1:<porta configurata nel setup es:8081> e aprite il collegamento al "Perl GUI Package Manager" e controllate la presenza dei seguenti moduli:
  
   * Archive-Tar-1.38   * Archive-Tar-1.38
Linea 29: Linea 29:
  
  
-Se ne manca qualcuno installatelo dal package manager+Se ne manca qualcuno installatelo dal package manager selezionando la repository in alto nel menu a tendina.
  
 ===== Configurazione ===== ===== Configurazione =====
Linea 37: Linea 37:
 Es. Es.
 <AudioOutputPath>C:/tmp</AudioOutputPath> <AudioOutputPath>C:/tmp</AudioOutputPath>
 +
 +==== MySql ====
 +Aggiungente le seguenti table:
 +   CREATE TABLE `recfromservice` (                                                          
 +                  `id` int(11) NOT NULL AUTO_INCREMENT,                                                  
 +                  `timestamp` datetime DEFAULT NULL,                                                     
 +                  `direction` int(11) DEFAULT NULL,                                                      
 +                  `duration` bigint(20) NOT NULL,                                                        
 +                  `localEntryPoint` varchar(255) DEFAULT NULL,                                           
 +                  `localParty` varchar(255) DEFAULT NULL,                                                
 +                  `remoteParty` varchar(255) DEFAULT NULL,                                               
 +                  `filename` varchar(255) DEFAULT NULL,                                                  
 +                  `recPortName` varchar(255) DEFAULT NULL,                                               
 +                  `expiryTimestamp` datetime DEFAULT NULL,                                               
 +                  `service_id` int(11) DEFAULT NULL,                                                     
 +                  `recPort_id` int(11) DEFAULT NULL,                                                     
 +                  `flag_erase` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'aggiunto per salvataggio file',  
 +                  PRIMARY KEY (`id`),                                                                    
 +                  KEY `FKA3B331B251080423` (`recPort_id`),                                               
 +                  KEY `FKA3B331B2C39BFD83` (`service_id`)                                                
 +                ) ENGINE=MyISAM AUTO_INCREMENT=165 DEFAULT CHARSET=latin1 
 +
 +   CREATE TABLE `recservice` (                
 +              `ID` int(11) NOT NULL AUTO_INCREMENT,    
 +              `Timestamp` datetime NOT NULL,           
 +              `RecPort` varchar(255) DEFAULT NULL,     
 +              `RemotePort` varchar(255) DEFAULT NULL,  
 +              PRIMARY KEY (`ID`)                       
 +            ) ENGINE=InnoDB DEFAULT CHARSET=latin1     
 +                               
  
 ==== Script per telefoni Cisco ==== ==== Script per telefoni Cisco ====
-Queste sono le righe da configurare+Queste sono le righe da configurare in PhoneService.pl
  
    ####### Costanti Database     ####### Costanti Database 
-     
    my $database = "oreka";    my $database = "oreka";
-    
    my $hostname = "localhost";    my $hostname = "localhost";
-     
    my $user = "root";    my $user = "root";
-    
    my $password = "123456";    my $password = "123456";
-    
    ###################    ###################
 +
 +Una volta configurato aggiungente il file PhoneService.pl nella cartella apache/htdocs di indigoPerl
 +
 +Configurate il servizio sul CallManager e aggiungetelo ai telefoni interessati
  
 ==== Script per pulizia Database/Cartelle ==== ==== Script per pulizia Database/Cartelle ====
  
-Modificare le seguenti righe:+Modificare le seguenti righe di ClearDB.pl:
  
    #######Costanti File     #######Costanti File 
-    
    #Path di origine dei file, bisogna impostare la stessa cartella impostata in Oreka    #Path di origine dei file, bisogna impostare la stessa cartella impostata in Oreka
-   
    my $origpath = '/Programmi/Apache Software Foundation/Tomcat 5.5/webapps/tmp/';    my $origpath = '/Programmi/Apache Software Foundation/Tomcat 5.5/webapps/tmp/';
-  +   
    #Path di destinazione dei file, deve essere impostata la root di apache    #Path di destinazione dei file, deve essere impostata la root di apache
-    
    my $destpath = '/Programmi/Apache Software Foundation/Tomcat 5.5/webapps';    my $destpath = '/Programmi/Apache Software Foundation/Tomcat 5.5/webapps';
      
    ####### Costanti Database     ####### Costanti Database 
-    
    my $database = "oreka";    my $database = "oreka";
-   
    my $hostname = "10.255.0.19";    my $hostname = "10.255.0.19";
-   
    my $user = "root";    my $user = "root";
-   
    my $password = "123456";    my $password = "123456";
-    
    my $tablePS = "recservice";    my $tablePS = "recservice";
-   
    my $tableOrekaTape = "rectape";    my $tableOrekaTape = "rectape";
-   
    my $tableOrekaSeg = "recsegment";    my $tableOrekaSeg = "recsegment";
-   
    my $tableDef = "recfromservice";    my $tableDef = "recfromservice";
      
 +Copiate il file ClearDB.pl in c:\
 +Aggiungete in operazioni pianificate "//perl.exe c:\ClearDB.pl//" e impostatelo per ripeterlo ogni 5 minuti 
  
 ===== Sorgente Script Perl ===== ===== Sorgente Script Perl =====
  
-==== Servizio per telefoni Cisco ====+==== Servizio per telefoni Cisco (PhoneService.pl) ====
  
    #!/usr/bin/perl    #!/usr/bin/perl
-    
    ###################################################################################    ###################################################################################
-    
    # Created by: Marco Longo, marchrist85@gmail.com    # Created by: Marco Longo, marchrist85@gmail.com
-    
    # Created by: Ergon2000, www.ergon2000.it    # Created by: Ergon2000, www.ergon2000.it
-    
    # Date: 03/02/2009    # Date: 03/02/2009
-   +   # Name: PhoneService.pl
    ##############################    ##############################
-    
    #Questo script riceve una richiesta http da un telefono cisco, ne legge l'ip e si connette alla pagina xml StreamingStatisticsX generata dal telefon    #Questo script riceve una richiesta http da un telefono cisco, ne legge l'ip e si connette alla pagina xml StreamingStatisticsX generata dal telefon
-    
    #da essa ricava l'indirizzo e la porta del sorgente della conversazione e l'indirizzo e la porta del destinatario, questi dati vengono registrati su    #da essa ricava l'indirizzo e la porta del sorgente della conversazione e l'indirizzo e la porta del destinatario, questi dati vengono registrati su
-    
    #un database mysql con il relativo timestamp     #un database mysql con il relativo timestamp 
-    
    ####################################################################################    ####################################################################################
-    
-    
-    
        
        
    use Cisco::IPPhone;     use Cisco::IPPhone; 
-    
    use XML::Simple;    use XML::Simple;
-    
    use LWP::Simple;    use LWP::Simple;
-    
    use Data::Dumper;    use Data::Dumper;
-    
    # use strict;    # use strict;
-    
    use DBI;    use DBI;
-    
    $|++;    $|++;
-    
    use CGI;    use CGI;
-    
-    
        
    ####### Costanti Database     ####### Costanti Database 
-    
    my $database = "oreka";    my $database = "oreka";
-    
    my $hostname = "localhost";    my $hostname = "localhost";
-    
    my $user = "root";    my $user = "root";
-    
    my $password = "123456";    my $password = "123456";
-    
    ###################    ###################
-    
-    
        
    ###Carico pagina web e prendo indirizzo ip client    ###Carico pagina web e prendo indirizzo ip client
-    
-    
-    
    my $cgi = CGI->new;    my $cgi = CGI->new;
-    
    map { "$_\t$ENV{$_}\n" } keys %ENV ;    map { "$_\t$ENV{$_}\n" } keys %ENV ;
-    
    my $remoteip = $ENV{'REMOTE_ADDR'};    my $remoteip = $ENV{'REMOTE_ADDR'};
-    
-    
        
    ###############################    ###############################
-    
    # my $count = 0;    # my $count = 0;
-    
    my $response;    my $response;
-    
-    
-    
    ####Recupero dati conversazione######    ####Recupero dati conversazione######
-    
    my $url = "http://$remoteip/StreamingStatisticsX";   #da modificare     my $url = "http://$remoteip/StreamingStatisticsX";   #da modificare 
-    
    my $response = get($url);    my $response = get($url);
-    
    $response =~ s///;    #Sostituisco    $response =~ s///;    #Sostituisco
-    
-   # while ($response = get($url) or $count == 10){ 
-    
-               # $response = get($url); 
-    
-               # $count = $count + 1; 
-    
-   # } 
        
    my $xs = XML::Simple->new(ForceArray => 1, KeepRoot => 1, KeyAttr=>[]);    my $xs = XML::Simple->new(ForceArray => 1, KeepRoot => 1, KeyAttr=>[]);
-    
    my $tmp = eval { $xs->XMLin($response)};    my $tmp = eval { $xs->XMLin($response)};
-    
-   # if ($@) { 
-    
-     # while ($@){ 
-    
-    # my $tmp = eval { $xs->XMLin($response)}; 
-    
-          # } 
-    
-   # } 
-    
    my $localip = @{$tmp -> {StreamingStatistics}}[0]->{LocalAddr}[0];    my $localip = @{$tmp -> {StreamingStatistics}}[0]->{LocalAddr}[0];
-    
    my $remoteip = @{$tmp -> {StreamingStatistics}}[0]->{RemoteAddr}[0];    my $remoteip = @{$tmp -> {StreamingStatistics}}[0]->{RemoteAddr}[0];
-    
    my $message = "registrazione In Corso";    my $message = "registrazione In Corso";
-    
    #################################    #################################
        
Linea 207: Linea 162:
        
    ##############    ##############
-    
-    
    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
-    
    my $timestamp = ($year+1900) ."-". ($month+1) ."-". $mday ." ". $hour .":". $min .":". $sec;     my $timestamp = ($year+1900) ."-". ($month+1) ."-". $mday ." ". $hour .":". $min .":". $sec; 
-    
-    
-    
-   # print ($tmp); 
-    
-   # print Dumper($tmp); 
-    
-    
        
    ##### Inserisco dati nel DB ######    ##### Inserisco dati nel DB ######
        
    $localip =~ s/\//,/;    #Sostituisco / con ,    $localip =~ s/\//,/;    #Sostituisco / con ,
-    
    $remoteip =~ s/\//,/;    $remoteip =~ s/\//,/;
-    
-    
        
    my $dbh = DBI->connect("DBI:mysql:dbname=$database;host=$hostname",$user,$password,{'RaiseError' => 1});    my $dbh = DBI->connect("DBI:mysql:dbname=$database;host=$hostname",$user,$password,{'RaiseError' => 1});
-    
    $dbh->do("INSERT INTO recservice (timestamp, recport, remoteport)VALUES (\"$timestamp\",\"$localip\",\"$remoteip\")") or $message ="Registrazione fallita, riprovare" ;    $dbh->do("INSERT INTO recservice (timestamp, recport, remoteport)VALUES (\"$timestamp\",\"$localip\",\"$remoteip\")") or $message ="Registrazione fallita, riprovare" ;
-    
    $dbh ->disconnect();    $dbh ->disconnect();
-    
-    
-    
        
    #my $sth = $dbh->prepare("INSERT INTO recservice VALUES ($timestamp,$localip)") or die(mysql_error());    #my $sth = $dbh->prepare("INSERT INTO recservice VALUES ($timestamp,$localip)") or die(mysql_error());
-    
    #$sth ->execute();    #$sth ->execute();
-    
-    
        
    my $mytext = new Cisco::IPPhone;    my $mytext = new Cisco::IPPhone;
-    
    $mytext->Text({ Title => "Registrazione", Prompt => $remoteip, Text => "Registrazione in corso" });    $mytext->Text({ Title => "Registrazione", Prompt => $remoteip, Text => "Registrazione in corso" });
-    
    $mytext->AddSoftKeyItem( { Name => "Exit", URL => "SoftKey:Exit", Position => "2" });    $mytext->AddSoftKeyItem( { Name => "Exit", URL => "SoftKey:Exit", Position => "2" });
-    
    print $mytext->Content;    print $mytext->Content;
  
-==== Servizio temporizzato per pulire database e cartella ====+==== Servizio temporizzato per pulire database e cartella (ClearDB.pl) ====
  
    #!/usr/bin/perl    #!/usr/bin/perl
-    
    ###################################################################################    ###################################################################################
-    
    # Created by: Marco Longo, marchrist85@gmail.com    # Created by: Marco Longo, marchrist85@gmail.com
-    
    # Created by: Ergon2000, www.ergon2000.it    # Created by: Ergon2000, www.ergon2000.it
-    
    # Date: 03/02/2009    # Date: 03/02/2009
-   +   # Name: clearDB.pl
    ##############################    ##############################
        
-       
    use DBI;    use DBI;
-    
    use strict;    use strict;
-    
    use File::Copy;    use File::Copy;
-    
    use File::Path;    use File::Path;
-    
    use File::Remove 'remove';    use File::Remove 'remove';
-    
-    
        
    #######Costanti File     #######Costanti File 
-    
    my $origpath = '/Programmi/Apache Software Foundation/Tomcat 5.5/webapps/';    my $origpath = '/Programmi/Apache Software Foundation/Tomcat 5.5/webapps/';
-    
    my $destpath = '/Programmi/Apache Software Foundation/Tomcat 5.5/webapps/tmp/';    my $destpath = '/Programmi/Apache Software Foundation/Tomcat 5.5/webapps/tmp/';
-    +      
-   #$origpath =~ s/ /\\ /g; +
-    +
-   #$destpath =~ s/ /\\ /g; +
-    +
-   +
    ####### Costanti Database     ####### Costanti Database 
-    
    my $database = "oreka";    my $database = "oreka";
-    
    my $hostname = "10.255.0.19";    my $hostname = "10.255.0.19";
-    
    my $user = "root";    my $user = "root";
-    
    my $password = "123456";    my $password = "123456";
-    
    my $tablePS = "recservice";    my $tablePS = "recservice";
-    
    my $tableOrekaTape = "rectape";    my $tableOrekaTape = "rectape";
-    
    my $tableOrekaSeg = "recsegment";    my $tableOrekaSeg = "recsegment";
-    
    my $tableDef = "recfromservice";    my $tableDef = "recfromservice";
-    
    ###################    ###################
-    
        
    my @row;    my @row;
-    
    my @rowdbrec;    my @rowdbrec;
-    +       
-    +
-   +
    ######################################## Lavoro sul DB ######    ######################################## Lavoro sul DB ######
        
    my $dbh = DBI->connect("DBI:mysql:dbname=oreka;host=$hostname",$user,$password,{'RaiseError' => 1}) or die "Can't connect to database: $DBI::errstr!";    my $dbh = DBI->connect("DBI:mysql:dbname=oreka;host=$hostname",$user,$password,{'RaiseError' => 1}) or die "Can't connect to database: $DBI::errstr!";
-    
    my $sth = $dbh->prepare("SELECT * FROM $tablePS") or die "Can't prepare SQL statement: $DBI::errstr\n";    my $sth = $dbh->prepare("SELECT * FROM $tablePS") or die "Can't prepare SQL statement: $DBI::errstr\n";
-    
    $sth -> execute() or die "Can't execute SQL statement: $DBI::errstr\n";    $sth -> execute() or die "Can't execute SQL statement: $DBI::errstr\n";
-    
        
    #$query_handle->bind_columns(undef, \$id, \$timestamp, \$recport);    #$query_handle->bind_columns(undef, \$id, \$timestamp, \$recport);
-    
-    
    while(@row = $sth->fetchrow_array()) {    while(@row = $sth->fetchrow_array()) {
 +       my $dbrec = $dbh->prepare("SELECT * FROM $tableOrekaTape WHERE (recPortName = \"@row[2]\" OR recPortName = \"@row[3]\") AND timestamp <= \"$row[1]\" AND expirYTimeStamp >= \"$row[1]\" ");
        
- my $dbrec = $dbh->prepare("SELECT * FROM $tableOrekaTape WHERE (recPortName = \"@row[2]\" OR recPortName = \"@row[3]\") AND timestamp <= \"$row[1]\" AND expirYTimeStamp >= \"$row[1]\" "); +   #my $dbrec = $dbh->prepare("SELECT * FROM $tableOrekaTape WHERE recPortName = \"10.255.0.19,24588\" AND timestamp <= \"2009-01-09 15:52:15\" AND expirYTimeStamp >= \"2009-01-09 15:52:15\" ");
-    +
-   my $dbrec = $dbh->prepare("SELECT * FROM $tableOrekaTape WHERE recPortName = \"10.255.0.19,24588\" AND timestamp <= \"2009-01-09 15:52:15\" AND expirYTimeStamp >= \"2009-01-09 15:52:15\" ");+
        
-    $dbrec -> execute();+   $dbrec -> execute();
        
-    @rowdbrec = $dbrec ->fetchrow_array;+   @rowdbrec = $dbrec ->fetchrow_array;
        
     $dbh->do("INSERT INTO $tableDef (id, timestamp, direction, duration, localEntryPoint, localParty, remoteParty, filename, recPortName, expiryTimestamp, service_id, recPort_id)VALUES (\"@rowdbrec[0]\",\"@rowdbrec[1]\",\"@rowdbrec[2]\",\"@rowdbrec[3]\",\"@rowdbrec[4]\",\"@rowdbrec[5]\",\"@rowdbrec[6]\",\"@rowdbrec[7]\",\"@rowdbrec[8]\",\"@rowdbrec[9]\",\"@rowdbrec[10]\",\"0\")");     $dbh->do("INSERT INTO $tableDef (id, timestamp, direction, duration, localEntryPoint, localParty, remoteParty, filename, recPortName, expiryTimestamp, service_id, recPort_id)VALUES (\"@rowdbrec[0]\",\"@rowdbrec[1]\",\"@rowdbrec[2]\",\"@rowdbrec[3]\",\"@rowdbrec[4]\",\"@rowdbrec[5]\",\"@rowdbrec[6]\",\"@rowdbrec[7]\",\"@rowdbrec[8]\",\"@rowdbrec[9]\",\"@rowdbrec[10]\",\"0\")");
-    
        
    ###############Lavoro su i file    ###############Lavoro su i file
Linea 356: Linea 248:
     if (move($origpath.@rowdbrec[7],$destpath.@rowdbrec[7]))     if (move($origpath.@rowdbrec[7],$destpath.@rowdbrec[7]))
   {   {
-   
     #se il file esiste e viene spostato     #se il file esiste e viene spostato
-     
     $dbh->do("DELETE FROM $tablePS WHERE ID = \"$row[0]\"") or die "impossibile eseguire query: $DBI::errstr!";     $dbh->do("DELETE FROM $tablePS WHERE ID = \"$row[0]\"") or die "impossibile eseguire query: $DBI::errstr!";
     print (@rowdbrec[0]);     print (@rowdbrec[0]);
     #$dbh->do("DELETE FROM $tableOrekaTape WHERE id = \"$@rowdbrec[0]\"") or die "impossibile eseguire query: $DBI::errstr!";     #$dbh->do("DELETE FROM $tableOrekaTape WHERE id = \"$@rowdbrec[0]\"") or die "impossibile eseguire query: $DBI::errstr!";
-     
     }     }
     else     else
     {     {
-    #se il file non esiste+  #se il file non esiste
     print ("file inesistente");     print ("file inesistente");
     }     }
Linea 378: Linea 267:
       if $DBI::err;       if $DBI::err;
              
-    
    my $sec; my $min;my $hour;my $mday;my $month; my $year; my $wday;my $yday; my$isdst;    my $sec; my $min;my $hour;my $mday;my $month; my $year; my $wday;my $yday; my$isdst;
-    +     ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst)=localtime(time);
-   ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst)=localtime(time); +
-   +
    my $timestamp = ($year+1900) ."-". ($month+1) ."-". $mday ." ". $hour .":". ($min -5).":". $sec;     my $timestamp = ($year+1900) ."-". ($month+1) ."-". $mday ." ". $hour .":". ($min -5).":". $sec; 
-    
        
    ########################Cancellazione File inutili    ########################Cancellazione File inutili
        
    $sth = $dbh->prepare("SELECT filename FROM $tableOrekaTape WHERE id NOT IN (SELECT id FROM $tableDef) AND timestamp < \"$timestamp\"") or die "Can't prepare SQL statement: $DBI::errstr\n";    $sth = $dbh->prepare("SELECT filename FROM $tableOrekaTape WHERE id NOT IN (SELECT id FROM $tableDef) AND timestamp < \"$timestamp\"") or die "Can't prepare SQL statement: $DBI::errstr\n";
-    
    $sth -> execute() or die "Can't execute SQL statement: $DBI::errstr\n";    $sth -> execute() or die "Can't execute SQL statement: $DBI::errstr\n";
-    
    while(@row = $sth->fetchrow_array()) {    while(@row = $sth->fetchrow_array()) {
-    
    remove($origpath.@row[0] );    remove($origpath.@row[0] );
        
-    
    ################################    ################################
        
        
    #####################Pulisco Database    #####################Pulisco Database
-    +      $dbh->do("DELETE FROM $tableOrekaTape WHERE id NOT IN (SELECT id FROM $tableDef) AND timestamp < \"$timestamp\"") or die "impossibile eseguire query: $DBI::errstr!"; 
-   $dbh->do("DELETE FROM $tableOrekaTape WHERE id NOT IN (SELECT id FROM $tableDef) AND timestamp < \"$timestamp\"") or die "impossibile eseguire query: $DBI::errstr!"; +      $dbh->do("DELETE FROM $tableOrekaSeg WHERE rectape_id NOT IN (SELECT id FROM $tableOrekaTape) AND timestamp < \"$timestamp\"") or die "impossibile eseguire query: $DBI::errstr!";
-    +
-   $dbh->do("DELETE FROM $tableOrekaSeg WHERE rectape_id NOT IN (SELECT id FROM $tableOrekaTape) AND timestamp < \"$timestamp\"") or die "impossibile eseguire query: $DBI::errstr!"; +
-   +
    ################################    ################################
-    
        
    $dbh ->disconnect or warn "Error disconnecting: $DBI::errstr\n";    $dbh ->disconnect or warn "Error disconnecting: $DBI::errstr\n";
-    
    ######################################## Fine Lavoro sul DB ######    ######################################## Fine Lavoro sul DB ######
-    +     
-   +
    exit;    exit;