Wednesday, 18 October 2017

Certcheck for checking and notifying certificate expiry date

#############################################################################################################
# Description : certcheck will report certificate expiry date for all the URLs that is available in urls.txt#
# Date  : 10/17/2017                                                                                        #
# Ver   : 2.0                                                                                               #
# Ver 1 : 10/17/2017                                                                                        #
# Ver 2 : Added Email Alerts 10/18/2017                                                                     #
# Usage : execute ./certcheck.ksh                                                                           #
#############################################################################################################

EXP_DAYS=90
DATA_FILE_PATH="urls.txt"
OPENSSL="/usr/bin/openssl"
MAILX="/bin/mailx"
EMAILADDRFILE='emails.txt'


function check_expiry {

        DAYS=`echo "(($(date -d "$2" +%s))-$(date +%s))/86400" | bc -l|awk -F'.' '{ print $1 }'`

        if [ $DAYS -lt 0 ]; then
                echo " Certificate already expired $DAYS ago";
        elif [ $DAYS -gt 0 -a $DAYS -lt $EXP_DAYS ] ; then
                echo " Certificate renewal due in $EXP_DAYS Days - Sending Email Alert";
                EMAIL_ADDRS=`cat $EMAILADDRFILE`
                echo " $EXP_DAYS Days certificate expiry notice for $1"|$MAILX -s "IMPORTANT ${1} - Certificate will expire in $EXP_DAYS Days"  $EMAIL_ADDRS
        else
                echo "   Certificate expires in $DAYS days"
        fi
}

cat $DATA_FILE_PATH|grep -v '#' |while read SERVERNAME
do
         if [ $(echo $SERVERNAME|grep ":" | wc -l) -eq 1 ]; then
           echo -n $SERVERNAME" "
           DATESTR=`(echo | $OPENSSL s_client -connect $SERVERNAME 2>/dev/null | $OPENSSL x509 -noout -enddate|sed 's/notAfter=//g') | awk -F' ' '{ print $1" "$2" "$4 }'`
        else
          echo -n ${SERVERNAME}:443 " "
           DATESTR=`(echo | $OPENSSL s_client -connect $SERVERNAME:443 2>/dev/null | $OPENSSL x509 -noout -enddate|sed 's/notAfter=//g' ) | awk -F' ' '{ print $1" "$2" "$4 }'`
         fi
        echo -n $DATESTR
        check_expiry "$SERVERNAME" "$DATESTR"
done

Saturday, 22 July 2017

PHP OCIi 12c XAMPP Configuration


Resolve it by following these steps:
Make sure you download and install Oracle instantclient at: http://www.oracle.com/technetwork/topics/winsoft-085727.html, but note:
  1. Take note of your Oracle database version; use Version 12.1.x for Oracle Database 12c and Version 11.1.x for 11g releases.
  2. In either case, make sure you download the Basic Lite version of the Oracle instantclient.
After that, do add the location of your Oracle instantclient to your System variable Path under your Environment Variables. Do equally ensure that you have both the PHP of your xampp and its extavailable and set there as well (if not, do add them).
Then, proceed to add a new System variable with TNS_ADMIN as a variable name and the location to Oracle instantclient as the variable value.
Also, define your User variables PATH with the same the location to Oracle instantclient as value.
After this stage, restart your computer for a full propagation of the newly defined environment variables.
Once on, you may open your Windows Command Prompt and run where oci* to ensure that you had your environment variables well defined; the response should look like this:
C:\Users\flex>where oci*

