Bash script for listing running WebLogic Servers and Node Managers

Peter Lorenzen
05/09-2013

If you have many domains running on the same Linux server it can be difficult to see what is running and what is not. I have created a Bash script that lists all WebLogic Server and Node Manager processes.

I have tested it on Red Hat 5 and 6.

Here is an example output.

##############################################################################
# WebLogic Servers
# <owner>  <domain>  <server>  <pid>  <ports>
##############################################################################
prism01ora  prism01osb  AdminServer        23738  7011
prism01ora  prism01osb  prism01osbServer1  24018  7890,8011
prism01ora  prism01por  AdminServer        2943   7021
prism01ora  prism01por  prism01porServer1  28665  8021
prism01ora  prism01wls  AdminServer        22510  7001
prism01ora  prism01wls  prism01wlsServer1  22362  8001
prism02ora  prism02osb  AdminServer        14114  null
prism02ora  prism02osb  prism02osbServer1  14029  null
prism02ora  prism02wls  AdminServer        13396  null
prism02ora  prism02wls  prism02wlsServer1  16414  null

##############################################################################
# Node Managers
# <owner>  <mw_home>  <pid>  <port>
##############################################################################
prism01ora  /prism01/app/oracle/product/osb111  2473   5557
prism01ora  /prism01/app/oracle/product/por103  2552   5558
prism01ora  /prism01/app/oracle/product/wls103  2519   5556
prism02ora  /prism02/app/oracle/product/osb111  10430  null
prism02ora  /prism02/app/oracle/product/wls103  12603  null

The reason some ports are listed as null is because the script was run by the prism01ora Linux user, and some of the processes is owned by prism02ora. I use netstat to get the used ports, and it does not allow ordinary users to get information about processes of other users.

If you pass a parameter to the script it will generate kill commands for the processes. This works especially well if you have set “Max Restarts Within Interval” for the WebLogic Servers 🙂

Here is an example output:

##############################################################################
# WebLogic Servers
# <owner>  <domain>  <server>  <pid>  <ports>
##############################################################################
prism01ora  prism01osb  AdminServer        23738  7011       kill  -9  23738
prism01ora  prism01osb  prism01osbServer1  24018  7890,8011  kill  -9  24018
prism01ora  prism01por  AdminServer        2943   7021       kill  -9  2943
prism01ora  prism01por  prism01porServer1  28665  8021       kill  -9  28665
prism01ora  prism01wls  AdminServer        22510  7001       kill  -9  22510
prism01ora  prism01wls  prism01wlsServer1  22362  8001       kill  -9  22362
prism02ora  prism02osb  AdminServer        14114  null       kill  -9  14114
prism02ora  prism02osb  prism02osbServer1  14029  null       kill  -9  14029
prism02ora  prism02wls  AdminServer        13396  null       kill  -9  13396
prism02ora  prism02wls  prism02wlsServer1  16414  null       kill  -9  16414

##############################################################################
# Node Managers
# <owner>  <mw_home>  <pid>  <port>
##############################################################################
prism01ora  /prism01/app/oracle/product/osb111  2473   5557  kill  -9  2473
prism01ora  /prism01/app/oracle/product/por103  2552   5558  kill  -9  2552
prism01ora  /prism01/app/oracle/product/wls103  2519   5556  kill  -9  2519
prism02ora  /prism02/app/oracle/product/osb111  10430  null  kill  -9  10430
prism02ora  /prism02/app/oracle/product/wls103  12603  null  kill  -9  12603

I create two aliases in .bash_profile.

alias list='/prism01/app/oracle/scripts/listWebLogicServers.sh'
alias listk='/prism01/app/oracle/scripts/listWebLogicServers.sh kill'

{ 3 comments… read them below or add one }

coskan gundogar May 18, 2015 at 07:34

Very nice and helpful script, thanks for sharing

Ravi September 8, 2015 at 05:39

Thanks a lot.. it helped

Eric Mason January 3, 2018 at 17:27

This is a very good script. Appreciate.

Leave a Comment

Previous post:

Next post: