Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic SYNERGY (steve huntington)
Decrease font size
Increase font size
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
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 13-Oct-2006 20:38
User is offline View Users Profile Print this message


Todd Alden

Posts: 71
Joined: 4-Oct-2002


#!/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;
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic SYNERGY forum.
There are currently 2 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 15:34.
There are currently 0 guests browsing this forum, which makes a total of 2 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.