Welcome to Oracle Database Administrator Home

24x7 oracle database support and solutions
Oracle DBA Home     PostgreSQL     DB2     MS SQL     MySQL     Datawarehouse     Unix Commands     CVS Help     OEM     Data Guard     Oracle FAQ     Networking     Oracle Concepts     SQLPlus Commands      
Database Jobs
Cron Jobs
Server Parameter File
Optimizer Statistics
Database User Maintenance
Oracle Installation
Oracle Expdp
Oracle 9i on RHES
Oracle Database Backup
Oracle RAC
Oracle Database Tuning
Oracle DBA Scripts
Oracle PLSQL
Oracle RMAN
Self managing oracle data
Oracle Newsletter
Oracle History
Unix Shell Scripts
Perl Scripts
Oracle Download
Database Auditing
Database Space Management
Manage Alert Log
Oracle Database Patching
Oracle Tools
Manage Listener Log
Changing the sysman passw
Top 20 Monitoring SQL
SOP
Routine Maintenance
Update ora-ds.xml -Interactive script
#!/usr/bin/perl
# Created by : Sachchida
system "clear" ;
print "#####################################################################\n";
print "DBCEO.COM, Inc. (c) 2006               \n";
print "All rights reserved.                         \n";
print "#####################################################################\n";
  $olddbhost = "";
  $olddbport = "";
  $olddbname = "";
  $olddbuser = "";
  $olddbpass = "";
  $olddbipaddr = "";
 
  $newdbhost = "";
  $newdbport = "";
  $newdbname = "";
  $newdbuser = "";
  $newdbpass = "";
  $newdbipaddr = "";
  $tempdbpass = "";
   
 $file= "/opt/se/jboss-3.2.3/server/tm/deploy/ora-ds.xml";
 open( FILE, "$file");
LINE:
 while(<FILE>) {
   if( $_ =~ /<connection-url>/) {
     /\@\/\/(.*):(.*)\/(.*)</;
     $olddbipaddr= $1;
     $olddbport= $2;
     $olddbname =$3;
   }
   if( $_ =~ /<user-name>/) {
     />(.*)</;
     $olddbuser = $1;
   }
   if($_ =~ /<password>/){
    />(.*)</;
     $olddbpass = $1;
   }
  }
 
  print "Accept [default_value] by pressing the Enter key\n\n"; 
  print "\n";
  print "Enter the hostname or IP of the database server[$olddbipaddr]:";
     $newdbipaddr = <STDIN>;
     if( $newdbipaddr eq "\n") {
       $newdbipaddr = $olddbipaddr;}
  print "\n";
  print "Enter the port number of the database server[$olddbport]:";
     $newdbport = <STDIN>;
     if( $newdbport eq "\n") {
       $newdbport = $olddbport;}
  print "\n";
  print "Enter the the database instance name[$olddbname]:";
     $newdbname = <STDIN>;
     if( $newdbname eq "\n") {
       $newdbname = $olddbname;}
  print "\n";
  print "Enter the the database application user name[$olddbuser]:";
     $newdbuser = <STDIN>;
     if( $newdbuser eq "\n") {
       $newdbuser = $olddbuser;}
  print "\n";
  print "Enter the database password (will not echo):";
     `stty -echo`;
     $newdbpass = <STDIN>;
     `stty echo`;
     if( $newdbpass eq "\n") {
          $newdbpass = $olddbpass;}
     print "\n";
     print "\nRe-enter the database password (will not echo):";
     `stty -echo`;
     $tempdbpass = <STDIN>;
     `stty echo`;
     
     if ($newdbpass ne $tempdbpass){
      print "\nPasswords do not match, please enter the password again (will not echo):";
      `stty -echo`;
      $newdbpass = <STDIN>;
      `stty echo`;
        if( $newdbpass eq "\n") {
          $newdbpass = $olddbpass;}
        print "\n";
      print "\nRe-enter the database password (will not echo):";
      `stty -echo`;
      $tempdbpass = <STDIN>;
      `stty echo`;
      if ($newdbpass ne $tempdbpass){
      print "\nPasswords do not match, please enter the password again (will not echo):";
      `stty -echo`;
      $newdbpass = <STDIN>;
      `stty echo`;
        if( $newdbpass eq "\n") {
          $newdbpass = $olddbpass;}
        print "\n";
      print "\nRe-enter the database password (will not echo):";
      `stty -echo`;
      $tempdbpass = <STDIN>;
      `stty echo`;
      if ($$newdbpass ne $tempdbpass){
      print "\nYou have entered wrong passwords three times. Good Bye!!\n";
      exit;
      }
      }
 if ($newdbpass eq ""){
     $newdbpass = $olddbpass;
 }
  }
  print "\n";
