您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關Linux Shell腳本監控WAS的運行狀態是怎么樣的,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。
原理:通過調用 WAS 自帶的腳本 wsadmin.sh 來獲取實例的狀態
操作系統版本:
[root]# head -1 /etc/redhat-release Red Hat Enterprise Linux Server release 5.3 (Tikanga) |
WAS 版本:
[root]# /opt/IBM/WebSphere/AppServer/bin/versionInfo.sh | grep -A 3 "Installed Product" Installed Product -------------------------------------------------------------------------------- Name IBM WebSphere Application Server - ND Version 7.0.0.25 |
代碼:
check_was_state.sh
#!/bin/ksh WAS_IP="192.168.222.3" WAS_USERNAME="wasadmin" WAS_PASSWORD="wasadmin" WAS_INSTANCE_NAME="SampleServer1" WSADMIN="/opt/IBM/WebSphere/AppServer/bin/wsadmin.sh" FILE_STAT_LOG=was_stat_`date +"%Y%m%d_%H%M%S"`.log $WSADMIN -lang jython -host $WAS_IP -user $WAS_USERNAME -password $WAS_PASSWORD -f check_was_state.py > $FILE_STAT_LOG 2>&1 grep "${WAS_INSTANCE_NAME}: STARTED" $FILE_STAT_LOG > /dev/null 2>&1 if [ $? == 0 ]; then echo "$WAS_IP $WAS_INSTANCE_NAME status is OK" else echo "$WAS_IP $WAS_INSTANCE_NAME status is not OK" fi
check_was_state.py
import AdminUtilities # List servers with specified server type servers = AdminTask.listServers('-serverType APPLICATION_SERVER') # Convert Jython string to list servers = AdminUtilities.convertToList(servers) # Loop through each server in server list for aServer in servers: # Obtain server and node names sname = aServer[0:aServer.find("(")] nname = aServer[aServer.find("nodes/")+6:aServer.find("servers/")-1] runningServer = AdminControl.queryNames("type=Server,node=" + nname + ",name=" + sname + ",*") if (len(runningServer) > 0): serverState = AdminControl.getAttribute(runningServer, "state") else: serverState = "STOPPED" # endIf # Two different states: STARTED, STOPPED print "%s: %s" % (sname,serverState) #endFor
看完上述內容,你們對Linux Shell腳本監控WAS的運行狀態是怎么樣的有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注億速云行業資訊頻道,感謝大家的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。