|
Wednesday, 05 May 2010 12:17 |
|
* [WLSTScripts]
*[How to get JMS messages]
* [Create multiple user accounts]
The following command lists all MessagingBridgeRuntimeMBean instances with all of the attributes.
__java weblogic.Admin -url your-server-url -username server-username -password server-password GET -pretty -type MessagingBridgeRuntime__
If you have the runtime mbean name of a particular bridge instance (or once you obtain the name from the previous command), you should be able to view only that instance using the following command.
__java weblogic.Admin -url your-server-url -username server-username -password server-password GET -pretty -type MessagingBridgeRuntime -mbean messaging-bridge-runtime-mbean-name__ |
|
Wednesday, 05 May 2010 11:32 |
|
Weblogic start script:
{{{
#!/bin/sh # # Init script to start and stop # WebLogic Admin Server for Production domain # DOMAIN_HOME="/opt/bea/wlserver_10.3/samples/domains/wl_server" export DOMAIN_HOME
wlstart() { echo starting Managed Server... su - weblogic -c "cd ${DOMAIN_HOME} && nohup startWebLogic.sh &" }
wlstop() { echo stopping Managed Server... su - weblogic -c "cd ${DOMAIN_HOME}/bin && nohup ./stopWebLogic.sh &" }
usage() { echo "Usage: $0 [ start | stop ]" }
case $1 in 'start') wlstart;; 'stop') wlstop;; *) usage;; esac }}}
{{{ FYI - This setting is 0 by default, might be worth changinging
Domain configuration / general / advanced
Archive Configuration Count: The number of archival versions of config.xml saved by the Administration Server each time the domain configuration is modified. }}}
{{{ java weblogic.Deployer -adminurl http://admin:7001 -name app -source /myapp/app.ear -targets server1,server2 -activate }}}
{{{ java weblogic.Deployer -adminurl http://admin:7001 -name app -targets server -remove -id tag }}}
{{{ openssl s_client -connect www.domainname.com:443 }}}
{{{ import java.io.*; import java.net.URL;
import java.security.*; import java.security.cert.*;
import javax.net.ssl.*;
public class InstallCert {
public static void main(String[] args) throws Exception { String host; int port; char[] passphrase; if ((args.length == 1) || (args.length == 2)) { String[] c = args[0].split(":"); host = c[0]; port = (c.length == 1) ? 443 : Integer.parseInt(c[1]); String p = (args.length == 1) ? "changeit" : args[1]; passphrase = p.toCharArray(); } else { System.out.println("Usage: java InstallCert <host>[:port] [passphrase]"); return; }
File file = new File("jssecacerts"); if (file.isFile() == false) { char SEP = File.separatorChar; File dir = new File(System.getProperty("java.home") + SEP + "lib" + SEP + "security"); file = new File(dir, "jssecacerts"); if (file.isFile() == false) { file = new File(dir, "cacerts"); } } System.out.println("Loading KeyStore " + file + "..."); InputStream in = new FileInputStream(file); KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); ks.load(in, passphrase); in.close();
SSLContext context = SSLContext.getInstance("TLS"); TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ks); X509TrustManager defaultTrustManager = (X509TrustManager)tmf.getTrustManagers()[0]; SavingTrustManager tm = new SavingTrustManager(defaultTrustManager); context.init(null, new TrustManager[] {tm}, null); SSLSocketFactory factory = context.getSocketFactory();
System.out.println("Opening connection to " + host + ":" + port + "..."); SSLSocket socket = (SSLSocket)factory.createSocket(host, port); socket.setSoTimeout(10000); try { System.out.println("Starting SSL handshake..."); socket.startHandshake(); socket.close(); System.out.println(); System.out.println("No errors, certificate is already trusted"); } catch (SSLException e) { System.out.println(); e.printStackTrace(System.out); }
X509Certificate[] chain = tm.chain; if (chain == null) { System.out.println("Could not obtain server certificate chain"); return; }
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.println(); System.out.println("Server sent " + chain.length + " certificate(s):"); System.out.println(); MessageDigest sha1 = MessageDigest.getInstance("SHA1"); MessageDigest md5 = MessageDigest.getInstance("MD5"); for (int i = 0; i < chain.length; i++) { X509Certificate cert = chain[i]; System.out.println (" " + (i + 1) + " Subject " + cert.getSubjectDN()); System.out.println(" Issuer " + cert.getIssuerDN()); sha1.update(cert.getEncoded()); System.out.println(" sha1 " + toHexString(sha1.digest())); md5.update(cert.getEncoded()); System.out.println(" md5 " + toHexString(md5.digest())); System.out.println(); }
System.out.println("Enter certificate to add to trusted keystore or 'q' to quit: [1]"); String line = reader.readLine().trim(); int k; try { k = (line.length() == 0) ? 0 : Integer.parseInt(line) - 1; } catch (NumberFormatException e) { System.out.println("KeyStore not changed"); return; }
X509Certificate cert = chain[k]; String alias = host + "-" + (k + 1); ks.setCertificateEntry(alias, cert);
OutputStream out = new FileOutputStream("jssecacerts"); ks.store(out, passphrase); out.close();
System.out.println(); System.out.println(cert); System.out.println(); System.out.println ("Added certificate to keystore 'jssecacerts' using alias '" + alias + "'"); } private static final char[] HEXDIGITS = "0123456789abcdef".toCharArray(); /* CHANGE ME FOR JAVA 1.4.X java 1.4.x doesn't use StringBuilder */ private static String toHexString(byte[] bytes) { StringBuilder sb = new StringBuilder(bytes.length * 3); for (int b : bytes) { b &= 0xff; sb.append(HEXDIGITS[b >> 4]); sb.append(HEXDIGITS[b & 15]); sb.append(' '); } return sb.toString(); }
private static class SavingTrustManager implements X509TrustManager {
private final X509TrustManager tm; private X509Certificate[] chain;
SavingTrustManager(X509TrustManager tm) { this.tm = tm; } public X509Certificate[] getAcceptedIssuers() { throw new UnsupportedOperationException(); } public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { throw new UnsupportedOperationException(); } public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { this.chain = chain; tm.checkServerTrusted(chain, authType); } }
} }}}
The above code works on java 1.5.X, change this to run on 1.4.x:
{{{ private static String toHexString(byte[] bytes) { StringBuffer sb = new StringBuffer(bytes.length * 3); for (int i =0; i < bytes.length; i++) { int b = bytes[i]; b &= 0xff; sb.append(HEXDIGITS[b >> 4]); sb.append(HEXDIGITS[b & 15]); sb.append(' '); } return sb.toString(); } |
|
|
Creating a volume group
pvcreate /dev/sde1 /dev/sdc1
vgcreate rootvg /dev/sde1 /dev/sdc1
lvcreate -L 20G -n rootvol rootvg
mkfs.ext3 /dev/rootvg/rootvol
Resizing filesystems under lvm control
lvm.static vgscan
lvm.static lvchange -ay /dev/rootvg/rootvol
e2fsck -f /dev/rootvg/rootvol
resize2fs /dev/rootvg/rootvol 4900M
lvm.static lvreduce -L 5000M /dev/rootvg/rootvol
resize2fs /dev/rootvg/rootvol
Increasing swap
swapoff -a
lvextend -L 10G /dev/rootvg/swap
mkswap /dev/rootvg/swap
swapon -a |
|
Tuesday, 04 May 2010 16:48 |
|
#! /bin/ksh
############################################################################# # Module Name: wlspider.ksh # # Author : Gary Thomson # # Date : 12/12/2001 # # Version : 1.0.0 # # Description: This script can run as a "daemon" or from the # # command line and is used to retrieve the weblogs # # from clients listed in wlmachine.conf # # # # Modification History # # Author Version Date Description Of Mod # # ========================================================================= # # Gary T 1.2 12/12/2001 Initial Version. # # Gary T 1.3 11/03/2002 Fix the following bugs from testing... 001, # # 003, 004, 005, 006, 007, 008 # # Gary T 1.4 11/03/2002 Fix obtaining logFormat. # # Gary T 1.5 12/03/2002 fspec version error now set to 0034. # # Gary T 1.6 12/03/2002 wlerror version error now set to 0037. # # Gary T 1.7 12/03/2002 wlspam version error now set to 0038. # # Gary T 1.8 12/03/2002 wlconf version error now set to 0036. # # Gary T 1.9 12/03/2002 Added functionality for archiing. # # Gary T 1.10 12/03/2002 Added functionality for writing logname to # # logfile. Added date to reconcile report. # # Gary T 1.11 12/03/2002 Fix for last fix. # # Gary T 1.12 12/03/2002 Improved logging, removed wlspam version, # # Gary T 1.13 12/03/2002 Fixed date problem, duplicate name problem # # Gary T 1.14 19/03/2002 Incorporate changes to base directory # # structure and name change to chv, chk. # # Neil B 1.15 20/03/2002 Added extra client connectivity checking. # # Neil B 1.16 21/03/2002 Code to stop recursive downloads occurring. # # Neil B 1.17 21/03/2002 Changed to use SCP instead of SSH for Conn. # # testing. # # Neil B 1.18 04/04/2002 Added FAIL detect and email to FTS. # #############################################################################
################## # Start download # ##################
startDownload() {
###################################################### # Accepts IP address and file names as parameters and# # ssh's to IP, chksum's the file then downloads the # # file and the trg file. Outputs to log file and # # and reconciliation report. # ######################################################
###################################################### # Log "time to download" # ######################################################
clientAddress=$1 webLogName=$2
writeLog 0010 $LINENO $webLogName
if [[ ! $MANUAL_FLAG -eq 1 ]] then destWebLogName=$3 chvFile=$4 else destWebLogName=${webLogName} chvFile=`print $WL_CHV_FILE | /bin/sed s/YYYYMMDD/${previousDay}/` writeLog 0027 $LINENO $webLogName fi
ERROR_FLAG=0 WL_RETRIES=$WL_RETRY
while [[ $WL_RETRIES -gt 0 ]] do
###################################################### # If ERROR_FLAG ok checksum the file and output to # # TRG on this server. If status not zero then set # # ERROR_FLAG cksum # ######################################################
if [[ $ERROR_FLAG = 0 ]] then writeLog 0045 $LINENO $webLogName /usr/local/bin/ssh 2> /dev/null $clientAddress "cksum $webLogName" > /tmp/`/bin/basename ${destWebLogName}.trg.$$`
if [[ $? -ne 0 ]] then ERROR_FLAG=1 writeLog 0011 $LINENO $webLogName else writeLog 0012 $LINENO $webLogName fi fi
###################################################### # If ERROR_FLAG ok compress the file # # if status not zero then set ERROR_FLAG compress. # ######################################################
if [[ $ERROR_FLAG = 0 ]] then writeLog 0046 $LINENO $webLogName /usr/local/bin/ssh 2> /dev/null $clientAddress "gzip $webLogName" if [[ $? -ne 0 ]] then ERROR_FLAG=1 writeLog 0013 $LINENO $webLogName else writeLog 0014 $LINENO $webLogName fi fi
###################################################### # If ERROR_FLAG ok then copy the file and rename the # # file to inlcude the logformat indicator. If status # # not zero then set ERROR_FLAG download # ######################################################
if [[ $ERROR_FLAG = 0 ]] then writeLog 0047 $LINENO $webLogName /usr/local/bin/scp 2> /dev/null ${clientAddress}:${webLogName}.gz ${WL_BASE}/${todaysDate}/`/bin/basename ${destWebLogName}.gz` if [[ $? -ne 0 ]] then ERROR_FLAG=1 writeLog 0015 $LINENO $webLogName else writeLog 0016 $LINENO $webLogName fi fi
###################################################### # If ERROR_FLAG ok move the TRG from /tmp to WL_BASE # # If status not zero then set ERROR_FLAG trg. # ######################################################
if [[ $ERROR_FLAG = 0 ]] then writeLog 0048 $LINENO $webLogName /bin/mv /tmp/`/bin/basename ${destWebLogName}.trg.$$` ${WL_BASE}/${todaysDate}/`/bin/basename ${destWebLogName}.trg` if [[ $? -ne 0 ]] then ERROR_FLAG=1 writeLog 0017 $LINENO $webLogName else
###################################################### # If ERROR_FLAG ok then append new filename to # # W_CHV_FILE. if status not zero then set ERROR_FLAG # # append. # ######################################################
writeLog 0049 $LINENO $webLogName
print "$sourceWebLogName OK" >> $chvFile if [[ $? -ne 0 ]] then ERROR_FLAG=1 writeLog 0019 $LINENO $webLogName else writeLog 0020 $LINENO $webLogName fi
writeLog 0018 $LINENO $webLogName fi fi
###################################################### # If ERROR_FLAG is zero at this point then the file # # has been transfered. If ERROR_FLAG not ok then # # decrement WL_RETRY. Loop will exit when no more # # retries. # ######################################################
if [[ $ERROR_FLAG -ne 0 ]] then let WL_RETRIES=WL_RETRIES-1 if [[ WL_RETRIES -eq 0 ]] then print "$sourceWebLogName FAILED" >> $chvFile fi else ###################################################### # Number of retries has been reached and file has # # to be downloaded. Write to error log and reconcile # # report. # ######################################################
WL_RETRIES=0 writeLog 0021 $LINENO $webLogName
###################################################### # Copy the log file to the archive directory. # ######################################################
/usr/bin/cp ${WL_BASE}/${todaysDate}/`/bin/basename ${destWebLogName}.gz` ${WL_ARCHIVE}
if [[ $? -ne 0 ]] then writeLog 0042 $LINENO $webLogName else writeLog 0043 $LINENO $webLogName fi
fi
done
WL_RETRIES=$WL_RETRY
writeLog 0026 $LINENO $webLogName
} #End start download
startReconcile() {
###################################################### # For each IP in wlmachine.conf get the the download # # time. If no download time then set to default. # # Check if the current time is greater than the # # download time, if so then check all the files in # # wlfspec.conf appear in the chv file ie. they've # # all been downloaded. If all the download times # # have been reached then we're ready for reconcile # # so if any files are missing then assume that they # # have failed. Send reconcile report to alertees. # ######################################################
ERROR_FLAG=0 FIRST_VERSION_RECORD=1
writeLog 0022 $LINENO
while read getLine do if [ $FIRST_VERSION_RECORD -ne 1 ] then timeToDownload=`print $getLine | /bin/awk -F, '{ print $6 }' | /bin/sed s/://` if [[ $timeToDownload = "" ]] then timeToDownload=`print $WL_DEFAULT_START | /bin/sed s/://` fi
currentTime=`/bin/date +%H%M`
if [[ $timeToDownload -gt $currentTime ]] then ###################################################### # We've not run the download, set the error # # flag and exit the function. # ######################################################
let ERROR_FLAG=ERROR_FLAG+1 fi fi FIRST_VERSION_RECORD=0 done < $WL_MACHINE_PATH
###################################################### # If error flag is zero then all the downloads have # # finished. So we can create the report and send to # # alertees after moving chv to chk. # ######################################################
if [[ $ERROR_FLAG -eq 0 ]] then writeLog 0022 $LINENO
#New Code added 29/04/03 - N.Bottomley
########################################################### # Process the FTP jobs before creating the CHK file # ###########################################################
FTPCHV=/tmp/ftp.chv
/usr/local/bin/weblogftp.ksh -f $FTPCHV
########################################################### # Cat the FTP and WLSpider CHV files to form the CHK # ###########################################################
cat $currentChvFile $FTPCHV > $currentChkFile
rm $currentChvFile
#End of New Code
#/bin/mv $currentChvFile $currentChkFile Fail="" Fail=`grep -i FAILED ${currentChkFile}` if [ "${Fail}" != "" ] then mailx -s "Weblogs Reconciliation Failure: Please Investigate"
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
< $currentChkFile fi
if [[ $? -ne 0 ]] then writeLog 0026 $LINENO else while read alertee do mailx -s "RECONCILIATION REPORT FOR ${previousDay}" $alertee < $currentChkFile if [[ $? -ne 0 ]] then writeLog OO25 $LINENO
fi done < ${WL_SPAM_PATH}
/usr/bin/cp ${currentChkFile} ${WL_ARCHIVE}
if [[ $? -ne 0 ]] then writeLog 0050 $LINENO else writeLog 0051 $LINENO fi
writeLog 0044 $LINENO fi
fi
} #End Reconcile
displayUsage() {
###################################################### # Usage: $0 - Run as Daemon # # $1- IP or hostname # # $2 - Date [YYYYMMDD] # ######################################################
print "Error 0001 Usage: " print "wlspider.ksh [no args - run as daemon]" print "wlspider.ksh [IP or hostname] [YYYYMMDD]" exit 0001
}
writeLog() {
###################################################### # Accepts 2 parameters, $1 error code and $2 lineno. # # Search for error in wlerror.conf and get the # # comment and error level. Write error code, comment # # error level and line number to error log file. # ######################################################
currentTime=`/bin/date +%Y%m%d%H%M` errorCode=$1 lineNumber=$2
case $# in 2) errorComment=`/bin/grep $errorCode $WL_ERROR_PATH | /bin/awk -F, '{ print $2 }'` errorLevel=`/bin/grep $errorCode $WL_ERROR_PATH | /bin/awk -F, '{ print $3 }'` errorLogName="" ;;
3) errorComment=`/bin/grep $errorCode $WL_ERROR_PATH | /bin/awk -F, '{ print $2 }'` errorLevel=`/bin/grep $errorCode $WL_ERROR_PATH | /bin/awk -F, '{ print $3 }'` errorLogName=`/bin/basename $3` ;;
4) errorComment=`/bin/grep $errorCode $WL_ERROR_PATH | /bin/awk -F, '{ print $2 }'` errorComment=`echo $errorComment: $3` errorLevel=$4 errorLogName="" ;;
esac
errorLogEntry="$currentTime $errorLogName $errorCode $errorComment. Error level $errorLevel at line $lineNumber"
print "$errorLogEntry" >> $WL_LOG_FILE
if [[ $MANUAL_FLAG = 1 ]] then print "$errorLogEntry" >&2 fi
if [[ $errorLevel -eq 1 ]] then exit $errorCode fi
print "$currentTime $errorLogName $errorCode $errorComment. Error level $errorLevel at line $lineNumber"
}
validateConfig() {
###################################################### # Check main config file exists and is readable. # # If not then error and exit. # ######################################################
if [[ ! -r $WL_CONF_FILE ]] then writeLog 0003 $LINENO "The wlspider.conf file does not exist or is not readable." 1 fi
###################################################### # Source the main config file # ######################################################
. $WL_CONF_FILE
if [[ $? -ne 0 ]] then writeLog 0028 $LINENO "Could not source wlspider.conf." 1 fi
###################################################### # Check the wlspider.conf file version matches the # # version set in the weblog users environment if not # # then exit. # ######################################################
if [[ $WL_CONF_VERSION != $WL_CONF_VER ]] then writeLog 0036 $LINENO "WL_CONF_VER does not match." 1 fi
###################################################### # Check log file exists and is writeable. If log # # file not exist then create. # ######################################################
if [[ ! -w $WL_LOG_FILE ]] then print "File wlspider.log does not exist, creating" /bin/touch $WL_LOG_FILE 2>/dev/null if [[ $? -ne 0 ]] then writeLog 0004 $LINENO "Cannot access log file." 1 fi fi
###################################################### # Check Error file exists and is readable. If Error # # file not exist then error to stdout and log # ######################################################
if [[ ! -r $WL_ERROR_PATH ]] then writeLog 0029 $LINENO "Cannot access wlerror.conf." 1 fi
###################################################### # Read in wlerror.conf version. Check # # wlerror.conf version. If not match # # WL_ERROR_VER then error and exit # ######################################################
read getLine < $WL_ERROR_PATH currentLine=${getLine#\#} errorVersion=${WL_ERROR_VER#\#}
if [[ $currentLine != $errorVersion ]] then writeLog 0037 $LINENO else unset getLine unset currentLine unset errorVersion fi
###################################################### # If WL_BASE not exist then log and create # ######################################################
if [[ ! -d $WL_BASE ]] then writeLog 0006 $LINENO /bin/mkdir -p $WL_BASE if [[ $? -ne 0 ]] then writeLog 0004 $LINENO else writeLog 0007 $LINENO fi elif [[ ! -w $WL_BASE ]] then writeLog 0030 $LINENO fi
###################################################### # If WL_ARCHIVE not exist then log and create # ######################################################
if [[ ! -d $WL_ARCHIVE ]] then writeLog 0039 $LINENO /bin/mkdir -p $WL_ARCHIVE if [[ $? -ne 0 ]] then writeLog 0004 $LINENO else writeLog 0040 $LINENO fi elif [[ ! -w $WL_ARCHIVE ]] then writeLog 0041 $LINENO fi
###################################################### # If WL_BASE/todaysDate not exist then log and # # create. # ######################################################
todaysDate=`/bin/date +\%Y\%m\%d`
if [[ ! -d ${WL_BASE}/${todaysDate} ]] then writeLog 0052 $LINENO /bin/mkdir -p ${WL_BASE}/${todaysDate} if [[ $? -ne 0 ]] then writeLog 0053 $LINENO else writeLog 0054 $LINENO fi elif [[ ! -w ${WL_BASE}/${todaysDate} ]] then writeLog 0055 $LINENO fi
###################################################### # Check WL_MACHINE_PATH exists and is readable. # # If not then error and exit. # ######################################################
if [[ ! -r $WL_MACHINE_PATH ]] then writeLog 0031 $LINENO fi
###################################################### # Read in wlmachine.conf version. Check # # wlmachine.conf version. If not match # # WL_MACHINE_VER then error and exit # ######################################################
read getLine < $WL_MACHINE_PATH currentLine=${getLine#\#} machineVersion=${WL_MACHINE_VER#\#}
if [[ $currentLine != $machineVersion ]] then writeLog 0008 $LINENO else unset getLine unset currentLine unset machineVersion fi
###################################################### # Check WL_FSPEC_PATH exists and is readable. # # If not then error and exit. # ######################################################
if [[ ! -r $WL_FSPEC_PATH ]] then writeLog 0033 $LINENO fi
###################################################### # Read in wlfspec.conf version. Check # # wlfspec.conf version. If not match # # WL_FSPEC_VER then error and exit # ######################################################
read getLine < $WL_FSPEC_PATH currentLine=${getLine#\#} fspecVersion=${WL_FSPEC_VER#\#}
if [[ $currentLine != $fspecVersion ]] then writeLog 0034 $LINENO else unset getLine unset currentLine unset fspecVersion fi
###################################################### # Check spam file exists and is readable. If spam # # file not exist then error to stdout and log # ######################################################
if [[ ! -r $WL_SPAM_PATH ]] then writeLog 0035 $LINENO fi
###################################################### # Read in wlfspam.conf version. Check # # wlspam.conf version. If not match # # WL_SPAM_VER then error and exit # ######################################################
# read getLine < $WL_SPAM_PATH # currentLine=${getLine#\#} # spamVersion=${WL_SPAM_VER#\#}
# if [[ $currentLine != $spamVersion ]] # then # writeLog 0038 $LINENO # else # unset getLine # unset currentLine # unset spamVersion # fi
###################################################### # Check the stop flag. If set then log and exit. # ######################################################
if [[ $WL_STOP_FLAG != 0 ]] then writeLog 0005 $LINENO fi
}
#main() {
###################################################### # Check command line parameters, # # If 2 and not zero then error to stdout and exit # ######################################################
if [[ $# -ne 2 && $# -ne 0 ]] then displayUsage fi
###################################################### # If parameters is zero then check if script is # # already running. If running then display error to # # stdout and exit. # ######################################################
if [[ $# -eq 0 ]] then /bin/ps -ef | /bin/grep -v $$ | /bin/grep -i "wlspider.ksh" | /bin/grep -v grep > /dev/null if [[ $? -eq 0 ]] then print "Error 0002 The wlspider.ksh daemon is already running. Line $LINENO" exit 0002 fi fi
###################################################### # If parameters = 2 then set MANUAL_FLAG and check # # parameters are valid # ######################################################
if [[ $# -eq 2 ]] then MANUAL_FLAG=1 manualClientAddress=$1 manualWebLogName=$2 else MANUAL_FLAG=0 fi
###################################################### # Initialize Variables # ######################################################
WL_STOP_FLAG=0 WL_CONF_FILE=/usr/local/etc/wlspider.conf
###################################################### # Loop while stop flag not set # ######################################################
while [[ $WL_STOP_FLAG -eq 0 ]] do
###################################################### # Validate function checks all the config files # # exist and are the right versions. # ######################################################
validateConfig
###################################################### # For each line in wlmachine do, extract time to # # download. If "time to download" equals null and # # "current time" >= WL_DEFAULT_START or MANUAL_FLAG # # set Start download. # # # # If "time to download" is not null and # # "current time" >= "time to download" and # # MANUAL_FLAG not set then Start download, End For # ######################################################
if [[ $MANUAL_FLAG = 1 ]] then
###################################################### # Manual flag set, start download. # ######################################################
startDownload $manualClientAddress $manualWebLogName exit fi
################################################# # Don't go through the main loop until the def # # time to download has been reached. # ################################################# defaultTimeToDownload=`print $WL_DEFAULT_START | /bin/sed s/://` while ( true ) do currentTime=`/bin/date +%H%M` if [ "${currentTime}" -ge "${defaultTimeToDownload}" ] then break fi sleep 60 done
for getLine in `/bin/cat $WL_MACHINE_PATH` do
###################################################### # Get download time from wlmachine.conf, get rid of # # colon, if no download time then use default time. # # Get IP address while we're here. # ######################################################
currentLine=`print "$getLine" | /bin/sed -e /^#/d -e /^$/d` if [[ $currentLine != "" ]] then timeToDownload=`print $currentLine | /bin/awk -F, '{ print $6 }' | /bin/sed s/://` defaultTimeToDownload=`print $WL_DEFAULT_START | /bin/sed s/://`
if [[ $timeToDownload -eq "" ]] then timeToDownload=$defaultTimeToDownload fi
autoClientAddress=`print $currentLine | /bin/awk -F, '{ print $1 }'`
###################################################### # Need filename at this point # ######################################################
for webLogName in `/bin/grep $autoClientAddress $WL_FSPEC_PATH | /bin/awk -F, '{ print $2 }'` do
downloadWebLogName=`/bin/grep $webLogName $WL_FSPEC_PATH | /bin/grep $autoClientAddress | /bin/awk -F, '{ print $4 }'`
###################################################### # Get yesterday's date from prev_date, add the date # # to the web log name. If reconcile report has been # # created yet then check if weblog has already been # # downloaded, if not then proceed with download. # ######################################################
previousDay=`/bin/cat /usr/local/etc/prev_date` logFormat=`/bin/grep $webLogName $WL_FSPEC_PATH | /bin/grep $autoClientAddress | /bin/awk -F, '{ print $3 }' | /bin/sort -u`
###################################################### # We need to check if the log is on and NT box with # # IIS, because the format of the log names needs to # # be handled differently, the only format they have # # is exYYYYMMDD.log. First use the logformat to check# # if it's IIS, if so set the appropriate source ad # # dest filename, if Apache then handle as normal. # ######################################################
ntCount=0
for checkLogFormat in `print $WL_NTCHECK` do if [[ $logFormat = $checkLogFormat ]] then let ntCount=ntCount+1 fi done
###################################################### # If ntCount is not equal to zero the server is an # # NT server so use that format, else use the apache # # format. # ######################################################
if [[ $ntCount -ne 0 ]] then sourceWebLogName="${webLogName}${previousDay#20}.log" fullWebLogName=$downloadWebLogName"_"${previousDay}"_"$logFormat else sourceWebLogName="${webLogName}_${previousDay}" fullWebLogName=$sourceWebLogName"_"$logFormat fi
currentChvFile=${WL_BASE}/${todaysDate}.chv currentChkFile=${WL_BASE}/${todaysDate}.chk
downLoaded="" if [[ -r $currentChvFile ]] then downLoaded=`/bin/grep $sourceWebLogName $currentChvFile` fi
currentTime=`/bin/date +%H%M` dayNow=`/bin/date +%Y%m%d`
if [[ "$currentTime" -ge "$timeToDownload" && "$downLoaded" = "" && ! -e "$currentChkFile" && "$dayNow" -gt "$previousDay" ]] then numberOfJobs=`jobs | /bin/awk '{ print $0 }' | /bin/wc -l` while [[ $numberOfJobs -ge $WL_THREADS ]] do /bin/sleep 1 numberOfJobs=`jobs | /bin/awk '{ print $0 }' | /bin/wc -l` done
########################################## # NB: Start Of 1.15 Additional Code # ########################################## writeLog 0056 $LINENO $autoClientAddress noOfRetries=5
ClientOK=0 while [[ $noOfRetries -gt 0 ]] do if [ $noOfRetries = 5 ] then # Issue this command only once rm -f /tmp/testconn.tst > /tmp/testconn.tst destDir=`dirname $sourceWebLogName`
/usr/local/bin/scp 2> /dev/null /tmp/testconn.tst ${autoClientAddress}:$destDir & sleep 5 fi
Pid="" Pid=`ps -ef | grep "testconn" | grep $autoClientAddress | grep -v grep | awk '{print $2}'` if [ "${Pid}" != "" ] then sleep 30 let noOfRetries=noOfRetries-1 ClientStr=`echo $autoClientdAddress - $fullWebLogName: Retries Remaining: ${noOfRetries}` writeLog 0057 $LINENO "$ClientStr" 4 else ClientOK=1 break fi done
########################################## # NB: End Of 1.15 Additional Code # ##########################################
if [ ClientOK -eq 1 ] then startDownload $autoClientAddress $sourceWebLogName $fullWebLogName $currentChvFile& else print "$sourceWebLogName FAILED" >> $currentChvFile ClientStr=`echo $autoClientdAddress - $fullWebLogName` writeLog 0058 $LINENO "$ClientStr" 4 kill -9 ${Pid} fi fi done fi done
###################################################### # If report exists call reconcile and check if ready # # to run report # ######################################################
###################################################### # Make sure all the background jobs are finished # # before allowing the reconciliation. # ######################################################
numberOfJobs=`jobs | /bin/awk '{ print $0 }' | /bin/wc -l` while [[ $numberOfJobs -ne 0 ]] do /bin/sleep 7 numberOfJobs=`jobs | /bin/awk '{ print $0 }' | /bin/wc -l` done
if [[ -w $currentChvFile ]] then startReconcile fi
#writeLog 0009 $LINENO /bin/sleep $WL_SLEEP_TIME
###################################################### # End While Loop # ######################################################
done
# } End Main |
|
Last Updated on Saturday, 08 May 2010 13:10 |
|