Saturday, September 14, 2013

Monitor Weblogic through the command line

Everything that is visible through the Weblogic admin console (http://reedi: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 java environment

There is a script for setting the CLASSPATH and PATH so that this tool can work. On pitblade, this 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

Sample commands

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
        ClasspathServletDisabled: false
        ClientCertProxyEnabled: false
        Cluster:
        ClusterRuntime:
        ClusterWeight: 100
        CompleteCOMMessageTimeout: -1
        CompleteHTTPMessageTimeout: -1
        CompleteIIOPMessageTimeout: -1
        CompleteMessageTimeout: 60
        CompleteT3MessageTimeout: -1
        CustomIdentityKeyStoreFileName:
        CustomIdentityKeyStorePassPhrase:
        CustomIdentityKeyStoreType:
        CustomTrustKeyStoreFileName:
        CustomTrustKeyStorePassPhrase:
        CustomTrustKeyStoreType:
        DefaultIIOPPassword:
        DefaultIIOPUser:
        DefaultInternalServletsDisabled: false
        DefaultProtocol: t3
        DefaultSecureProtocol: t3s
        DefaultTGIOPPassword: ******
        DefaultTGIOPUser: guest
        DomainLogFilter:
        EnabledForDomainLog: true
        ExecuteQueues: weblogic.kernel.Default
        ExpectedToRun: true
        ExternalDNSName:
        ExtraEjbcOptions:
        ExtraRmicOptions:
        GracefulShutdownTimeout: 10
        HealthCheckIntervalSeconds: 180
        HealthCheckTimeoutSeconds: 60
        HttpdEnabled: true
        IIOP: myserver
        IIOPEnabled: true
        IdleConnectionTimeout: 65
        IdleIIOPConnectionTimeout: -1
        IgnoreSessionsDuringShutdown: true
        InstrumentStackTraceEnabled: true
        InterfaceAddress:
        JDBCLogFileName: myserver/jdbc.log
        JDBCLoggingEnabled: false
        JMSDefaultConnectionFactoriesEnabled: true
        JNDITransportableObjectFactoryList:
        JavaCompiler: javac
        JavaCompilerPostClassPath:
        JavaCompilerPreClassPath:
        JavaStandardTrustKeyStorePassPhrase:
        KeyStores: DemoIdentityAndDemoTrust
        ListenAddress:
        ListenDelaySecs: 0
        ListenPort: 7001
        ListenPortEnabled: true
        Log: myserver
        LogRemoteExceptionsEnabled: false
        LoginTimeout: 1000
        LoginTimeoutMillis: 5000
        LowMemoryGCThreshold: 5
        LowMemoryGranularityLevel: 5
        LowMemorySampleSize: 10
        LowMemoryTimeInterval: 3600
        MSIFileReplicationEnabled: false
        Machine:
        ManagedServerIndependenceEnabled: true
        MaxCOMMessageSize: -1
        MaxHTTPMessageSize: -1
        MaxIIOPMessageSize: -1
        MaxMessageSize: 10000000
        MaxOpenSockCount: -1
        MaxT3MessageSize: -1
        MessageIdPrefixEnabled: true
        MuxerClass:
        Name: myserver
        NativeIOEnabled: true
        NetworkAccessPoints:
        Notes:
        ObjectName: myserver
        Parent: mydomain
        PreferredSecondaryGroup:
        Registered: true
        ReliableDeliveryPolicy:
        ReplicationGroup:
        RestartDelaySeconds: 0
        RestartIntervalSeconds: 3600
        RestartMax: 2
        ReverseDNSAllowed: false
        SSL: myserver
        ServerStart: myserver
        ServerVersion: 8.1.0.0
        SocketReaders: -1
        StagingMode:
        StartupMode: RUNNING
        StdoutDebugEnabled: false
        StdoutEnabled: true
        StdoutFormat: standard
        StdoutLogStack: true
        StdoutSeverityLevel: 32
        StuckThreadMaxTime: 600
        StuckThreadTimerInterval: 600
        TGIOPEnabled: false
        ThreadPoolPercentSocketReaders: 33
        TransactionLogFilePrefix: ./
        TransactionLogFileWritePolicy: Cache-Flush
        TunnelingClientPingSecs: 45
        TunnelingClientTimeoutSecs: 40
        TunnelingEnabled: false
        Type: Server
        UploadDirectoryName: ./myserver/upload
        VerboseEJBDeploymentEnabled: false
        WebServer: myserver
        WeblogicPluginEnabled: false
        XMLEntityCache:
        XMLRegistry:

get server stats

pitblade:II:root: > java weblogic.Admin -username user -password pass GET -pretty -type ServerRuntime
---------------------------
MBeanName: "mydomain:Location=myserver,Name=myserver,Type=ServerRuntime"
        ActivationTime: 1149801609891
        AdminServer: true
        AdminServerHost: pitblade
        AdminServerListenPort: 7001
        AdminServerListenPortSecure: false
        AdministrationPort: 9002
        AdministrationPortEnabled: false
        CachingDisabled: true
        ClusterRuntime:
        CurrentDirectory: /dsk2/local/bea81/user_projects/mydomain/.
        HealthState: State:HEALTH_OK,ReasonCode:[,]
        JVMID: -6864539854587189921/205.230.28.80/null/null/-840557488/9/7001/7001/-1/-1/7001/-1/-1/0/0/mydomain/myserver
        JVMRuntime: myserver
        ListenAddress: pitblade/205.230.28.80
        ListenPort: 7001
        ListenPortEnabled: true
        Name: myserver
        ObjectName: myserver
        OpenSocketsCurrentCount: 1
        Parent:
        Registered: true
        RestartsTotalCount: 0
        SSLListenAddress:
        SSLListenPort: 7002
        SSLListenPortEnabled: false
        ServerSecurityRuntime: myserver
        SocketsOpenedTotalCount: 1
        State: RUNNING
        Type: ServerRuntime
        WeblogicVersion: WebLogic Server 8.1  Thu Mar 20 23:06:05 PST 2003 246620
WebLogic XMLX Module 8.1  Thu Mar 20 23:06:05 PST 2003 246620

get queue stats

pitblade:II:root: > java weblogic.Admin -username user -password pass GET -pretty -type ExecuteQueueRuntime
---------------------------
MBeanName: "mydomain:Location=myserver,Name=weblogic.admin.RMI,ServerRuntime=myserver,Type=ExecuteQueueRuntime"
        CachingDisabled: true
        ExecuteThreadCurrentIdleCount: 2
        ExecuteThreads: [Lweblogic.management.runtime.ExecuteThread;@1ee2c2c
        Name: weblogic.admin.RMI
        ObjectName: weblogic.admin.RMI
        Parent: myserver
        PendingRequestCurrentCount: 0
        PendingRequestOldestTime: 1151346311947
        Registered: true
        ServicedRequestTotalCount: 25
        Type: ExecuteQueueRuntime
---------------------------
MBeanName: "mydomain:Location=myserver,Name=weblogic.kernel.System,ServerRuntime=myserver,Type=ExecuteQueueRuntime"
        CachingDisabled: true
        ExecuteThreadCurrentIdleCount: 5
        ExecuteThreads: [Lweblogic.management.runtime.ExecuteThread;@a9255c
        Name: weblogic.kernel.System
        ObjectName: weblogic.kernel.System
        Parent: myserver
        PendingRequestCurrentCount: 0
        PendingRequestOldestTime: 1151346312003
        Registered: true
        ServicedRequestTotalCount: 1581056
        Type: ExecuteQueueRuntime
---------------------------
MBeanName: "mydomain:Location=myserver,Name=weblogic.kernel.Default,ServerRuntime=myserver,Type=ExecuteQueueRuntime"
        CachingDisabled: true
        ExecuteThreadCurrentIdleCount: 15
        ExecuteThreads: [Lweblogic.management.runtime.ExecuteThread;@af72d8
        Name: weblogic.kernel.Default
        ObjectName: weblogic.kernel.Default
        Parent: myserver
        PendingRequestCurrentCount: 0
        PendingRequestOldestTime: 1151346312035
        Registered: true
        ServicedRequestTotalCount: 414117
        Type: ExecuteQueueRuntime
---------------------------
MBeanName: "mydomain:Location=myserver,Name=weblogic.admin.HTTP,ServerRuntime=myserver,Type=ExecuteQueueRuntime"
        CachingDisabled: true
        ExecuteThreadCurrentIdleCount: 2
        ExecuteThreads: [Lweblogic.management.runtime.ExecuteThread;@21e554
        Name: weblogic.admin.HTTP
        ObjectName: weblogic.admin.HTTP
        Parent: myserver
        PendingRequestCurrentCount: 0
        PendingRequestOldestTime: 1151346312061
        Registered: true
        ServicedRequestTotalCount: 5471
        Type: ExecuteQueueRuntime
---------------------------
MBeanName: "mydomain:Location=myserver,Name=weblogic.kernel.Non-Blocking,ServerRuntime=myserver,Type=ExecuteQueueRuntime"
        CachingDisabled: true
        ExecuteThreadCurrentIdleCount: 0
        ExecuteThreads: [Lweblogic.management.runtime.ExecuteThread;@14df764
        Name: weblogic.kernel.Non-Blocking
        ObjectName: weblogic.kernel.Non-Blocking
        Parent: myserver
        PendingRequestCurrentCount: 0
        PendingRequestOldestTime: 1151346312088
        Registered: true
        ServicedRequestTotalCount: 0
        Type: ExecuteQueueRuntime

get queue stats for just the default execute queue (the one that does application work)

This shows that there are 15 idle threads that can be used by the application and there are no pending requests. Also, this queue has serviced 415,607 requests.
pitblade:II:root: > java weblogic.Admin -username user -password pass -pretty GET -mbean "mydomain:Location=myserver,Name=weblogic.kernel.Default,ServerRuntime=myserver,Type=ExecuteQueueRuntime"
---------------------------
MBeanName: "mydomain:Location=myserver,Name=weblogic.kernel.Default,ServerRuntime=myserver,Type=ExecuteQueueRuntime"
        CachingDisabled: true
        ExecuteThreadCurrentIdleCount: 15
        ExecuteThreads: [Lweblogic.management.runtime.ExecuteThread;@48edb5
        Name: weblogic.kernel.Default
        ObjectName: weblogic.kernel.Default
        Parent: myserver
        PendingRequestCurrentCount: 0
        PendingRequestOldestTime: 1151352425362
        Registered: true
        ServicedRequestTotalCount: 415607
        Type: ExecuteQueueRuntime

The same query for production looks like this:
reedi.psmfc.org:C1:root: > java weblogic.Admin -url t3://reedi:7001 -username user -password pass -pretty GET -mbean "mydomain2:Location=myserver,Name=weblogic.kernel.Default,ServerRuntime=myserver,Type=ExecuteQueueRuntime"
---------------------------
MBeanName: "mydomain2:Location=myserver,Name=weblogic.kernel.Default,ServerRuntime=myserver,Type=ExecuteQueueRuntime"
        CachingDisabled: true
        ExecuteThreadCurrentIdleCount: 15
        ExecuteThreads: [Lweblogic.management.runtime.ExecuteThread;@48edb5
        Name: weblogic.kernel.Default
        ObjectName: weblogic.kernel.Default
        Parent: myserver
        PendingRequestCurrentCount: 0
        PendingRequestOldestTime: 1151355058643
        Registered: true
        ServicedRequestTotalCount: 796640
        Type: ExecuteQueueRuntime

get JVM stats

pitblade:II:root: > java weblogic.Admin -username user -password pass GET -pretty -type JVMRuntime
---------------------------
MBeanName: "mydomain:Location=myserver,Name=myserver,ServerRuntime=myserver,Type=JVMRuntime"
        CachingDisabled: true
        HeapFreeCurrent: 221438512
        HeapSizeCurrent: 265879552
        JavaVendor: Sun Microsystems Inc.
        JavaVersion: 1.4.1_02-ea
        Name: myserver
        OSName: SunOS
        OSVersion: 5.9
        ObjectName: myserver
        Parent: myserver
        Registered: true
        Type: JVMRuntime

On production that same command gets just the admin server JVM stats:
"$JAVA_HOME/bin/java" weblogic.Admin -url t3://reedi:7001 -username $WLS_USER -password $WLS_PW -pretty GET -type JVMRuntime
reedi.psmfc.org:C1:root: > ./watchHeap.sh
---------------------------
MBeanName: "mydomain2:Location=myserver,Name=myserver,ServerRuntime=myserver,Type=JVMRuntime"
        CachingDisabled: true
        HeapFreeCurrent: 16717904
        HeapSizeCurrent: 62840832
        JavaVendor: Sun Microsystems Inc.
        JavaVersion: 1.4.1_02-ea
        Name: myserver
        OSName: SunOS
        OSVersion: 5.9
        ObjectName: myserver
        Parent: myserver
        Registered: true
        Type: JVMRuntime
To get the JVM stats for the app servers that are doing the work, specify the adminurl to an appserver instead of the admin server:
"$JAVA_HOME/bin/java" weblogic.Admin -url t3://reedi:7003 -username $WLS_USER -password $WLS_PW -pretty GET -type JVMRuntime

reedi.psmfc.org:C1:root: > ./watchHeap.sh
---------------------------
MBeanName: "mydomain2:Location=appserver_reedi,Name=appserver_reedi,ServerRuntime=appserver_reedi,Type=JVMRuntime"
        CachingDisabled: true
        HeapFreeCurrent: 137764704
        HeapSizeCurrent: 265879552
        JavaVendor: Sun Microsystems Inc.
        JavaVersion: 1.4.1_02-ea
        Name: appserver_reedi
        OSName: SunOS
        OSVersion: 5.9
        ObjectName: appserver_reedi
        Parent: appserver_reedi
        Registered: true
        Type: JVMRuntime

get JDBC stats

We have connection pools configured, but are not using them, so this is not a useful source of information.
pitblade:II:root: > java weblogic.Admin -username user -password pass GET -pretty -type JDBCConnectionPoolRuntime
---------------------------
MBeanName: "mydomain:Location=myserver,Name=SOCKEYE,ServerRuntime=myserver,Type=JDBCConnectionPoolRuntime"
        ActiveConnectionsAverageCount: 0
        ActiveConnectionsCurrentCount: 0
        ActiveConnectionsHighCount: 0
        CachingDisabled: true
        ConnectionDelayTime: 360
        ConnectionLeakProfileCount: 0
        ConnectionsTotalCount: 1
        CurrCapacity: 1
        Enabled: true
        FailuresToReconnectCount: 0
        HighestNumAvailable: 1
        HighestNumUnavailable: 0
        LeakedConnectionCount: 0
        MaxCapacity: 30
        Name: SOCKEYE
        NumAvailable: 1
        NumUnavailable: 0
        ObjectName: SOCKEYE
        Parent: myserver
        PoolState: true
        Properties: database=sockeye::ptagis3;user=webjsp
        Registered: true
        State: Running
        Type: JDBCConnectionPoolRuntime
        VersionJDBCDriver: ca.edbc.jdbc.EdbcDriver
        WaitSecondsHighCount: 0
        WaitingForConnectionCurrentCount: 0
        WaitingForConnectionHighCount: 0
---------------------------
MBeanName: "mydomain:Location=myserver,Name=PTAGIS3_Blueback,ServerRuntime=myserver,Type=JDBCConnectionPoolRuntime"
        ActiveConnectionsAverageCount: 0
        ActiveConnectionsCurrentCount: 0
        ActiveConnectionsHighCount: 0
        CachingDisabled: true
        ConnectionDelayTime: 577
        ConnectionLeakProfileCount: 0
        ConnectionsTotalCount: 1
        CurrCapacity: 1
        Enabled: true
        FailuresToReconnectCount: 0
        HighestNumAvailable: 1
        HighestNumUnavailable: 0
        LeakedConnectionCount: 0
        MaxCapacity: 15
        Name: PTAGIS3_Blueback
        NumAvailable: 1
        NumUnavailable: 0
        ObjectName: PTAGIS3_Blueback
        Parent: myserver
        PoolState: true
        Properties: database=Blueback::ptagis3;user=webjsp
        Registered: true
        State: Running
        Type: JDBCConnectionPoolRuntime
        VersionJDBCDriver: ca.edbc.jdbc.EdbcDriver
        WaitSecondsHighCount: 0
        WaitingForConnectionCurrentCount: 0
        WaitingForConnectionHighCount: 0

No comments:

Post a Comment