Friday, 15 September 2017

Monitor Weblogic through the command line

Everything that is visible through the Weblogic admin console (http://localhost:7001/console) can be accessed through a command line java tool. This tool can be used to gather data about the weblogic servers via scripting.  There are at least two ways to get runtime monitoring data about weblogic processes. This document covers the use of the java classes that get information from management beans (mbeans). There is also a java tool that allows for browsing the mbean tree like an ftp client: Weblogic Scripting Tool (WLST).
Set the Environment:
Set the java environment
There is a script for setting the CLASSPATH and PATH so that this tool can work. On pitblade (WL Server), the setWLSEnv script is /dsk2/local/bea81/weblogic81/server/bin/setWLSEnv.sh
pitblade:II:root: > source setWLSEnv.sh
CLASSPATH=/dsk2/local/bea81/jdk141_02/lib/tools.jar:/dsk2/local/bea81/weblogic81/server/lib/weblogic_sp.jar:
/dsk2/local/bea81/weblogic81/server/lib/weblogic.jar:/dsk2/local/bea81/weblogic81/server/lib/ojdbc14.jar:
:/dsk1/AdvIngres/ing26/ingres/lib/edbc.jar:/dsk1/AdvIngres/ing26/ingres/lib/edbc.jar

PATH=/dsk2/local/bea81/weblogic81/server/bin:/dsk2/local/bea81/jdk141_02/jre/bin:/dsk2/local/bea81/jdk141_02/bin:
/dsk1/AdvIngres/ing26/ingres/bin:/dsk1/AdvIngres/ing26/ingres/utility:/dsk1/AdvIngres/ing26/ingres/files:
/dsk1/AdvIngres/ing26/ingres/lib:/dsk1/AdvIngres/ing26/ingres/SUNWspro/bin:/sbin:/usr/sbin:/bin:/usr/bin:
/usr/ucb:/etc:/usr/etc:/opt/fw/bin:/var/adm/psmfc/bin:/usr/openwin/bin:/usr/local/bin:/usr/psmfc/bin:
/usr/ccs/bin:/usr/lib/nis:/opt/gnu/bin:/usr/local/bin
Your environment has been set.
Verify that the java environment is set properly Success
pitblade:II:root: > java weblogic.Admin
weblogic.Admin is a command-line utility for managing WebLogic Server. Try:
        weblogic.Admin help LIFECYCLE   Starting, stopping, discovering servers
        weblogic.Admin help INFO        Retrieving info about WebLogic Server
        weblogic.Admin help JDBC        Working with JDBC connection pools
        weblogic.Admin help MBEAN       Working with WebLogic Server MBeans
        weblogic.Admin help CLUSTER     Working with clusters
        weblogic.Admin help ALL         Help for all commands
Usage: java [<SSL trust options>] weblogic.Admin
        [ [-url | -adminurl] [<protocol>://]<listen-address>:<port>]
        -username <username> -password <password>
        <COMMAND> <ARGUMENTS>
More info available at: http://e-docs.bea.com/wls/docs81/admin_ref/cli.html
Failure
pitblade:II:root: > java weblogic.Admin
Exception in thread “main” java.lang.NoClassDefFoundError: weblogic/Admin

get state
pitblade:II:root: > java weblogic.Admin -username user -password pass GETSTATE myserver
Current state of “myserver” : RUNNING

get server config
pitblade:II:root: > java weblogic.Admin -username user -password pass GET -pretty -type Server
—————————
MBeanName: “mydomain:Name=myserver,Type=Server”
        AcceptBacklog: 50
        AdministrationPort: 0
        AutoKillIfFailed: false
        AutoRestart: true
        COM: myserver
        COMEnabled: false
        CachingDisabled: true

No comments:

Post a Comment