How to count the active ASP.NET Sessions (SQL Server)?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I know that when the SessionState is set to SQL Server (ASP.NET 1.1) these
counters in PerfMon are not valued:
- Sessions Abandoned
- Sessions Active
- Sessions Timed Out
- Sessions Total
Is there another way to get these counters (especially "Sessions Active")
when the SessionState is set to SQL Server?
Thanks in advance!
Joe

--
 
Joe,

Performance counters are only valid for In-Process session state management.
To count active sessions in SQLServer mode you need to create a stored
procedure in the tempdb database that returns the counter:

DECLARE @Now DATETIME

SELECT COUNT(*) AS SessionCount
FROM ASPStateTempSessions
WHERE (Expires < @Now)


hope this helps
 
Milosz,
Yes, thank you very much!

--
Milosz Skalecki said:
Joe,

Performance counters are only valid for In-Process session state management.
To count active sessions in SQLServer mode you need to create a stored
procedure in the tempdb database that returns the counter:

DECLARE @Now DATETIME

SELECT COUNT(*) AS SessionCount
FROM ASPStateTempSessions
WHERE (Expires < @Now)


hope this helps
 
Milosz Skalecki and others,

I would rather go:

SELECT COUNT(*) AS SessionCount
FROM [ASPStateTempSessions]
WHERE ([Expires] > GETDATE())

GETDATE() instead of a variable that's not really needed (and only
declared?) and I changed the < to > to actually get all sessions that expires
in the future, and not the ones that have already expired...
 
I actually ended up with this:

SELECT COUNT(*) AS SessionCount FROM ASPStateTempSessions WHERE
DATEADD(mi,15,LockDateLocal) > CURRENT_TIMESTAMP

Users active in the last 15 minutes ...

Eirikh said:
Milosz Skalecki and others,

I would rather go:

SELECT COUNT(*) AS SessionCount
FROM [ASPStateTempSessions]
WHERE ([Expires] > GETDATE())

GETDATE() instead of a variable that's not really needed (and only
declared?) and I changed the < to > to actually get all sessions that expires
in the future, and not the ones that have already expired...


Milosz Skalecki said:
Joe,

Performance counters are only valid for In-Process session state management.
To count active sessions in SQLServer mode you need to create a stored
procedure in the tempdb database that returns the counter:

DECLARE @Now DATETIME

SELECT COUNT(*) AS SessionCount
FROM ASPStateTempSessions
WHERE (Expires < @Now)


hope this helps
 
Back
Top