The below code takes the following parameters:
- Host Name in the pcHost parameter
- Port Number in the pcPort parameter(optional)
- Instance name in the pcInstance parameter
- Agent Id for a specific PASOE agent
- Session Id for a specific PASOE session
Then calls the appropriate REST API to fetch memory leak information from a PASOE session whose agent has the AblObjects tracking feature turned on.
USING OpenEdge.Net.HTTP.RequestBuilder.
USING openedge.net.http.IHttpRequest.
USING openedge.net.http.IHttpResponse.
USING Progress.Json.ObjectModel.*.
USING OpenEdge.Net.HTTP.ClientBuilder.
USING OpenEdge.Net.HTTP.ResponseBuilder.
USING OpenEdge.Net.HTTP.IHttpClientLibrary.
USING OpenEdge.Net.HTTP.Lib.ClientLibraryBuilder.
USING OpenEdge.Net.HTTP.Credentials.
DEFINE INPUT PARAMETER pcHost AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcPort AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcInstance AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcAgentId AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER piSessionId AS INTEGER NO-UNDO.
DEFINE VARIABLE oResponse AS IHttpResponse NO-UNDO.
DEFINE VARIABLE oEntity AS JsonObject NO-UNDO.
DEFINE VARIABLE oABLOutput AS JsonObject NO-UNDO.
DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO.
DEFINE VARIABLE oLib AS IHttpClientLibrary NO-UNDO.
DEFINE VARIABLE oCredentials AS Credentials NO-UNDO.
DEFINE VARIABLE cURL AS CHARACTER NO-UNDO.
DEFINE VARIABLE cMessage AS CHARACTER NO-UNDO.
// These TEMP-TABLEs, FIELDs and DATASET can be renamed as desired,
// However if you do you must use SERIALIZE-NAME with their original
// name or READ-JSON (below) will fail to import them correctly
//
// See examples of this in the Objects temp-table below where I had
// to avoid using ABL keywords for the Size, Source and Line fields
DEFINE TEMP-TABLE ABLObjects NO-UNDO
FIELD AgentSessionId AS INTEGER
FIELD tcInstanceName AS CHARACTER
FIELD tcAgentId AS CHARACTER
INDEX idxABLObjects IS PRIMARY UNIQUE
tcInstanceName tcAgentId AgentSessionId.
DEFINE TEMP-TABLE Objects NO-UNDO
FIELD ObjType AS CHARACTER LABEL "ObjectType" FORMAT "x(15)"
FIELD HandleId AS INTEGER FORMAT "zzzzzz9" LABEL "Handle"
FIELD tiSize AS INT64 SERIALIZE-NAME "Size" LABEL "Memory" FORMAT "->>,>>>,>>>,>>9"
FIELD tcSource AS CHARACTER SERIALIZE-NAME "Source" LABEL "Program" FORMAT "x(25)"
FIELD tiLine AS INTEGER SERIALIZE-NAME "Line" LABEL "Line No" FORMAT "zzzzzzzz9"
FIELD ABLObjectsId AS RECID.
DEFINE DATASET ABLOutput FOR ABLObjects, Objects
// Note the usage of the PARENT-ID-RELATION because there are no fields
// Otherwise to link the two tables
PARENT-ID-RELATION relABLObjects FOR ABLObjects, Objects
PARENT-ID-FIELD ABLObjectsId.
DEFINE QUERY qryLeaks FOR ABLObjects,Objects SCROLLING.
DEFINE BROWSE leaksBrowse QUERY qryLeaks
DISPLAY Objects.ObjType
Objects.tiSize
Objects.tcSource
Objects.tiLine
Objects.HandleId
WITH WIDTH 75 10 DOWN.
DEFINE FRAME fLeaks leaksBrowse.
cURL = "http://" + pcHost + (IF (pcPort GT "") EQ TRUE THEN ":" + pcPort ELSE "") +
"/oemanager/applications/" + pcInstance +
"/agents/" + pcAgentId + "/ABLObjects/sessions/" + STRING(piSessionId).
// You have to login with admin rights to the tomcat manager. If you've changed
// the admin user and/or password you'll need to use the modified credentials
oCredentials = NEW Credentials("http://localhost","tomcat","tomcat").
// Build and execute the request
ASSIGN oRequest = RequestBuilder:Get(cUrl)
:UsingBasicAuthentication(oCredentials)
:Request
oResponse = ResponseBuilder:Build():Response
oLib = ClientLibraryBuilder:Build():sslVerifyHost(NO):Library
NO-ERROR.
ClientBuilder:Build()
:UsingLibrary(oLib)
:Client:Execute(oRequest,oResponse).
oEntity = CAST(oResponse:Entity,JsonObject).
cMessage = oEntity:GetCharacter('errmsg').
IF (cMessage GT "") EQ TRUE THEN DO:
MESSAGE "Request failed with the below error:" SKIP(1)
cMessage
VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
RETURN.
END.
// result is the main JsonObject to look at. All results from the
// request are nested under the result field
oABLOutput = CAST(oEntity:GetJsonObject('result'),JsonObject).
// For this request the objects are all contained in a JsonObject that
// can be neatly imported using the READ-JSON method for the DATASET
// defined up top of this program. Here we fetch the ABLOutput DATASET.
// Below this note the usage of READ-JSON to read this object into the
// DATASET, automatically formatting the data into the DATASET object's
// TEMP-TABLEs
oABLOutput = CAST(oABLOutput:GetJsonObject('ABLOutput'),JsonObject).
DATASET ABLOutput:READ-JSON("JsonObject",oABLOutput,"APPEND").
OPEN QUERY qryLeaks FOR EACH ABLObjects,
EACH Objects
WHERE Objects.ABLObjectsId EQ RECID(ABLObjects).
ENABLE ALL WITH FRAME fLeaks.
WAIT-FOR CLOSE OF THIS-PROCEDURE.
The RAW JSON Response String generated by this request is below:
{
"result":{
"ABLOutput":{
"ABLObjects":[
{
"AgentSessionId":7,
"Objects":[
{
"ObjType":"MEMPTR",
"HandleId":33029,
"Size":50000,
"Source":"srvMemLeak.p",
"Line":13
},
{
"ObjType":"MEMPTR",
"HandleId":33026,
"Size":50000,
"Source":"srvMemLeak.p",
"Line":13
},
{
"ObjType":"MEMPTR",
"HandleId":33023,
"Size":50000,
"Source":"srvMemLeak.p",
"Line":13
},
{
"ObjType":"MEMPTR",
"HandleId":33020,
"Size":50000,
"Source":"srvMemLeak.p",
"Line":13
},
{
"ObjType":"MEMPTR",
"HandleId":33017,
"Size":50000,
"Source":"srvMemLeak.p",
"Line":13
},
{
"ObjType":"MEMPTR",
"HandleId":33014,
"Size":50000,
"Source":"srvMemLeak.p",
"Line":13
},
{
"ObjType":"MEMPTR",
"HandleId":33011,
"Size":50000,
"Source":"srvMemLeak.p",
"Line":13
},
{
"ObjType":"MEMPTR",
"HandleId":33008,
"Size":50000,
"Source":"srvMemLeak.p",
"Line":13
},
{
"ObjType":"MEMPTR",
"HandleId":33005,
"Size":50000,
"Source":"srvMemLeak.p",
"Line":13
},
{
"ObjType":"MEMPTR",
"HandleId":33002,
"Size":50000,
"Source":"srvMemLeak.p",
"Line":13
},
{
"ObjType":"PROCEDURE",
"Name":"srvMemLeak.p",
"HandleId":33000,
"Source":"SERVER.p",
"Line":2
},
{
"ObjType":"QUERY",
"HandleId":33001,
"Source":"srvMemLeak.p",
"Line":12
},
{
"ObjType":"Progress.Lang.Object",
"Name":"Progress.Json.ObjectModel.JsonObject",
"HandleId":33003,
"Source":"srvMemLeak.p",
"Line":14
},
{
"ObjType":"QUERY",
"HandleId":33004,
"Source":"srvMemLeak.p",
"Line":12
},
{
"ObjType":"Progress.Lang.Object",
"Name":"Progress.Json.ObjectModel.JsonObject",
"HandleId":33006,
"Source":"srvMemLeak.p",
"Line":14
},
{
"ObjType":"QUERY",
"HandleId":33007,
"Source":"srvMemLeak.p",
"Line":12
},
{
"ObjType":"Progress.Lang.Object",
"Name":"Progress.Json.ObjectModel.JsonObject",
"HandleId":33009,
"Source":"srvMemLeak.p",
"Line":14
},
{
"ObjType":"QUERY",
"HandleId":33010,
"Source":"srvMemLeak.p",
"Line":12
},
{
"ObjType":"Progress.Lang.Object",
"Name":"Progress.Json.ObjectModel.JsonObject",
"HandleId":33012,
"Source":"srvMemLeak.p",
"Line":14
},
{
"ObjType":"QUERY",
"HandleId":33013,
"Source":"srvMemLeak.p",
"Line":12
},
{
"ObjType":"Progress.Lang.Object",
"Name":"Progress.Json.ObjectModel.JsonObject",
"HandleId":33015,
"Source":"srvMemLeak.p",
"Line":14
},
{
"ObjType":"QUERY",
"HandleId":33016,
"Source":"srvMemLeak.p",
"Line":12
},
{
"ObjType":"Progress.Lang.Object",
"Name":"Progress.Json.ObjectModel.JsonObject",
"HandleId":33018,
"Source":"srvMemLeak.p",
"Line":14
},
{
"ObjType":"QUERY",
"HandleId":33019,
"Source":"srvMemLeak.p",
"Line":12
},
{
"ObjType":"Progress.Lang.Object",
"Name":"Progress.Json.ObjectModel.JsonObject",
"HandleId":33021,
"Source":"srvMemLeak.p",
"Line":14
},
{
"ObjType":"QUERY",
"HandleId":33022,
"Source":"srvMemLeak.p",
"Line":12
},
{
"ObjType":"Progress.Lang.Object",
"Name":"Progress.Json.ObjectModel.JsonObject",
"HandleId":33024,
"Source":"srvMemLeak.p",
"Line":14
},
{
"ObjType":"QUERY",
"HandleId":33025,
"Source":"srvMemLeak.p",
"Line":12
},
{
"ObjType":"Progress.Lang.Object",
"Name":"Progress.Json.ObjectModel.JsonObject",
"HandleId":33027,
"Source":"srvMemLeak.p",
"Line":14
},
{
"ObjType":"QUERY",
"HandleId":33028,
"Source":"srvMemLeak.p",
"Line":12
},
{
"ObjType":"Progress.Lang.Object",
"Name":"Progress.Json.ObjectModel.JsonObject",
"HandleId":33030,
"Source":"srvMemLeak.p",
"Line":14
}
]
}
]
},
"ABLReturnVal":true,
"agentId":"EQruUKdITjqHHfDML8YmhQ",
"pid":"23924"
},
"versionNo":1,
"outcome":"SUCCESS",
"versionStr":"v11.7.4 ( 2018-10-10 )",
"errmsg":"",
"operation":"GET ABL OBJECTS REPORT"
}