您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
今天就跟大家聊聊有关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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。