C:\oraclexe\app\oracle\product\11.2.0\server\bin\oci.dll
C:\oraclexe\app\oracle\product\11.2.0\server\bin\ocijdbc11.dll
C:\oraclexe\app\oracle\product\11.2.0\server\bin\ocijdbc11.sym
C:\oraclexe\app\oracle\product\11.2.0\server\bin\ociw32.dll
C:\instantclient_11_2\oci.dll
C:\instantclient_11_2\oci.sym
C:\instantclient_11_2\ocijdbc11.dll
C:\instantclient_11_2\ocijdbc11.sym
C:\instantclient_11_2\ociw32.dll
C:\instantclient_11_2\ociw32.sym
If not, you must have missed something and need to revisit the process, ensuring to completing it effectively.
You may now proceed to your php.ini file (provided environment variables are well defined) and enable your oci extensions (php_oci8.dll and php_oci8_11g.dll) by uncommenting them; you can achieve that by simply removing the semi column (;) before the said extensions.
Do remember to save your php.ini file, then, restart or start your Apache if it isn't already running.
To check your PHP oci8 configurations are enabled, you may go back to your Windows Command Prompt and run: php --ri oci8; the response should be similar to the one below:
C:\Users\flex>php --ri oci8

OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.1.1
Revision => $Id: 86f22a208f89dcd5b305e82929a7429683968b11 $
Oracle Run-time Client Library Version => 11.2.0.4.0
Oracle Compile-time Instant Client Version => 10.2

Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.events => Off => Off

Statistics =>
Active Persistent Connections => 0
Active Connections => 0
Alternatively, you can create a PHP file with as<?php phpinfo(); ?> content, then open it in your browser and search for oci8 occurrences; it should show enabled there as well.

Saturday, 1 April 2017

Workforce 17.x Certificate Installation Procedure.

1) Create a Certificate Request

keytool -genkeypair -v -alias '<hostname>' -keyalg 'RSA' -keysize 2048 -validity 1825 -keystore '/u01/wforce/TST/17.0/workforce.keystore' -storepass <password>

CN = <hostname> -> use the servername as CN (important)
OU = OrgUnit
O = Org
L = Altamonte
S = Florida
C = US

2) Generate NEW CSR Request
keytool -certreq -alias '<hostname>' -keystore '/u01/wforce/TST/17.0/workforce.keystore' -storepass <password>

-----BEGIN NEW CERTIFICATE REQUEST-----

4Q3Jxb63U9VMpqjGwU54o1cX6sJOpWgpxT5cpgP9tkf8ovV0jmvE3XhGztG1qDlYyov2J8/fMySJ
EUkC8nIKJHV9O/yM0jHZnhpjn1b+dwq8lE92sGz1DDNBDFJp73tnV3OgqOIn12wTro70wpHrao/h
t5LrmRfngtvt+6Bpsa/V7KOpCTXyYKe/OLcYB5r4OsliPUoNijXoIO+018U/3GwW7KP+NYc=
-----END NEW CERTIFICATE REQUEST-----

Once you have this key, save this to notepad and request for a signed key to   (Create a Service Request)

3) These are the intermediate certificates mandatory for your organization to be imported

keytool -importcert -alias 'ahsca' -keystore '/u01/wforce/TST/17.0/workforce.keystore' -storepass <password> -file '/u01/wforce/TST/17.0/newAffirmTrust_OV1.cer'
keytool -importcert -alias 'AffirmTrustOV1' -keystore '/u01/wforce/TST/17.0/workforce.keystore' -storepass <password> -file '/u01/wforce/TST/17.0/newAffirmTrust_OV1.cer'

4) Once you have the signed key from Step 2. Use the following command to import the key into Keystore

keytool -importcert -alias '<hostname>' -keystore '/u01/wforce/TST/17.0/workforce.keystore' -storepass <password> -file '/u01/wforce/TST/17.0/<hostname>.p7b'

5) Once you have the key imported. Use the following command to convert the signed key into PK12 format as workforce will need to be in this format

keytool -importkeystore -srckeystore '/u01/wforce/TST/17.0/workforce.keystore' -destkeystore '/u01/wforce/TST/17.0/<hostname>.p12' -srcstoretype JKS -deststoretype PKCS12 -srcalias 'lkmvwtabsdev21' -srcstorepass <password> -srckeypass <password> -deststorepass <password>

6) Use the ant command to import the certificate back in the keystore

