AppServer agent PID

Posted by ojfoggin on 27-Oct-2009 05:54

Hi guys,

I'm trying to create a diagnostic type thing and I would like to be able to access the currently connected AppServer agent Process ID.

We will shortly be changing to a new AppServer architecture that I have established but if there are ever any locked app servers there is no way to find who is locking it.

If I can get the AppServer PID and output it somewhere in some sort of log it will help in quickly unlocking the AppServer agent and fixing the code that locked it.

I have quickly checked through the server object handle attributes but none of them seem to do what I'm looking for.

Is this possible to do from the GUI side?  If not is it something I can do in a procedure running on the agent itself?

Thanks for the help!

Oliver

All Replies

Posted by rbf on 27-Oct-2009 07:12

Hi Oliver,

Officially there is no way.

There are some tricks that you can use. The easiest one is to parse the value of the -ASID parameter from SESSION:STARTUP-PARAMETERS in the AppServer agent. Apparently it returns a unique sequence number for each agent, but of course it is not documented and I don't know if it is reused when agents are trimmed and added. However, it is probably sufficient for your current purposes.

You can find the real PID through the following code:

FIND FIRST _MyConnection.
DISPLAY _MyConnection._MyConn-Pid.

However, for this you need a database connection. Any database connection will do.

HTH

-peter

Message was edited by: Peter van Dam

Posted by ojfoggin on 27-Oct-2009 07:24

Thanks for the answer,

I have noted your last comment also.

The problem I am facing is that the system was set up so that each time data was required from the server it would...

1. Connect to an agent.

2. Run a persitent procedure on the agent.

3. Run an internal proc of the PP.

4. Delete the PP.

5. Disconnect from the agent.

This has lead to sloppy coding i.e. opening a persistent procedure but then deleting the wrong procedure handle.  This did not matter previously as the agent would be disconnected and all PPs would be closed.

Now I have set up the system to connect at login and disconnect at log out.

It is working perfectly now but there are still places that we haven't caught all the sloppy bits of code and we are experiencing locked appservers on our test system.  On the dev system it is easy to fix as there are only 5 of us in the same room so it only takes 5 mins to find what's going on.

On the test system we have a much wider user base and if an appserver becomes locked there is no way of finding which user is locking it.  Using the PID I was ghoping to be able to find the user who has locked the agent so we can eliminate the sloppy code and get back to a state where we no longer need to know the agent we are on.

I hope this makes sense.

Thanks

Oliver

Posted by Roy Ellis on 27-Oct-2009 07:36

Actually in 10.2A or newer there is a built in way to get this information.

It is available in the "asbman" utility and in both OpenEdge Explorer and OpenEdge Management.  It is called "List AppServer Connections".

Using the "asbman" utility simply run:

[prompt]$ $DLC/bin/asbman -i asbroker1 -listclients
OpenEdge Release 10.2A02 as of Tue Aug 11 20:16:05 EDT 2009


Connecting to Progress AdminServer using rmi://localhost:20931/Chimera (8280)
Searching for asbroker1 (8288)
Connecting to asbroker1  (8276)

   ConnHdl User             Rmt IP                       Rmt Port State
   ------- ----                       ------                            -------- -----
       178                  192.18.2.126                     2686 CONNECTED

To get detailed information on a user use "-clientdetail" connection handle or use "all":

[prompt]$ $DLC/bin/asbman -i asbroker1 -clientdetail all
OpenEdge Release 10.2A02 as of Tue Aug 11 20:16:05 EDT 2009


Connecting to Progress AdminServer using rmi://localhost:20931/Chimera (8280)
Searching for asbroker1 (8288)
Connecting to asbroker1  (8276)

conn hdl= 180
user name=
remote addr= 192.18.2.126
remote port= 2689
connection state= CONNECTED
conn ID= 172.18.2.129::asbroker1::3090::901347e6c1a6fda2:5ba51b58:12495056b4f:-7f8c
request count= 0
agent PID= 3883
agent port= 2155

In OpenEdge Explorer or Management select your AppServer and then select the "AppServer Client Connections" Link.

HTH, Roy

Posted by ojfoggin on 27-Oct-2009 08:53

One of our guys found another way around it...


find _myconnection no-lock no-error.

if avail _myconnection
then
message "PID = " _myconnection._MyConn-Pid.
else "not avail".

Although I will be putting it out to a char.

Thanks for the help!

Posted by gus on 27-Oct-2009 08:57

The following code will obtain the current process' id (i.e. the agent's process id) in the 4GL on Unix and Linux systems. Note that the library name might be slightly different on your system (e.g. it might be /usr/lib/libc.so.6 or something similar). And for 64-bit 4GL executables, the library would be in /usr/lib64/libc.so

PROCEDURE getpid EXTERNAL "/usr/lib/libc.so":

DEFINE RETURN PARAMETER ret-val AS long.

END PROCEDURE.

def var pid as integer.

run getpid (output pid).

display pid.

Posted by ojfoggin on 27-Oct-2009 09:07

LOL! Sorry Peter, I just saw the second part of your post.

Thanks for the help

This thread is closed