Showing posts with label Script. Show all posts
Showing posts with label Script. Show all posts

Tuesday, 17 April 2018

Python script to generate thread dump in Weblogic Server.

Python script to generate thread dump as below:

Step 1: Create a script vi ThreadDump.py in Unix terminal and copy paste the below snippet

$ vi ThreadDump.py
connect('weblogic','weblogic','t3://localhost:7001')
cd('Servers')
cd('AdminServer')
threadDump(writeToFile='true',fileName='ThreadDump.txt')
disconnect()
exit()
Edit the username, password, Adminserver URL as per your environment

Step 2: Now run setWLSEnv.sh script to setup the classpath & path


/u01/app/oracle/product/fmw/wlserver_10.3/server/bin

$ ../setWLSEnv.sh
Step 3 : Finally run the below command to generate the thread dump using WLST

$ java weblogic.WLST ThreadDump.py

Friday, 6 April 2018

Script to get the CPU utilization status of any process running on a linux system

Steps to get the CPU utilization status of any process running on a linux system

1.Copy and paste the below code onto the linux server using vi editor


$ cd /tmp/scripts/


$ vi cpuUtilization.sh
#!/bin/sh

var1=`ps -ef | grep Dweblogic.Name | grep Server_1| awk '{print $2}'`

var2=` ps -ef | grep Dweblogic.Name |grep Server_2|awk '{print $2}'`

time=`date +%d-%m-%y-%H:%M:%S`


ps -eLo pid,ppid,tid,pcpu,comm | grep "$var1" > /u01/apps/oracle/Server_CPU_Utilization/Server_1_"$time"

ps -eLo pid,ppid,tid,pcpu,comm | grep "$var2" > /u01/apps/oracle_oc/Server_CPU_Utilization/Server_2_"$time"
2. Now set a cronjob to get the script executed automatically after a specified interval say 5 mins

$ */5,* * * *  /tmp/scripts/cpuUtilization.sh

3. The output of the script would be append to the files at the location

/u01/apps/oracle/Server_CPU_Utilization

Note: Steps to set cronjob “At every 5th minute.”



Script to get alert when response time exceeds the threshold limit using weblogic server access.log

Steps to get mail alert using the weblogic server access.log when response time exceeds the threshold limit

1.Copy and paste the below code onto the weblogic server using vi editor

vi /u01/apps/oracle_oc/user_projects/domains/Domain_Production/responseTimeAlert.sh
----------------------------------------------------------------------
#/bin/sh
dat=`date +"%y-%m-%d"`
dat1=`date +"%H:%M:"`
var=`grep $dat1 /u01/apps/oracle_oc/user_projects/domains/Domain_Production/servers/Managed_Server/logs/access.log | grep "/gb/en.html" | awk '$3>50' > /export/home/weblogic/Scripts/Alert_ResponseTime/Alert_ResponseTime_$dat`

echo $var
if [ -s /export/home/weblogic/Scripts/Alert_ResponseTime/Alert_ResponseTime_$dat ]
then
echo $dat
mailx -s 'The Response time of below given urls is greater than 50 sec' Website.Support@gmail.com <  /export/home/weblogic/Scripts/Alert_ResponseTime/Alert_ResponseTime_$dat
 <fi
------------------------------------------------------------------------

2. Configure the cronjob for the script created

* * * * * /u01/apps/oracle_oc/user_projects/domains/Domain_Production/responseTimeAlert.sh

3. Whenever the response time for any request exceeds 50 sec, a mail would be triggered.

Monday, 2 April 2018

How to Decrypt password of Weblogic 8.1 Admin Console?

Steps to create a script and decrypt the password encrypted(3DES)



1. Copy the password from the config.xml file $BEA_MIDDLEWARE_DOMAIN/user_projects/domains//config/

2. Change the directory in the terminal to the weblogic domain directory/security

"cd $BEA_MIDDLEWARE_DOMAIN/user_projects/domains/
/security/" so as to provide the path of the SerializedSystemIni.dat file

3. Create a java script file using the vi editor command "$vi SsmDecrypt.java" 

Copy and paste the below code 

***************************************************************
import weblogic.security.internal.SerializedSystemIni;
import weblogic.security.internal.*;
import weblogic.security.internal.encryption.*;

