在運維過程中,經常要獲悉WebLogic Server的狀態以便於主動的維護,本文通過weblogic WLST腳本初步設計了一下
腳本大概為2個,一是WLST的py腳本,getStates.py
connect('weblogic','weblogic12','localhost:7001') |
另一個是linux的sh腳本
#!/bin/bash echo "*************** $result" done |
腳本為沒隔1分鍾去訪問一下weblogic server的AdminServer,獲取狀態信息,並把結果輸入到result.log
在實際的生產環境中,基本可以設置為5分鍾或者10分鍾定期訪問一下
另外需要注意的是,在網絡不是太穩定狀態下,建議修改腳本,5分鍾訪問如果失敗,再等5分鍾再訪問一次,如果還是失敗,就再等5分鍾再訪問一次,如果三次訪問
失敗,觸發后續的操作.
后續操作可以是echo,或者發郵件,或者調用api發短信到手機的模式.
試驗了一下,運行不多久把weblogic server直接給停了,輸出如下:
[weblogic@dockervm WLST]$ sh getStates.sh
*************** 1
Connecting successfully
*************** 1
Connecting successfully
*************** 1
Connecting successfully
*************** 1
Connecting successfully
Problem invoking WLST - Traceback (innermost last):
File "/home/weblogic/WLST/getStates.py", line 1, in ?
File "<iostream>", line 19, in connect
File "<iostream>", line 552, in raiseWLSTException
WLSTException: Error occurred while performing connect : Error getting the initial context. There is no server running at t3://localhost:7001 : t3://localhost:7001: Destination 0:0:0:0:0:0:0:1, 7001 unreachable; nested exception is:
java.net.ConnectException: Connection refused; No available router to destination
Use dumpStack() to view the full stacktrace :
*************** 0
======= Connecting fail ========