Salesforce

Basic OEJMX Queries for inspecting and stopping PASOE agents

« Go Back

Information

 
TitleBasic OEJMX Queries for inspecting and stopping PASOE agents
URL NameBasic-OEJMX-Queries-for-inspecting-and-stopping-PASOE-agents
Article Number000114863
EnvironmentProduct: OpenEdge
Version: 11.7.3, 11.7.4, 11.7.5, 11.7.6, 11.7.7, 11.7.8, 11.7.9, 11.7.10, 11.7.11, 12.x
OS: All Supported Platforms
Question/Problem Description
This article provides some basic OEJMX queries that can be used to query a pasoe broker for agent list, status and stacks.
 
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
In the below examples, UNIX naming and pathing syntax is used.  For Windows environments, use proper slash direction and path indicators and use oejmx.bat instead of oejmx.sh.

Get a list of agents

Query file looks like:
{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgents","<agent-name>"]}
Example:
{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgents","oepas1"]}

Call looks like:
<instance-dir>/bin/oejmx.sh -R -Q <input-query-path\file> -O <output-path\file>
Example:
/usr/wrk/oepas1/bin/oejmx.sh -R -Q /usr/wrk/oepas1/temp/getAgents_oepas1.qry -O /usr/wrk/oepas1/temp/getAgents_oepas1.out
Output looks like:
{"getAgents":{"agents":[{"agentId":"xloyKr55Rpagx7qFYbo9bw","pid":"12337","state":"AVAILABLE"}]}}

Use AgentId in subsequent queries.  AgentId and PID are interchangeable with these queries, however pasoe will often reuse the same PID so it's not a unique identifier of an agent.  AgentId is unique.

Get Stacks:
To get a list of the stacks on all threads in a multi-session agent...

Query looks like:
{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgentStacks","<AgentId>"]}
Example:
{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgentStacks","xloyKr55Rpagx7qFYbo9bw"]}
Call looks like:
<instance-dir>/bin/oejmx.sh -R -Q <input-query-path\file> -O <output-path\file>
Example:
/usr/wrk/oepas1/bin/oejmx.sh -R -Q /usr/wrk/oepas1/temp/getAgentStacks_oepas1.qry -O /usr/wrk/oepas1/temp/getAgentStacks_oepas1.out
Output looks like:
{"getAgentStacks":{"ABLStacks":[{"Status":"Executing","Databases":[{"DBNAME":"/usr/wrk/oepas1/dbs/db1","DBTYPE":"PROGRESS","LDBNAME":"db1"}],"BrokerSessionId":"0B6911916EE1A13012E747DC77556515094A5B2672F8.oepas1","Callstack":[{"Line":14,"Routine":"server.p","Source":"/usr/wrk/oepas1/openedge/server.p"}],"StartupParams":"-pf /usr/dlc/startup.pf,-cpinternal ISO8859-1,-cpstream ISO8859-1,-cpcoll Basic,-cpcase Basic,-d mdy,-numsep 44,-numdec 46,(end .pf),-logginglevel 2,-logfile /usr/wrk/oepas100/logs/oepas1.agent.log,-uburl AppServerDC://0.0.0.0:60243/,-logname oepas1,-logentrytypes ASPlumbing,DB.Connects,-ubpropfile /usr/wrk/oepas1/conf/openedge.properties,-ASID 1,-ipver IPv4,-sectok XXXXXXXXXXXXXXXXXXXXXX,-T /usr/wrk/oepas1/temp,-db /usr/wrk/oepas1/dbs/db1","Propath":"/usr/wrk/oepas1/webapps/ROOT/WEB-INF/openedge,/usr/wrk/oepas1/openedge,/usr/dlc/tty,/usr/dlc/tty/OpenEdge.BusinessLogic.pl,/usr/dlc/tty/prodict.pl,/usr/dlc/tty/ablunit.pl,/usr/dlc/tty/adeshar.pl,/usr/dlc/tty/OpenEdge.Core.pl,/usr/dlc/tty/OpenEdge.ServerAdmin.pl,/usr/dlc/tty/adecomp.pl,/usr/dlc/tty/adecomm.pl,/usr/dlc/tty/adeedit.pl,/usr/dlc/tty/dataadmin.pl,/usr/dlc/tty/netlib/OpenEdge.Net.pl,/usr/dlc,/usr/dlc/bin","AgentSessionId":10,"OO4GLObjs":"","PersProcs":""}]}}

Get Statuses:
To get the status for all threads in a given agent...

Query looks like:
{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgentStatus","<AgentId>"]}
Example:
{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgentStatus","xloyKr55Rpagx7qFYbo9bw"]}
Call looks like:
<instance-dir>/bin/oejmx.sh -R -Q <input-query-path\file> -O <output-path\file>
Example:
/usr/wrk/oepas1/bin/oejmx.sh -R -Q /usr/wrk/oepas1/temp/getAgentStatus_oepas1.qry -O /usr/wrk/oepas1/temp/getAgentStatus_oepas1.out
Output looks like:
{"getAgentStatus":{"sessions":5,"threads":5,"requests":5,"connections":5}}
Workaround
Notes
The following Linux scripts may be helpful to automate the use of the OEJMX API calls.
getagents.sh:
#!/bin/sh
# Set DLC and PATH. 
# If DLC is not /usr/dlc please adjust as necessary.
export DLC=/usr/dlc
export PATH=$DLC/bin:$PATH
# This checks if the PAS instance name was passed as the first arg for this script
if [ $1 != '' ]; then
    # The following line creates the get-agents.qry file with the supplied value for PAS instance name.
    echo '{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgents","'$1'"]}'>./get-agents.qry
else
        #If the get-agents.qry exists use its contents to get agent info.
        if [ -e 'get-agents.qry' ]; then 
                echo "Since no instance name was supplied as a parameter using existing get-agents.qry"
        else
                echo "You must supply the PAS instance name or an existing get-agents.qry must exist in this directory."
                read -p "What is the PAS instance name? " pasname
                echo '{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgents","'$pasname'"]}'>./get-agents.qry

        fi
fi

#Check to see if oejmx.sh is found in $PATH
if oejmx.sh -v oejmx.sh > /dev/null 2>&1; then #Test to see if the oejmx.sh script is in the $PATH
  echo oejmx.sh is available
else
  echo "oejmx.sh not found in $PATH"
  #This script use the PASdirinfo file if one exists.
  if [ -e ./PASdirinfo ]; then 
        pasdir=`cat ./PASdirinfo`
  else
        #If no PASdirinfo file exists prompt the user then generate the file
        read -p "What is the PAS instance directory path? " pasdir 
  fi
  #Test if the value supplied by user for pasdir exists and if so write that info the PASdirinfo file
  if [ -e $pasdir ]; then
        echo $pasdir >./PASdirinfo
  fi
        #Test again to see if the oejmx.sh can be found
        if oejmx.sh -v oejmx.sh > /dev/null 2>&1; then
                echo "found oejmx.sh"
        fi
fi
#If pasdir is not blank and the directory exists query the PAS and generate the get-agents.out file
if [ $pasdir != '' ] && [ -e $pasdir ]; then
        $pasdir/bin/oejmx.sh -R -Q ./get-agents.qry -O ./get-agents.out
else
        echo "PASDIR not correctly set."
        exit
fi
#Display the contents of the get-agents.out file
cat get-agents.out
#end of getagents.sh

getstacks.sh:
#!/bin/sh
# Set DLC and PATH. 
# If DLC is not /usr/dlc please adjust as necessary.
export DLC=/usr/dlc
export PATH=$DLC/bin:$PATH
#If a PASdirinfo file already exists in the directory read the contents into the pasdir variable
if [ -e ./PASdirinfo ]; then
  pasdir=`cat ./PASdirinfo`
else
  #If no PASdirinfo file exists prompt the user then generate the file
  read -p "What is the PAS instance directory path? " pasdir
        if [  -e $pasdir ]; then
           echo $pasdir > ./PASdirinfo
        else
           echo "PASDIR does not exist"
        fi
                #Test again to see if the oejmx.sh can be found
                if oejmx.sh -v oejmx.sh > /dev/null 2>&1; then
                        echo "found oejmx.sh"
                fi
fi
#If the get-agents.out file exists then extract the PAS instance name from the file
if [ -e ./get-agents.out ]; then
        #Grab the agentID value from the get-agents.out
        new=`awk -F \" '{print $8}' get-agents.out`
        var='{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgentStacks","'${new}'"]}'
        echo $var > ./stacks.qry
else
        echo "No get-agents.qry exists"
        read -p "What is the PAS instance name? " pasname
        if [ $pasname != '' ]; then
                echo '{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgents","'$pasname'"]}'>./get-agents.qry
                echo "Using get-agents.out to supply agentID"\
                #Check to see if oejmx.sh is found in $PATH
                if oejmx.sh -v oejmx.sh > /dev/null 2>&1; then
                  echo "oejmx.sh found in $PATH"
                else
                  echo "oejmx.sh not found in $PATH"

                #If pasdir is not blank and the directory exists query the PAS and generate the get-agents.out file
                if [ $pasdir != '' ] && [ -e $pasdir ]; then
                        $pasdir/bin/oejmx.sh -R -Q ./get-agents.qry -O ./get-agents.out
                        echo "made new get-agents.out"
                else
                        echo "PASDIR not correctly set."
                        exit
                fi
                
                #Grab the agentID value from the get-agents.out
                new=`awk -F \" '{print $8}' get-agents.out`

                #Concatenate strings and output to stacks.qry file
                var='{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgentStacks","'${new}'"]}'
                echo $var > ./stacks.qry
        fi
fi

    #Test if the value supplied by user for pasdir exists and if so write that info the PASdirinfo file
    if [ -e ./PASdirinfo ]; then
        pasdir=`cat ./PASdirinfo`
    fi
fi
#Initiate the OEJMX query
"$pasdir/bin/oejmx.sh" -R -Q ./stacks.qry -O ./stacks.out
cat ./stacks.out

#end of getstacks.sh

getstatus.sh:
#!/bin/sh
# Set DLC and PATH. 
# If DLC is not /usr/dlc please adjust as necessary.
export DLC=/usr/dlc
export PATH=$DLC/bin:$PATH

#Test to see if the get-agents.out exists. If yes use its contents
if [ -e ./get-agents.out ]; then
# This checks if the PAS instance name was passed as the first arg for this script, if yes create the get-agents.out file
new=`awk -F \" '{print $8}' get-agents.out`
else
        echo "No get-agents.qry exists"

        #If no PASdirinfo file exists prompt the user then generate the file
        read -p "What is the PAS instance name? " pasname
        if [ $pasname != '' ]; then
                #Concatenate strings and output to get-agents.qry file
                echo '{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgents","'$pasname'"]}'>./get-agents.qry
                echo "Using get-agents.out to supply agentID"
                #Invoke OEJMX to get the agentID
                /usr/wrk/oepas1/bin/oejmx.sh -R -Q ./get-agents.qry -O ./get-agents.out
                new=`awk -F \" '{print $8}' get-agents.out`
        fi
fi
#Concatenate strings and output to status.qry file
var='{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgentStatus","'${new}'"]}'
echo $var >status.qry

#Invoke OEJMX to get status of Agent
/usr/wrk/oepas1/bin/oejmx.sh -R -Q ./status.qry -O ./status.out
cat ./status.out

#end of getstatus.sh
Keyword Phrase
Last Modified Date6/2/2023 5:52 PM

Powered by