close FILE;
#open the file for output
  open(OUTFILE, " >/opt/se/jboss-3.2.3/server/tm/deploy/ora-ds-temp.xml");
  open(FILEREAD, "/opt/se/jboss-3.2.3/server/tm/deploy/ora-ds.xml");
print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
  print "Updating the Oracle connection information with the information you entered.\n";
  print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1!!!!!!!\n";
  chomp($newdbipaddr);
  chomp($newdbport);
  chomp($newdbname);
  chomp($newdbuser);
  chomp($newdbpass);
 
   # backup file before edit
  `cp /opt/se/jboss-3.2.3/server/tm/deploy/ora-ds.xml /opt/se/jboss-3.2.3/server/tm/deploy/ora-ds.xml.bak`;
 
  # edit the IP address or hostname
#  $orads = `cat  /opt/se/jboss-3.2.3/server/tm/deploy/ora-ds.xml`;

while (<FILEREAD>) {
  if( $_ =~ /<connection-url>/) {
     s/.*/\t\t<connection-url>jdbc:oracle:thin:\@\/\/$newdbipaddr:$newdbport\/$newdbname<\/connection-url>/;
   }
   if( $_ =~ /<user-name>/) {
  s/.*/\t\t<user-name>$newdbuser<\/user-name>/;
   }
   if( $_ =~ /<password>/) {
  s/.*/\t\t<password>$newdbpass<\/password>/;
   }
   print OUTFILE "$_";
}    
 
 
   close OUTFILE;
   close FILEREAD;
   `mv /opt/se/jboss-3.2.3/server/tm/deploy/ora-ds-temp.xml /opt/se/jboss-3.2.3/server/tm/deploy/ora-ds.xml`;
  `cat /opt/se/jboss-3.2.3/server/tm/deploy/ora-ds.xml`;
  print "The Oracle connection information has been successfully updated.\n";
  print "###################################################################\n";
  exit;
 
PostgreSQL Analysis - Logfile
#!/usr/bin/perl
#
#    analyze_postgresql analyzes statement run times from the PostgreSQL 7.4
#    server log, when statement and duration logging is enabled.
#    Copyright (C) 2004  Erik G. Burrows
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#
# To use:
#    1. In your postgresql.conf file, set log_statement and log_duration to true
#    2. Run analyze script as ./analyze_postgresql.pl < logfile
#
# The most time consuming statements will be displayed, sorted by "cost" descending.
# Statement "cost" is computed by multiplying the average statement run time by the
# number of times it was executed.
#
# For purposes of accounting, when parsing statements, all numbers are converted to
# 1234, and all quoted strings are converted to 'foo'. This allows statements
# varying only with specified data to be counted together.
%statements = ();
%cur_statements = ();
$cur_pid = "";
$limit_display = 30;
while(<STDIN>) {
    chomp;
    if (/\[(\d )\]\s* LOG\:\s* statement\:\s*(.*)$/) {
 $pid = $1;
 $sql = $2;
 $sql =~ s/\'\'//g;
 $sql =~ s/\'.*?\'/\'foo\'/g;
 $sql =~ s/\d /1234/g;
 $cur_pid = $pid;
 $cur_statements{$cur_pid} = $sql;
    } elsif (/\[(\d )\]\s* LOG\:\s* duration\:\s* (. ) ms$/) {
 $pid = $1;
 $time = $2;
 $sql = $cur_statements{$pid};
 if ($sql) {
     if (! defined $statements{$sql}) {
  $statements{$sql} = {
         sql => $sql,
         times => [],
         count => 0
         };
     }
       $statements{$sql}->{"count"};
    
     push(@{$statements{$sql}->{"times"}}, $time);
 }
    } elsif (/\[(\d )\]\s* LOG\:/) {
    } elsif (/\[(\d )\]\s* WARNING\:/) {
    } elsif (/\[(\d )\]\s* ERROR\:/) {
 # Misc log messages
    } else {
 # Continuation of last statement
 s/\'\'//g;
 s/\'.*?\'/\'foo\'/g;
 s/\d /1234/g;
 $cur_statements{$cur_pid} .= "\n" . $_;
    }
}
foreach $sql (keys(%statements)) {
    $total = 0;
    foreach (@{$statements{$sql}->{"times"}}) {
 $total = $_;
    }
    $statements{$sql}->{"average"} = $total / $statements{$sql}->{"count"};
}
$i = 0;
foreach $sql (sort({$statements{$b}->{"count"} * $statements{$b}->
{"average"} <=> $statements{$a}->{"count"} * $statements{$a}->
{"average"} } keys(%statements))) {
    $i;
    if ($i > $limit_display) {
 last;
    }
    print $statements{$sql}->{"count"} . " x " . (int($statements{$sql}->
{"average"}) / 1000) . " (" . (int($statements{$sql}->{"count"} * 
$statements{$sql}->{"average"}) / 1000) . ") $sql\n";
}