zoukankan      html  css  js  c++  java
  • 定期访问WebLogic Server返回状态的脚本

    在运维过程中,经常要获悉WebLogic Server的状态以便于主动的维护,本文通过weblogic WLST脚本初步设计了一下

    脚本大概为2个,一是WLST的py脚本,getStates.py

    connect('weblogic','weblogic12','localhost:7001')
    serverRuntime()
    state('AdminServer')

    另一个是linux的sh脚本

    #!/bin/bash
    . /home/weblogic/Oracle/Middleware/user_projects/domains/base_domain/bin/setDomainEnv.sh
    cd /home/weblogic/WLST
    while [ true ]; do
    /bin/sleep 60
    java weblogic.WLST /home/weblogic/WLST/getStates.py > /home/weblogic/WLST/result.log
    result=$(grep "RUNNING" /home/weblogic/WLST/result.log | wc -l)

    echo "*************** $result"
    if [ "$result" = "1" ]; then
    echo "Connecting successfully"
    else
    echo " ======= Connecting fail ========"
    fi

    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 ========

  • 相关阅读:
    WPF DataGrid根据内容设置行颜色
    wpf: DataGridTextColumn 数字格式显示,编辑时取消格式(StringFormat)
    关于wpf,datagrid,双向数据绑定用法解决方案
    AddTransient、AddSingleton、AddScoped 三者都应该在什么场景下使用
    Fetch API 使用 fatch 函数调用 .netcore WebApi接口报错:Failed to fetch
    ASP.NET Core 中使用Session会话
    利用 Google Chart API 生成二维码大小不一致
    Razor Page 文件
    asp.net core 的 razor pages 如何使用ajax调用后台方法
    asp.net core 发布到iis session无法传递的问题
  • 原文地址:https://www.cnblogs.com/ericnie/p/5282706.html
Copyright © 2011-2022 走看看