Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7092844
  • 博文数量: 3857
  • 博客积分: 6409
  • 博客等级: 准将
  • 技术积分: 15948
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 16:48
个人简介

迷彩 潜伏 隐蔽 伪装

文章分类

全部博文(3857)

文章存档

2017年(5)

2016年(63)

2015年(927)

2014年(677)

2013年(807)

2012年(1241)

2011年(67)

2010年(7)

2009年(36)

2008年(28)

分类: 系统运维

2014-08-12 15:47:26

原理:通过调用 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

点击(此处)折叠或打开

  1. #!/bin/ksh
  2. WAS_IP="192.168.222.3"
  3. WAS_USERNAME="wasadmin"
  4. WAS_PASSWORD="wasadmin"
  5. WAS_INSTANCE_NAME="SampleServer1"
  6. WSADMIN="/opt/IBM/WebSphere/AppServer/bin/wsadmin.sh"
  7. FILE_STAT_LOG=was_stat_`date +"%Y%m%d_%H%M%S"`.log
  8. $WSADMIN -lang jython -host $WAS_IP -user $WAS_USERNAME -password $WAS_PASSWORD -f check_was_state.py > $FILE_STAT_LOG 2>&1

  9. grep "${WAS_INSTANCE_NAME}: STARTED" $FILE_STAT_LOG > /dev/null 2>&1
  10. if [ $? == 0 ]; then
  11.     echo "$WAS_IP $WAS_INSTANCE_NAME status is OK"
  12. else
  13.     echo "$WAS_IP $WAS_INSTANCE_NAME status is not OK"
  14. fi

check_was_state.py

点击(此处)折叠或打开

  1. import AdminUtilities

  2. # List servers with specified server type
  3. servers = AdminTask.listServers('-serverType APPLICATION_SERVER')

  4. # Convert Jython string to list
  5. servers = AdminUtilities.convertToList(servers)

  6. # Loop through each server in server list
  7. for aServer in servers:
  8.     # Obtain server and node names
  9.     sname = aServer[0:aServer.find("(")]
  10.     nname = aServer[aServer.find("nodes/")+6:aServer.find("servers/")-1]
  11.     runningServer = AdminControl.queryNames("type=Server,node=" + nname + ",name=" + sname + ",*")
  12.     if (len(runningServer) > 0):
  13.         serverState = AdminControl.getAttribute(runningServer, "state")
  14.     else:
  15.         serverState = "STOPPED"
  16.     # endIf
  17.     # Two different states: STARTED, STOPPED
  18.     print "%s: %s" % (sname,serverState)
  19. #endFor


阅读(703) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~