Entrambe le parti precedenti la revisioneRevisione precedenteProssima revisione | Revisione precedente |
registrazione_chiamate [2009/02/03 11:52] – marco | registrazione_chiamate [2014/07/03 14:57] (versione attuale) – modifica esterna 127.0.0.1 |
---|
| |
==== 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 $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 |
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: 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 |
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 |
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"); |
} | } |
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; |