./ant importTomcatCertificate -Dcertificate.file=/u01/wforce/TST/17.0/<hostname>.p12 -Dcertificate.pass=<password> -Dkeystore.alias=<hostname>


7) Important Step.

cat /u01/wforce/TST/17.0/catalina_base/conf/server.xml |grep keyAlias -A2 -B2

     keystoreFile="/u01/wforce/TST/17.0/workforce.keystore"
     keystorePass="<password>" algorithm="SunX509"
            keyAlias="<hostname>"                         <---- Change to <hostname> as shown
            compression="on"
            compressionMinSize="2048"

8) bounce back the Empcenter Services

/u01/wforce/TST/17.0/wfsctl restart



Thursday, 23 June 2016

New Load Balancer Testing for PeopleSoft.



New Load Balancer Testing for PeopleSoft.

siege -c255  "http://hrdmo.ps.com:16000/psp/hrdmo/?cmd=login POST userid=PS&pwd=PS"

HTTP/1.1 200   4.72 secs:    2179 bytes ==> POST http://hrdmo.ps.com:16000/psp/hrdmo/?cmd=login
HTTP/1.1 200   4.73 secs:    2179 bytes ==> POST http://hrdmo.ps.com:16000/psp/hrdmo/?cmd=login
HTTP/1.1 200   4.80 secs:    2179 bytes ==> POST http://hrdmo.ps.com:16000/psp/hrdmo/?cmd=login
HTTP/1.1 200   4.82 secs:    2179 bytes ==> POST http://hrdmo.ps.com:16000/psp/hrdmo/?cmd=login
HTTP/1.1 200   4.85 secs:    2179 bytes ==> POST http://hrdmo.ps.com:16000/psp/hrdmo/?cmd=login
HTTP/1.1 200   4.83 secs:    2179 bytes ==> POST http://hrdmo.ps.com:16000/psp/hrdmo/?cmd=login
HTTP/1.1 200   5.56 secs:    2179 bytes ==> POST http://hrdmo.ps.com:16000/psp/hrdmo/?cmd=login
HTTP/1.1 200   4.98 secs:    2179 bytes ==> POST http://hrdmo.ps.com:16000/psp/hrdmo/?cmd=login
HTTP/1.1 200   4.95 secs:    2179 bytes ==> POST http://hrdmo.ps.com:16000/psp/hrdmo/?cmd=login
HTTP/1.1 200   5.00 secs:    2179 bytes ==> POST http://hrdmo.ps.com:16000/psp/hrdmo/?cmd=login


help to do load testing for PeopleSoft applications











Thursday, 21 January 2016

RMAN Database Backup Script.

00 18 * * 6  nohup /home/oracle/scripts/backupscripts/backup_script_v5.ksh FSPRD 0 8 "/backups" "Emailid@domain.com" >> /tmp/FSPRD_nohup_rmanrun.log 1>&2 &

#!/bin/ksh
set -xv
export DB_NAME=$1;
export BKP_LEVEL=$2;
export PARALLEL=$3;
export FOLDER_PATH=$4;
export DBA_EMAIL="$5";
export PROCESS_NUMBER=$$;
mkdir -p "${FOLDER_PATH}/rman/${DB_NAME}/BACKUPS/LOGS/";
ORACLE_HOSTNAME=xyz; export ORACLE_HOSTNAME
ORACLE_UNQNAME=$DB_NAME; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=$DB_NAME; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
LOG_DATE=`date +%d%m%Y`
LOGFILE="${FOLDER_PATH}/rman/$DB_NAME/BACKUPS/LOGS/${ORACLE_UNQNAME}_${PROCESS_NUMBER}_LEVEL${BKP_LEVEL}_`date +%d%m%Y`.log"
TRACEFILE="${FOLDER_PATH}/rman/$DB_NAME/BACKUPS/LOGS/${ORACLE_UNQNAME}_${PROCESS_NUMBER}_LEVEL${BKP_LEVEL}_TRACE_`date +%d%m%Y`.trc"
TIMETRACKER="${FOLDER_PATH}/rman/$DB_NAME/BACKUPS/LOGS/${ORACLE_UNQNAME}_${PROCESS_NUMBER}_TIME_TRACK_L${BKP_LEVEL}_`date +%d%m%Y`.log"

