Changeset 44

Show
Ignore:
Timestamp:
04/11/08 18:52:15 (11 years ago)
Author:
rmcmillen
Message:

Using new calls vice old_update. Reference Ticket #19

Location:
honeywall/trunk/rpm-devel/roo-base
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • honeywall/trunk/rpm-devel/roo-base/roo-base.spec

    r27 r44  
    2424# Version follows CentOS version so yum $releasever works 
    2525Version: 5 
    26 Release: 24.hw 
     26Release: 25.hw 
    2727License: GPL 
    2828Source: %{name}-%{version}.tar.gz 
  • honeywall/trunk/rpm-devel/roo-base/src/dlg/config/purgeDB.pl

    r13 r44  
    5353my $dbpasswd="honey"; 
    5454 
    55 sub old_update($$$){ 
    56    my ($select_statement,$update_statement,$dbh)[email protected]_; 
    57    my $sth; 
    58    my $sth2;   
    59    my $ident1; 
    60    my $ident2; 
    61    my $row_limit=1000; 
    62    my $num_selected=$row_limit*2; 
    63    my $iter=0; 
    64    my $sth; 
    65    my $base; 
    66  
    67  
    68    #$select_statement .= " LIMIT 1000"; 
    69     
    70     
    71    while($num_selected>=$row_limit){ 
    72       $base=$iter*$row_limit; 
    73       $sth="$select_statement  LIMIT $base,$row_limit"; 
    74       #$sth=$dbh->prepare($select_statement) or die "cannot prepare query". $sth->errstr; 
    75       $sth=$dbh->prepare($select_statement) or die "cannot prepare query". $sth->errstr;  
    76       $sth->execute() or die "Cannot execute statement $select_statement\n".$sth->errstr; 
    77       $num_selected=$sth->rows; 
    78       $sth->bind_columns(undef,\$ident1,\$ident2); 
    79  
    80       $sth2=$dbh->prepare($update_statement) or die "cannot prepare query $update_statement\n".$sth2->errstr; 
    81       while($sth->fetch){ 
    82           $sth2->bind_param(1,$ident1,DBI::SQL_INTEGER); 
    83           $sth2->bind_param(2,$ident2,DBI::SQL_INTEGER); 
    84           $sth2->execute() or die "cannot execute statement $update_statement\n".$sth2->errstr; 
    85       } 
    86       $sth2->finish; 
    87       $iter++; 
    88    } 
    89    $sth->finish; 
    90     
    91 } 
    92  
    93  
    9455sub main(){ 
    9556 
    9657   my $dbdays; 
    97    #my $dbdays= `cat $CONFDIR/HwDBDAYS` 
    9858 
    9959   # Check to see if user entered a valid number of days on command line 
     
    10363       $dbdays = $COMMANDARG; 
    10464   } 
     65   chomp($dbdays); 
    10566 
    10667   my $limit=time()-3600*24*$dbdays; 
     
    11778   my $ids_id; 
    11879 
    119    #print("limit=$limit \n"); 
    120  
    121  
    12280   #deletion is made on two steps 
    12381   #step 1 marks what data is to be deleted 
     
    12684   #--------- 
    12785   #step1.a mark ids data based on argus... 
    128    #$sth=$dbh->prepare("UPDATE ids,argus SET ids.to_be_deleted=1 WHERE ids.argus_id=argus.argus_id AND argus.end_sec<$limit") or die "cannot prepare statement for ids". $dbh->errstr; 
    129    #$sth->execute() or die "cannot execute statement".$sth->errstr; 
     86   $sth=$dbh->prepare("UPDATE ids,flow SET ids.to_be_deleted=1 WHERE ids.flow_id=flow.flow_id AND flow.src_end_sec<$limit") or die "cannot prepare statement for ids". $dbh->errstr; 
     87   $sth->execute() or die "cannot execute statement".$sth->errstr; 
    13088   #print("ids marked\n"); 
    131    #$sth->finish; 
    132    old_update("SELECT ids.sensor_id,ids_id FROM ids,flow WHERE flow.sensor_id=ids.sensor_id AND ids.flow_id=flow.flow_id AND flow.src_end_sec<$limit", 
    133               "UPDATE  ids SET to_be_deleted=1  WHERE sensor_id=? and ids_id=?", 
    134                $dbh); 
     89   $sth->finish; 
    13590 
    13691   #step1.b mark process tree based on process... 
    137    #$sth=$dbh->prepare("UPDATE process_tree,process SET process_tree.to_be_deleted=1 WHERE (child_process=process_id OR parent_process=process_id) AND pcap_time_max<$limit") or die "cannot prepare statement for ids". $dbh->errstr; 
    138    #$sth->execute() or die "cannot execute statement".$sth->errstr; 
    139    #print("ids done\n"); 
    140    #$sth->finish; 
    141    old_update("SELECT process_tree.sensor_id,child_process FROM process_tree,process  WHERE (child_process=process_id OR parent_process=process_id) AND pcap_time_max<$limit", 
    142               "UPDATE process_tree SET to_be_deleted=1 WHERE sensor_id=? and child_process=?", 
    143                $dbh); 
     92   $sth=$dbh->prepare("UPDATE process_tree,process SET process_tree.to_be_deleted=1 WHERE (child_process=process_id OR parent_process=process_id) AND pcap_time_max<$limit") or die "cannot prepare statement for ids". $dbh->errstr; 
     93   $sth->execute() or die "cannot execute statement".$sth->errstr; 
     94   #print("process_tree, process done\n"); 
     95   $sth->finish; 
    14496  
    14597   #step1.c mark process to com  ->should it be on the same table? 
    146    #$sth=$dbh->prepare("UPDATE process_to_com,process SET process_to_com.to_be_deleted=1 WHERE process_to_com.process_id=process.process_id AND pcap_time_max<$limit") or die "cannot prepare statement for ids". $dbh->errstr; 
    147    #$sth->execute() or die "cannot execute statement".$sth->errstr; 
    148    #print("ids done\n"); 
    149    #$sth->finish; 
    150  old_update("SELECT process_to_com.sensor_id,process_to_com.process_id FROM process_to_com,process  WHERE process_to_com.sensor_id=process.sensor_id AND process_to_com.process_id=process.process_id AND pcap_time_max<$limit", 
    151               "UPDATE process_to_com SET to_be_deleted=1 WHERE sensor_id=? and process_id=?", 
    152                $dbh); 
     98   $sth=$dbh->prepare("UPDATE process_to_com,process SET process_to_com.to_be_deleted=1 WHERE process_to_com.process_id=process.process_id AND pcap_time_max<$limit") or die "cannot prepare statement for ids". $dbh->errstr; 
     99   $sth->execute() or die "cannot execute statement".$sth->errstr; 
     100   #print("process_to_com, process done\n"); 
     101   $sth->finish; 
    153102 
    154103   #step1.d mark sys_read  
    155    #$sth=$dbh->prepare("UPDATE sys_read,process SET sys_read.to_be_deleted=1 WHERE sys_read.process_id=process.process_id AND pcap_time_max<$limit") or die "cannot prepare statement for ids". $dbh->errstr; 
    156    #$sth->execute() or die "cannot execute statement".$sth->errstr; 
    157    #print("ids done\n"); 
    158    #$sth->finish; 
    159  old_update("SELECT sys_read.sensor_id,sys_read_id  FROM sys_read,process WHERE sys_read.sensor_id=process.sensor_id AND sys_read.process_id=process.process_id AND pcap_time_max<$limit", 
    160               "UPDATE sys_read SET to_be_deleted=1 WHERE sensor_id=? and sys_read_id=?", 
    161                $dbh); 
    162  
    163  
     104   $sth=$dbh->prepare("UPDATE sys_read,process SET sys_read.to_be_deleted=1 WHERE sys_read.process_id=process.process_id AND pcap_time_max<$limit") or die "cannot prepare statement for ids". $dbh->errstr; 
     105   $sth->execute() or die "cannot execute statement".$sth->errstr; 
     106   #print("sys_read, process done\n"); 
     107   $sth->finish; 
    164108 
    165109   #step1.e mark sys_open  
    166    #$sth=$dbh->prepare("UPDATE sys_open,process SET sys_open.to_be_deleted=1 WHERE sys_open.process_id=process.process_id AND pcap_time_max<$limit") or die "cannot prepare statement for ids". $dbh->errstr; 
    167    #$sth->execute() or die "cannot execute statement".$sth->errstr; 
    168    #print("ids done\n"); 
    169    #$sth->finish; 
    170   old_update("SELECT sys_open.sensor_id,sys_open_id  FROM sys_open,process WHERE sys_open.sensor_id=process.sensor_id AND sys_open.process_id=process.process_id AND pcap_time_max<$limit", 
    171               "UPDATE sys_open SET to_be_deleted=1 WHERE sensor_id=? and sys_open_id=?", 
    172                $dbh); 
    173  
    174  
     110   $sth=$dbh->prepare("UPDATE sys_open,process SET sys_open.to_be_deleted=1 WHERE sys_open.process_id=process.process_id AND pcap_time_max<$limit") or die "cannot prepare statement for ids". $dbh->errstr; 
     111   $sth->execute() or die "cannot execute statement".$sth->errstr; 
     112   #print("sys_open, process done\n"); 
     113   $sth->finish; 
    175114 
    176115   #step1.f mark sys_socket   
    177    #$sth=$dbh->prepare("UPDATE sys_socket,process SET sys_socket.to_be_deleted=1 WHERE sys_socket.process_id=process.process_id AND pcap_time_max<$limit") or die "cannot prepare statement for ids". $dbh->errstr; 
    178    #$sth->execute() or die "cannot execute statement".$sth->errstr; 
     116   $sth=$dbh->prepare("UPDATE sys_socket,process SET sys_socket.to_be_deleted=1 WHERE sys_socket.process_id=process.process_id AND pcap_time_max<$limit") or die "cannot prepare statement for ids". $dbh->errstr; 
     117   $sth->execute() or die "cannot execute statement".$sth->errstr; 
    179118   #print("sock_ marked done\n"); 
    180    #$sth->finish; 
    181    old_update("SELECT sys_socket.sensor_id,sys_socket_id  FROM sys_socket,process WHERE sys_socket.sensor_id=process.sensor_id AND sys_socket.process_id=process.process_id AND pcap_time_max<$limit", 
    182               "UPDATE sys_socket SET to_be_deleted=1 WHERE sensor_id=? and sys_socket_id=?", 
    183                $dbh); 
    184  
    185  
     119   $sth->finish; 
    186120 
    187121   #-------------------- 
     
    192126   $sth=$dbh->prepare("DELETE FROM flow WHERE src_end_sec<$limit") or die "cannot prepare statement for flow". $dbh->errstr; 
    193127   $sth->execute() or die "cannot execute statement".$sth->errstr; 
    194    #print("argus done\n"); 
    195128   $sth->finish; 
    196129 
     
    198131   $sth=$dbh->prepare("DELETE FROM process WHERE pcap_time_max<$limit") or die "cannot prepare statement for flow". $dbh->errstr; 
    199132   $sth->execute() or die "cannot execute statement".$sth->errstr; 
    200    #print("process done\n"); 
    201133   $sth->finish; 
    202134 
     
    204136   $sth=$dbh->prepare("DELETE FROM ids WHERE to_be_deleted=1") or die "cannot prepare statement for flow". $dbh->errstr; 
    205137   $sth->execute() or die "cannot execute statement".$sth->errstr; 
    206    #print("ids done\n"); 
    207138   $sth->finish; 
    208139 
     
    210141   $sth=$dbh->prepare("DELETE FROM process_tree WHERE to_be_deleted=1") or die "cannot prepare statement for flow". $dbh->errstr; 
    211142   $sth->execute() or die "cannot execute statement".$sth->errstr; 
    212    #print("process_tree done\n"); 
    213143   $sth->finish; 
    214144 
     
    216146   $sth=$dbh->prepare("DELETE FROM process_to_com WHERE to_be_deleted=1") or die "cannot prepare statement for flow". $dbh->errstr; 
    217147   $sth->execute() or die "cannot execute statement".$sth->errstr; 
    218    #print("process_to_com  done\n"); 
    219148   $sth->finish; 
    220149 
     
    222151   $sth=$dbh->prepare("DELETE FROM sys_open WHERE to_be_deleted=1") or die "cannot prepare statement for flow". $dbh->errstr; 
    223152   $sth->execute() or die "cannot execute statement".$sth->errstr; 
    224    #print("sys_open done\n"); 
    225153   $sth->finish;   
    226154 
     
    228156   $sth=$dbh->prepare("DELETE FROM sys_read WHERE to_be_deleted=1") or die "cannot prepare statement for flow". $dbh->errstr; 
    229157   $sth->execute() or die "cannot execute statement".$sth->errstr; 
    230    #print("sys_read done\n"); 
    231158   $sth->finish; 
    232159 
     
    234161   $sth=$dbh->prepare("DELETE FROM sys_socket WHERE to_be_deleted=1") or die "cannot prepare statement for flow". $dbh->errstr; 
    235162   $sth->execute() or die "cannot execute statement".$sth->errstr; 
    236    #print("sys_socket done\n"); 
    237163   $sth->finish; 
    238  
    239  
    240  
    241164 
    242165   #print "$limit  $dbdays\n";