Thursday, 29 March 2018

Automate monitoring weblogic parameters using scripts


    At times working with SOA, OSB which run on Weblogic, there arises a requirement to monitor your server health, pending messages in queues, thread performance, and not use the admin console in doing so.
    In such cases, there arises a demand for scripts to do the dirty work. In this post, we will cover a few basic scripts that can be implemented to monitor these parameters.
    Not going into much depth right now, please find the scripts that are a mix of wlst, shell and python.
    Little or basic knowledge of these languages is required to perform this activity immediately.
    These scripts are written in two parts for better understanding. The caller (shell) and the called (python).
    Effectively the .py files are passing connection parameters to invoke the specific mBeans.

  • ServerHealth Monitoring

    The .py file is being invoked by the .sh and the date is written to a temp file. The temp file is then acted upon to fetch the final value.
  • ##################################ServerHealth.sh##################################
    #ServerHealth.py
    connect(‘username’,’password’,’t3://:)
    domainRuntime()
    cd('/ServerRuntimes/soa_server1/ThreadPoolRuntime/ThreadPoolRuntime')
    x=get('ServerHealthState')
    print x
    # ServerHealth.sh
    #!/bin/bash
    /……path to your wlst…/bin/./wlst.sh ServerHealth.py >expendable.txt
    tail -1 expendable.txt |cut -d',' -f2 | cut -d':' -f2

  • Hogging thread monitor

  • This is an important parameter to identify the health of the server. Alerts can be configured if the configured parameter breaches its threshold. The same hierarchy is followed here as depicted above.
    ##################################hogging.sh##################################
    #hog.py
    connect(‘username’,’password’,’t3://:)
    domainRuntime()
    cd('/ServerRuntimes/soa_server1/ThreadPoolRuntime/ThreadPoolRuntime')
    x=get('HoggingThreadCount')
    print x
    #hogging.sh
    #!/bin/bash
    /……path to your wlst…/bin/./wlst.sh hog.py >expendable.txt
    tail -2 expendable.txt
  • Pending messages in queues.

  • ##################################RTEQ.sh################################## 
    RTEQ.py
    connect(‘username’,’password’,’t3://:)
    domainRuntime()
    cd('ServerRuntimes/soa_server1/JMSRuntime/*server1.jms/JMSServers/JMSServer-1/Destinations/*Module*')
    x=get('MessagesCurrentCount')
    print x
    #!/bin/bash
    /opt/egate/middleware/Oracle_OSB1/common/bin/./wlst.sh RTEQ.py >expendable.txt
    tail -1 expendable.txt
    rm expendable.txt

Happy scripting....Feel free to share your scripts so everyone can benefit. 

No comments:

Post a Comment