public class SsmDecrypt
{
public static EncryptionService es = null;
public static ClearOrEncryptedService ces = null;

public static void main(String args[])
{
String s = null;
if(args.length == 0)
System.out.println("Enter Password");
else
if(args.length == 1)
s = args[0];
else
System.err.println("Usage: java Decrypt [ password ]");
es = SerializedSystemIni.getExistingEncryptionService();
if(es == null)
{
System.err.println("Unable to initialize encryption service");
return;
}
ces = new ClearOrEncryptedService(es);
if(s != null)
System.out.println("\nDecrypted Password is:"+ces.decrypt(s));
}
}
*************************************************************

4. Execute the below command along with the encrypted password

$
java SsmDecrypt <{3DEX}password>
Example

$java SsmDecrypt {3DES}ChApor4ZjYQ=

Output
Decrypted Password is:xxxxxxxx

Sunday, 1 April 2018

How to Decrypt password of Weblogic 11g Admin Console from any path in the terminal?

Steps to create a script and decrypt the password encrypted(AES)


1. Copy the password from the boot.properties file in the path $WLS_MIDDLEWARE_DOMAIN/user_projects/domains/Domain_Name/servers/AdminServer/security/boot.properties

2. Change the directory in the terminal to the weblogic domain directory of which password is to be decrypted

"cd $WLS_MIDDLEWARE_DOMAIN/user_projects/domains/Domain_Name/

3. Create a python script file using the vi editor command "$vi DecryptTest.py" 

Copy and paste the below code 

*********************************************
import os
import weblogic.security.internal.SerializedSystemIni
import weblogic.security.internal.encryption.ClearOrEncryptedService

def decrypt(domainHomeName, encryptedPwd):
    domainHomeAbsolutePath = os.path.abspath(domainHomeName)
    encryptionService = weblogic.security.internal.SerializedSystemIni.getEncryptionService(domainHomeAbsolutePath)
    ces = weblogic.security.internal.encryption.ClearOrEncryptedService(encryptionService)
    clear = ces.decrypt(encryptedPwd)
    print "Decrypted Password:" + clear


try:
    if len(sys.argv) == 3:
        decrypt(sys.argv[1], sys.argv[2])
    else:
        print "INVALID ARGUMENTS"
        print " Usage: java weblogic.WLST DecryptTest.py <{AES}lS2Fkjs0z5pXl9FgAj/hQvmhP59Pdyj27QdWWFWIsPM\=>"
        print " Example:"
        print "java weblogic.WLST DecryptTest.py
<{AES}lS2Fkjs0z5pXl9FgAj/hQvmhP59Pdyj27QdWWFWIsPM\=>"

except:
    print "Unexpected error: ", sys.exc_info()[0]
    dumpStack()
    raise
**************************************************

4. Execute the below command and then enter the encrypted password copied from boot.properties file 

$java weblogic.WLST decrypttest.py <absolute path of Weblogic domain>


Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Output:-
Decrypted Password:xxxxxxxx


How to Decrypt password of Weblogic 11g Admin Console?



Steps to create a script and decrypt the password encrypted(AES)



1. Copy the password from the boot.properties file in the path $WLS_MIDDLEWARE_DOMAIN/user_projects/domains/Domain_Name/servers/AdminServer/security/boot.properties

2. Change the directory in the terminal to the weblogic domain directory/security

"cd $WLS_MIDDLEWARE_DOMAIN/user_projects/domains/Domain_Name
/security/

3. Create a python script file using the vi editor command "$vi DecryptScript.py"

Copy and paste the below code

******************************************

from weblogic.security.internal import *
from weblogic.security.internal.encryption import *

encryptionService = SerializedSystemIni.getEncryptionService(".")
clearOrEncryptService = ClearOrEncryptedService(encryptionService)

passwd = raw_input("Enter encrypted password of one which you wanted to decrypt : ")
plainpwd = passwd.replace("\\", "")

print "Plain Text password is: " + clearOrEncryptService.decrypt(plainpwd)

******************************************
*

4. Execute the below command and then enter the encrypted password copied from boot.properties file

$java weblogic.WLST DecryptScript.py


Initializing WebLogic Scripting Tool (WLST) ...
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands

Enter encrypted password of one which you wanted to decrypt : {AES}25YwE3caKyHO23Ym6LNNiLTPxKm7V3YhR4uZdzyjboo=

Output:-
Plain Text password is: XXXXXXXXX



All about WebLogic t3 and t3s Protocol

WebLogic's  implementation of the RMI specification uses a proprietary protocol known as T3. You can think of T3 (and secure T3S) as a l...