Changes between Initial Version and Version 1 of Old/Documentation/OTG/Measurement/DatabaseProcess


Ignore:
Timestamp:
Oct 14, 2005, 8:13:15 PM (19 years ago)
Author:
zhibinwu
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Old/Documentation/OTG/Measurement/DatabaseProcess

    v1 v1  
     1
     2== Perl Script to Dump Database ==
     3
     4Here we provide a script to dump desirable information from the database.
     5
     6The script did:
     7 * dump the sender-side table and receiver-side table from one or more OML database
     8 * count how many records are in each table
     9 * put those number pairs in a file
     10
     11The comparison of those two numbers could give an indication of the packet loss of OTG/OTR application
     12
     13The program take database names as input arguments and save the result in "tempres" file
     14
     15{{{
     16
     17#!/usr/bin/perl
     18
     19# this script read one or more databases and extract how many packets are sent and received respectively.
     20#
     21
     22use Mysql;
     23
     24$hostname = 'idb1.orbit-lab.org';
     25$user     = 'orbit';
     26$database = 'none';
     27$password = 'orbit';
     28$resultfile ='tempres';
     29
     30
     31$table1 = "temp/tx_table";
     32$table2 = "temp/rx_table";
     33
     34$driver   = 'mysql';
     35
     36my $noiselevel = 18;
     37my $now = localtime time;
     38open(res, ">>$resultfile")
     39                || die "Can't open result file: $!\n";
     40print res "$now test with noise level set in $noiselevel dbm \n";
     41close res;
     42
     43foreach(@ARGV)
     44{
     45   dumpDB($_,$table1,$table2);
     46   system("awk 'BEGIN {cnt=0} {cnt =cnt+1} END {printf(\"%d \", cnt) >> \"$resultfile\" }' $table2");
     47   system("awk 'BEGIN {cnt=0} {cnt =cnt+1} END {printf(\"%d \\n\", cnt) >> \"$resultfile\" }' $table1");
     48}
     49
     50print "Done. check tempres file! \n";
     51
     52#we need a subfunction to read 1 database 2 table and dump to two files
     53sub dumpDB
     54{
     55  my ($dbname,$f1, $f2) = @_;
     56  open (OUTFILE1, "> $f1");
     57  open (OUTFILE2, "> $f2");
     58 my $dbh = Mysql->connect($hostname, $dbname, $user, $password);
     59 my $sql_query1="SELECT sequence_no, pkt_seqno, pkt_size_sample_sum, tx_timestamp from sender_otg_senderport";
     60 my $sql_query2="SELECT sequence_no, pkt_seqno, rcvd_pkt_size_sample_sum, xmitrate, rx_timestamp from receiver_otr_receiverport";
     61  my $sth1 = $dbh->query($sql_query1);
     62  while(my @record1 = $sth1->FetchRow) {
     63      print OUTFILE1 "@record1 \n";
     64  }
     65
     66  my $sth2 = $dbh->query($sql_query2);
     67  while(my @record2 = $sth2->FetchRow) {
     68    print OUTFILE2 "@record2 \n";
     69   }
     70  close OUTFILE1;
     71  close OUTFILE2;
     72}
     73                                   
     74
     75
     76
     77}}}