One of the questions I regularly get from DBAs and Dynamics GP systems administrators alike is, “how do I know how long a GP user has been idle in the system without the use of third party products?”. It is sufficient to say that they are good third party products out there that rely on Dexterity scripting to provide this information and perform all sort of actions that the system administrator may want to do, take for example Rockton Software’s Omni Tools with it’s inactivity timeout feature.
SQL Server offers a great way of tracking idle times from a process perspective. This is very cool, because most of the time we want to know that there is absolutely nothing running on the user’s session before we decide to take some action — most of the time remotely.
The following script displays the time (in seconds) the last batch was executed for a particular Dynamics GP user. It looks at the DEX_SESSION table and cross-reference it with the SPIDs retrieved via the undocumented SQL Server system stored procedure sp_who2.
The script can be automated to track idleness information periodically and obtain detailed reports of system usage among GP users — a sort of process activity. I use it a lot to plan server expansions activities and monitoring for my clients in conjunction with other important metrics. I hope you find this script useful in your daily administrative activities.
[Edit] One thing I truly like about blogging is that there is no short of solutions to a problem. My friend Robert Cavill, Systems Analyst in Western Australia offers his own version of determining Dynamics GP users’ activity (or lack thereof). Robert adds “I have to point out to you that sometimes I have noticed that on my system the DEX_SESSION table infrequently will not have a row present in it for an active user“. His comment is well on as the above script will exclude such users. Why and how a logged on user does not register a session in the DEX_SESSION table is something that’s up for research, but the bottom line is it happens, especially on Citrix and Terminal Server environments. Take a look at Robert’s elegant script:
If you have a script that you use for this purpose or a variation, please don’t hesitate to send it in or attach as a comment. I will be more than glad to publish your solution.
sp_who – Transact-SQL Server Reference. Click here
Until next post!
Mariano Gomez, MIS, MCP, MVP
Maximum Global Business, LLC
04/15/2009 – Added script by Robert Cavill and commentary to his solution.