Hi all,
I have a set of custom procedures and events to log some informations (connId, login timestamp,...) about user connections and disconnections.
This custom informations are useful to me to identify possible performance issues during specific timeframes.
My idea is, once a user is logging out, to collect the connection properties: ConnectedTime and ApproximateCPUTime using the following query.
select value from sa_conn_properties(@connId) where PropName = 'ApproximateCPUTime' --value is in sec select value from sa_conn_properties(@connId) where PropName = 'ConnectedTime' --value is in sec
I have the following event triggered on "User Disconnection" where I try to collect the properties of interest.
CREATE EVENT "dba"."ev_MON_Logout" TYPE "Disconnect" HANDLER begin declare @user varchar(30) declare @connid integer declare @approx_cpu_time numeric(10) declare @conn_time numeric(10) select @connid=event_parameter('ConnectionID') select @user=event_parameter('User') select @approx_cpu_time=convert(numeric(10), value) from sa_conn_properties(@connid) where PropName = 'ApproximateCPUTime' -- in sec select @conn_time=convert(numeric(10), value)/1000 from sa_conn_properties(@connid) where PropName = 'ConnectedTime' -- in sec -- ...after collection they are stored in my own monitoring tables end;
The problem is that I tried the above solution, but I have always the properties value equals to null.
Can be the problem the fact that when the event is triggered, the corresponding connection is already closed, so that only the @connid and @user are returned and not the other properties?
How can I get ConnectedTime and ApproximateCPUTimeautomatically for each connection?
During my tests I tried also to use "sa_eng_properties" instead of "sa_conn_properties" in order to obtain an engine estimation at that moment instead of the connection one, but I obtain a strange result.
select * from sa_eng_properties() where PropName = 'ApproximateCPUTime'
PropNum,PropName,PropDescription,Value
385,ApproximateCPUTime,Approximate CPU time used,-6551729.6684032
Why do I obtain always the above value? ...and what does it mean?
Best regards,
Stefano