![]() |
Telelogic SYNERGY (steve huntington) | ![]() |
Topic Title: Weekly maintenace tasks Topic Summary: A simple script used to conduct recommended weekly database maintenace tasks Created On: 13-Oct-2006 20:38 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
#!/usr/std/bin/perl5 ################################################################# # %filespec: weekly_dbmaint63.pl-1 % # # Modified by: %created_by% on %date_modified% # - # Created by Todd Alden, July 27, 2004 # # This script is designed to do weekly maintenance tasks on # Synergy databases. All of the tasks executed with in this # script can be done with "live" databases (that is with users # using the databases). # This script should be run weekly on all production databases. # # Arguments: # arg 1 = Fully qualified file to which to write log info # arg 2 = Comma separated list of database paths to process # # NOTE: Sites need to set up some CCM site-specific variables # immediately following these comments. # NO FURTHER modification should be required! # If any further modifications are needed, please send email to: # ccm@eng.delcoelect.com # ################################################################ ################################## # BEGIN SITE SPECIFIC INFORMATION ################################## # set the $CCM_HOME environment variable $ENV{'CCM_HOME'}="/vol/ccm64"; #$ENV{'CCM_HOME'}="c:\\Program Files\\CMSynergy\\ccm63"; # identify server architecture # uncomment ONE of the following lines # if win; ccm_root passwd MUST be specified #$server="sol2"; $passwd_arg=""; $server="hpux"; $passwd_arg=""; #$server="win"; $passwd_arg="-pw ################################## # END SITE SPECIFIC INFORMATION ################################## # grab arguments $logfile=$ARGV[0]; $db_list=$ARGV[1]; ####################### # UNIX SERVER SPECIFIC ####################### if (($server eq "sol2") || ($server eq "hpux")) { # set the $PATH environment variable with forward slashes $ENV{'PATH'}="/usr/bin:/usr/ucb:$ENV{'CCM_HOME'}/bin:$ENV{'CCM_HOME'}/informix/bin"; # error file for STDERR: can write to same file as stdout # set errfile to NULL string $errfile=""; # set up to use mailx $mailer="/usr/bin/mailx"; # fully qualified 'mail' command $recipient=$m; # no switches necessary $mailfile="\<$tmpfile"; # redirect file 2b mailed into mailx ####################### # NT SERVER SPECIFIC ####################### } elsif ($server eq "win") { # set the $PATH environment variable with backward slashes $ENV{'PATH'}="$ENV{'PATH'}:$ENV{'CCM_HOME'}\\bin:$ENV{'CCM_HOME'}\\informix\\bin"; # error file for STDERR: must write to separate file from stdout $errfile=$logfile; $errfile=~s/\..*$/\.err/; # set up to use ccm_mail $mailer="$ENV{'CCM_HOME'}\\bin\\util\\ccm_mail"; # use ccm_mail $recipient="-r $m"; # ccm_mail switch & recipient $mailfile="-c $tmpfile"; # ccm_mail switch file 2b mailed ####################### # UNKNOWN ARCHITECTURE ####################### } else { print "Unknown architecture.\n"; exit 1; } ######################## # start processing here ######################## # open logfile(s) if ( $errfile eq "" ) { # UNIX server # redirect stderr & stdout to logfile open (STDERR,">$logfile") || die "Can't redirect stderr to $logfile.\n"; open (STDOUT,">&STDERR") || die "Can't duplicate stdout to $logfile.\n"; } else { # NT server # redirect stderr & stdout to logfile open (STDERR,">$errfile") || die "Can't redirect stderr to $errfile.\n"; open (STDOUT,">$logfile") || die "Can't redirect stdout to $logfile.\n"; } select (STDERR); $|=1; select (STDOUT); $|=1; ############################### # Main processing ############################### foreach $db (split(/,/,$db_list)) { # start ccm session in from database printf "***Attempting to start session on $db\n"; $ENV{CCM_ADDR} = `$ENV{CCM_HOME}/bin/ccm start -d $db -m -q -nogui -r ccm_admin`; @ccm_status = `$ENV{CCM_HOME}/bin/ccm status`; $in_session = grep /\(current session\)/, @ccm_status; # If the user isn't in a CCM session, print an error and go to next db if(! $in_session) { printf "$0: CM Synergy session not started in $db. All other operations aborted.\n"; next; } # DO a file system check with the fix option printf "***fs check on $db\n"; system("$ENV{CCM_HOME}/bin/ccm fs_check -f"); # DO a clean_cache (default options) printf "***clean_cache on $db\n"; system("$ENV{CCM_HOME}/bin/ccm clean_cache"); # DO a clean_up all (remove unused auto-tasks and reconfig temp) printf "***clean_up on $db\n"; system("$ENV{CCM_HOME}/bin/ccm clean_up -all"); # exit out of ccm session system("$ENV{CCM_HOME}/bin/ccm stop"); # DO a full update of statistics on the database printf "***update statistics on $db\n"; system("$ENV{CCM_HOME}/bin/ccmdb update_statistics $db"); } # determine the date and time ($sec,$min,$hour,$mday,$mon,$year,$wday, $yday, $isdst) = localtime(time); # format date and time $cyear = $year - 100; # correct for perl bug $mon++; # incr by 1, so the month falls in the 1 to 12 range $DATE=sprintf("%2.2d:%2.2d, %2.2d/%2.2d/%2.2d", $hour,$min,$mon,$mday,$cyear); # output date&time databases were unprotected printf "Database maintain done at: $DATE\n"; # clean-up close (STDOUT); close (STDERR); exit 0; |
|
![]() |
Telelogic SYNERGY
» Scripts and Customizations
»
Weekly maintenace tasks
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.