kewlclassic
asked on
I need to write a python script using wsadmin which Stop's, Sync and Start's all the JVM on Node1 and then send an email after the task is done.
I am using WebSphere Application Server 7.0 running on windows. I need a wsadmin script which will do a Stop, Sync and Start of all the JVM on the node and then send an email after all the JVM's are started. I want the email notification include that it stopped, synced and started the JVM's.
Please help me out.
Thanks
Please help me out.
Thanks
ASKER
Thanks Walter. But the one which you attached above is just stopping and starting the node agent. I need one to stop all the JVM's on one node and then perform Sync and and then start all JVM's. Repeat this step for the other node as well. Once this is done, an email needs to be send confirming all task's has been done.
I don't know how to start writing a script. Any help will be much appreciated.
Thanks
I don't know how to start writing a script. Any help will be much appreciated.
Thanks
Ok, let me see if I can came with something. But I believe that you need to get started on reading anything you can from the first link.
To start creating a script, is pretty much what you saw above. Python is really a simple and very efficient and effective language.
http://www.python.org is the place to start with python.
Cheers,
Walter.
To start creating a script, is pretty much what you saw above. Python is really a simple and very efficient and effective language.
http://www.python.org is the place to start with python.
Cheers,
Walter.
ASKER
--Walter, thanks again.
I took few samples from this forum and wrote this one. Its works but needs modification.
I need this script to perform stop/sync/start and send email on node1 and then do the same stop/syn/start on node2 and send the email.
I took the wsadmin control commands from WebSphere Admin Console by stopping the JVM, syncing the nodes manually. But this needs to be refined. As i said above, if you can help me out using this as base script, I really appreciate it. The email thing is working fine. So please when you modify this, please include all the output results come out in email.
Thanks
Kewlclassic
########################## ########## ###
import smtplib
sender = 'xxxxxx@xxxx.com'
receivers = ['xxxxx@xxx.com.com']
#Create empty string
outmsg = ''
print "Stopping JVM's"
outmsg = outmsg + "Stopping JVM's\n"
AdminControl.invoke('WebSp here:name= ABCD_CM01, process=AB CD_CM01,pl atform=pro xy,node=ES B-node01,j 2eeType=J2 EEServer,v ersion=7.0 .0.25,type =Server,mb eanIdentif ier=cells/ ESB_MODL/n odes/esbmo dl-node01/ servers/HU B_CM01/ser ver.xml#Se rver_13637 03386444,c ell=ESB_MO DL,spec=1. 0,processT ype=Manage dProcess', 'stop')
serverCount= len(AdminControl.queryName s('type=Se rver,cell= ESB_MODL,n ode=esbmod l-node01,* ').split() )
while(serverCount > 1):
print serverCount
# outmsg = outmsg + serverCount+'\n'
print "Server is stopping"
outmsg = outmsg + 'Server is stopping\n'
sleep(5)
serverCount= len(AdminControl.queryName s('type=Se rver,cell= ESB_MODL,n ode=esbmod l-node01,* ').split() )
print "Server Stopped"
outmsg = outmsg + 'Server Stopped\n'
AdminControl.invoke('WebSp here:name= repository ,process=n odeagent,p latform=co mmon,node= tcmesbmodl -node01,ve rsion=5.0, type=Confi gRepositor y,mbeanIde ntifier=re pository,c ell=ESB_MO DL,spec=1. 0', 'refreshRepositoryEpoch')
AdminControl.invoke('WebSp here:name= cellSync,p rocess=dmg r,platform =common,no de=modl-dm gr-node,ve rsion=7.0. 0.25,type= CellSync,m beanIdenti fier=cellS ync,cell=E SB_MODL,sp ec=1.0', 'syncNode', '[tcmesbmodl-node01]', '[java.lang.String]')
Sync1 = AdminControl.completeObjec tName('typ e=NodeSync ,node=tcme sbmodl-nod e01,*')
SyncStatus =AdminControl.invoke(Sync1 , 'sync')
print "Sync Status"
outmsg = outmsg + 'Sync Status\n'
while(SyncStatus !="true"):
print "Sync in Progress"
# outmsg = outmsg + 'Sync in Progress\n'
sleep (5)
SyncStatus =AdminControl.invoke(Sync1 , 'sync')
print "Sync Complete"
outmsg = outmsg + 'Sync Complete\n'
print "Starting JVM's"
outmsg = outmsg + "Starting JVM's\n"
AdminControl.invoke('WebSp here:name= EFGH_CM01, process=EF GH_CM01,pl atform=com mon,node=t cmesbmodl- node01,dia gnosticPro vider=true ,version=7 .0.0.25,ty pe=NodeAge nt,mbeanId entifier=N odeAgent,c ell=ESB_MO DL,spec=1. 0', 'launchProcess', '[AGENTHUB_CM01]', '[java.lang.String]')
print "All JVM's Started"
outmsg = outmsg + "All JVM's Started\n"
# Send email
message = """From: From Person <xxxxx@xxx.com>
To: To Person <xxxxx@xxx.com
Subject: WESB MODL-Stop-Start-Sync Node1
%s
""" % ( outmsg )
try:
s = smtplib.SMTP('mail1.domain .com')
s.sendmail(sender, receivers, message)
print "Successfully sent email"
except SMTPException:
print "Error: unable to send email"
I took few samples from this forum and wrote this one. Its works but needs modification.
I need this script to perform stop/sync/start and send email on node1 and then do the same stop/syn/start on node2 and send the email.
I took the wsadmin control commands from WebSphere Admin Console by stopping the JVM, syncing the nodes manually. But this needs to be refined. As i said above, if you can help me out using this as base script, I really appreciate it. The email thing is working fine. So please when you modify this, please include all the output results come out in email.
Thanks
Kewlclassic
##########################
import smtplib
sender = 'xxxxxx@xxxx.com'
receivers = ['xxxxx@xxx.com.com']
#Create empty string
outmsg = ''
print "Stopping JVM's"
outmsg = outmsg + "Stopping JVM's\n"
AdminControl.invoke('WebSp
serverCount= len(AdminControl.queryName
while(serverCount > 1):
print serverCount
# outmsg = outmsg + serverCount+'\n'
print "Server is stopping"
outmsg = outmsg + 'Server is stopping\n'
sleep(5)
serverCount= len(AdminControl.queryName
print "Server Stopped"
outmsg = outmsg + 'Server Stopped\n'
AdminControl.invoke('WebSp
AdminControl.invoke('WebSp
Sync1 = AdminControl.completeObjec
SyncStatus =AdminControl.invoke(Sync1
print "Sync Status"
outmsg = outmsg + 'Sync Status\n'
while(SyncStatus !="true"):
print "Sync in Progress"
# outmsg = outmsg + 'Sync in Progress\n'
sleep (5)
SyncStatus =AdminControl.invoke(Sync1
print "Sync Complete"
outmsg = outmsg + 'Sync Complete\n'
print "Starting JVM's"
outmsg = outmsg + "Starting JVM's\n"
AdminControl.invoke('WebSp
print "All JVM's Started"
outmsg = outmsg + "All JVM's Started\n"
# Send email
message = """From: From Person <xxxxx@xxx.com>
To: To Person <xxxxx@xxx.com
Subject: WESB MODL-Stop-Start-Sync Node1
%s
""" % ( outmsg )
try:
s = smtplib.SMTP('mail1.domain
s.sendmail(sender, receivers, message)
print "Successfully sent email"
except SMTPException:
print "Error: unable to send email"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
just figured it out.
http://www.ibm.com/developerworks/websphere/library/samples/SampleScripts.html
http://wsadminlib.blogspot.com.br/2010/12/how-to-start-node-agent-using-scripting.html
Basic script from last link:
Open in new window