echo -e "  ${ORACLE_UNQNAME} LEVEL ${BKP_LEVEL} BACKUP START AND END TIME DETAILS" > $TIMETRACKER
echo  "====================================================" >> $TIMETRACKER
date >>$TIMETRACKER
rman target / catalog RMANCAT/<PASSWORD>@RMANDB USING $DB_NAME $BKP_LEVEL $PARALLEL "'$FOLDER_PATH'" trace=$TRACEFILE log=$LOGFILE <<EOF
run {
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '&4/rman/&1/BACKUPS/&1_snapshot_ctrl_file.ctl';
crosscheck backup;
crosscheck archivelog all;
CONFIGURE DEVICE TYPE DISK PARALLELISM &3 BACKUP TYPE TO BACKUPSET;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '&4/rman/&1/BACKUPS/L&2_%T_%d_%s_%p_%U';
backup incremental level &2 device type disk as compressed backupset database tag = 'weekly0';
sql 'alter system archive log current';
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '&4/rman/&1/BACKUPS/&2_ARCH_%T_%d_%s_%p_%U';
backup device type disk as compressed backupset archivelog all delete input tag L&2_ARCHIVE_LOGS;
delete noprompt obsolete device type disk;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '&4/rman/&1/BACKUPS/&2_CNTL_%T_%d_%s_%p_%U';
backup current controlfile tag L&2_CNT_FILE_BKP;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '&4/rman/&1/BACKUPS/&2_SPFILE_%T_%d_%s_%p_%U';
backup spfile tag L&2_SP_FILE_BKP;
}
EOF

date >> $TIMETRACKER
echo -e "\n====================================================\n\n" >> $TIMETRACKER
echo -e "\n  HISTORICAL RMAN BACKUP DETAILS " >> $TIMETRACKER
echo -e "====================================================\n" >> $TIMETRACKER
sqlplus -s \"/ as sysdba\"  @/home/oracle/scripts/backupscripts/rman_backup_info.sql >> $TIMETRACKER
echo -e "\n====================================================\n\n" >> $TIMETRACKER

echo -e "  ORA- ERROR DETAILS If ANY? " >> $TIMETRACKER
echo -e "====================================================\n" >> $TIMETRACKER
cat $TRACEFILE | grep ORA-  >> $TIMETRACKER
echo -e "====================================================\n\n" >> $TIMETRACKER

echo -e "  FEW LINES of LOG FILE " >> $TIMETRACKER
echo -e "====================================================\n" >> $TIMETRACKER
tail -20 $TRACEFILE >> $TIMETRACKER
echo -e "====================================================\n\n" >> $TIMETRACKER

error_count=$(cat $TRACEFILE | grep ORA- | wc -l);
if  [ $error_count -gt 0 ]; then
        mailx -s "RMAN Level ${BKP_LEVEL} BACKUP FAILED FOR $DB_NAME ${LOG_DATE}" -r noreply@domain.com  ${DBA_EMAIL} < $TIMETRACKER
else
        mailx -s "RMAN Level ${BKP_LEVEL} BACKUP SUCCESS FOR $DB_NAME ${LOG_DATE}" -r noreply@domain.com  ${DBA_EMAIL} < $TIMETRACKER
        cp /backups/rman/FSPRD/BACKUPS/*CNTL* /backups/rman/FSPRD/BACKUPS/CNTLFILESAVE/
        find /backups/rman/FSPRD/BACKUPS/CNTLFILESAVE/ -name '*CNTL*' -type f -mtime +30 -exec rm {} \;
        nohup sh -xv /home/oracle/scripts/syncdrincr.ksh 1>&2 > /tmp/trace_dr_backups.log &
fi

exit