This shell script will display all the instances of Weblogic server (Admin & Managed Servers) running on any physical or virtual machine. This will capture the username which initiated the weblogic instance, PID of the weblogic instance and domain name of the weblogic instance.
The output format will look as below:
******************************************************************************
User | PID | Server Name | Domain Name
******************************************************************************
oracle | 2239 | AdminServer | /soa/data/domains/OSB_DEV1
oracle | 18406 | AdminServer | /soa/data/domains/UTIL_DEV1
oracle | 23326 | OSB_MngdSvr1 | /soa/data/domains/OSB_DEV1
oracle | 23888 | BAM_MngdSvr1 | /soa/data/domains/UTIL_DEV1
oracle | 23889 | B2B_MngdSvr1 | /soa/data/domains/UTIL_DEV1
oracle | 23953 | JMS_MngdSvr1 | /soa/data/domains/UTIL_DEV1
The BASH Shell script to get this output:
The output format will look as below:
******************************************************************************
User | PID | Server Name | Domain Name
******************************************************************************
oracle | 2239 | AdminServer | /soa/data/domains/OSB_DEV1
oracle | 18406 | AdminServer | /soa/data/domains/UTIL_DEV1
oracle | 23326 | OSB_MngdSvr1 | /soa/data/domains/OSB_DEV1
oracle | 23888 | BAM_MngdSvr1 | /soa/data/domains/UTIL_DEV1
oracle | 23889 | B2B_MngdSvr1 | /soa/data/domains/UTIL_DEV1
oracle | 23953 | JMS_MngdSvr1 | /soa/data/domains/UTIL_DEV1
The BASH Shell script to get this output:
#!/bin/bash regex="^([a-zA-Z]*)\s+([0-9]*)\s[0-9]* .*-Dweblogic\.Name=([a-zA-Z0-9_]*).*\s-Ddomain\.home=([a-zA-Z0-9_\.\/]*).*weblogic\.Server$" javap=`ps -ef | grep -v grep | grep weblogic.Server` IFS=$'\n' echo "******************************************************************************" printf " User | PID | Server Name | Domain Name\n" echo "******************************************************************************" for jp in $javap do if [[ $jp =~ $regex ]]; then n=${#BASH_REMATCH[*]} #echo "${BASH_REMATCH[1]} | ${BASH_REMATCH[2]} | ${BASH_REMATCH[3]} | ${BASH_REMATCH[4]}" printf "%+10s | %-8s | %-15s | %-30s\n" ${BASH_REMATCH[1]} ${BASH_REMATCH[2]} ${BASH_REMATCH[3]} ${BASH_REMATCH[4]} fi done |
No comments:
Post a Comment