Friday, August 19, 2011

Script to check the status of application in weblogic domain & send email

Place the script under *\wlserver_10*\common\bin
Trigger it like wlst.sh robin.py (for windows: wlst.cmd robin.py)
To redirect the output to a file  ./wlst.sh robin.py > robin.log
To send by email  mailx -s "status" "robin4444@blogspot.com" < robin.log

below is robin.py code

#wlst script to check status of deployed applications

import os
import sys

username='weblogic'
password='welcome1'
url='t3://localhost:7001'
connect(username, password, url)
print ' Application Deployed '

cd("AppDeployments")
app = ls(returnMap='true')

domainRuntime()

cd("AppRuntimeStateRuntime/AppRuntimeStateRuntime")

print ' Targetted on Admin '
i=1

for appName in app:
        appState = cmo.getIntendedState(appName, "AdminServer")
        print appName, '','==>',     appState

i=i+1
print ' '
print ' Targetted on Cluster '
i=1

for appName in app:
        appState = cmo.getIntendedState(appName, "new_Cluster_1")
        print appName, '','==>',     appState

i=i+1
print ' '
print ' visit robin4444.blogspot.com today '


change the below values to suite your respective domain's values
weblogic welcome1 t3://localhost:7001 AdminServer new_Cluster_1

so, Usage will be like   
./wlst.sh robin.py > robin.log; mailx -s "status" "robin4444@blogspot.com" < robin.log

1 comment:

Blogger said...

BlueHost is ultimately the best website hosting provider for any hosting services you need.