469,915 Members | 2,457 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,915 developers. It's quick & easy.

Get the number of sessions going on now.

Hiya!
How would i get this number? thanks!
Jul 19 '05 #1
19 7695
www.perfhound.com

"Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
news:uR**************@TK2MSFTNGP10.phx.gbl...
Hiya!
How would i get this number? thanks!

Jul 19 '05 #2
Sub Session_OnStart()
Application.Lock
Application("SessionCount") = Application("SessionCount") + 1
Application.Unlock
End Sub

Sub Session_OnEnd()
Application.Lock
Application("SessionCount") = Application("SessionCount") - 1
Application.Unlock
End Sub

In your global.asa.

Ray at work
"Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
news:uR**************@TK2MSFTNGP10.phx.gbl...
Hiya!
How would i get this number? thanks!

Jul 19 '05 #3
i love you Ray.

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:Oz**************@TK2MSFTNGP11.phx.gbl...
Sub Session_OnStart()
Application.Lock
Application("SessionCount") = Application("SessionCount") + 1
Application.Unlock
End Sub

Sub Session_OnEnd()
Application.Lock
Application("SessionCount") = Application("SessionCount") - 1
Application.Unlock
End Sub

In your global.asa.

Ray at work
"Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
news:uR**************@TK2MSFTNGP10.phx.gbl...
Hiya!
How would i get this number? thanks!


Jul 19 '05 #4
I love you too Jeff. :]

Ray at work

"Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
news:uL**************@TK2MSFTNGP09.phx.gbl...
i love you Ray.

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:Oz**************@TK2MSFTNGP11.phx.gbl...
Sub Session_OnStart()
Application.Lock
Application("SessionCount") = Application("SessionCount") + 1
Application.Unlock
End Sub

Sub Session_OnEnd()
Application.Lock
Application("SessionCount") = Application("SessionCount") - 1
Application.Unlock
End Sub

In your global.asa.

Ray at work
"Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
news:uR**************@TK2MSFTNGP10.phx.gbl...
Hiya!
How would i get this number? thanks!



Jul 19 '05 #5
Careful though, the session_onEnd will not always fire when you expect, if
at all.
http://www.aspfaq.com/2078
"Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
news:uL**************@TK2MSFTNGP09.phx.gbl...
i love you Ray.

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:Oz**************@TK2MSFTNGP11.phx.gbl...
Sub Session_OnStart()
Application.Lock
Application("SessionCount") = Application("SessionCount") + 1
Application.Unlock
End Sub

Sub Session_OnEnd()
Application.Lock
Application("SessionCount") = Application("SessionCount") - 1
Application.Unlock
End Sub

In your global.asa.

Ray at work
"Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
news:uR**************@TK2MSFTNGP10.phx.gbl...
Hiya!
How would i get this number? thanks!



Jul 19 '05 #6
> I love you too Jeff. :]

Stop guys.. I'm getting teary eyed.
Jul 19 '05 #7
Ray, take my clothes out of the dryer when you get home please

"Randy Rahbar" <rvrahbarAThotmail.com> wrote in message
news:OC**************@TK2MSFTNGP09.phx.gbl...
I love you too Jeff. :]


Stop guys.. I'm getting teary eyed.

Jul 19 '05 #8
Evertjan. wrote on 13 nov 2003 in
microsoft.public.inetserver.asp.general:
Ray at <%=sLocation%> wrote on 13 nov 2003 in
microsoft.public.inetserver.asp.general:
Sub Session_OnStart()
Application.Lock
Application("SessionCount") = Application("SessionCount") + 1
Application.Unlock
End Sub

Sub Session_OnEnd()
Application.Lock
Application("SessionCount") = Application("SessionCount") - 1
Application.Unlock
End Sub

In your global.asa.


You will need this too, I think:

Sub Application_OnStart
Application("Active") = 0
End Sub

I mean:

Sub Application_OnStart
Application("SessionCount") = 0
End Sub


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #9
Oh, did you leave them in there again? You know that I hate it when you do
that! Now I'm going to have to iron them all again. >:|

Ray at work

"Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
news:uY*************@TK2MSFTNGP11.phx.gbl...
Ray, take my clothes out of the dryer when you get home please

"Randy Rahbar" <rvrahbarAThotmail.com> wrote in message
news:OC**************@TK2MSFTNGP09.phx.gbl...
I love you too Jeff. :]


Stop guys.. I'm getting teary eyed.


Jul 19 '05 #10
Also see the WMI approach.
http://www.aspfaq.com/2491


"Jeff Clark" <JeffC@NO_SPAMreturnventures.com> wrote in message
news:uR**************@TK2MSFTNGP10.phx.gbl...
Hiya!
How would i get this number? thanks!

Jul 19 '05 #11
> Careful though, the session_onEnd will not always fire when you expect, if
at all.
http://www.aspfaq.com/2078


But it does always fire though (in my experience)...I have used Rays technique
for over 3 years and at the end of the day, the counter is always zero.

Brian

Jul 19 '05 #12
> But it does always fire though (in my experience)...I have used Rays
technique
for over 3 years and at the end of the day, the counter is always zero.


I've seen cases where it never fired. And remember that you're not always
checking the counts at the end of the day. :-)
Jul 19 '05 #13
Do you know in what situations it wouldn't fire? I mean, if you go and kill
inetinfo.exe or something, it fire then, but as soon as you did that, you'd
have zero sessions anyway.

Ray at work

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...
But it does always fire though (in my experience)...I have used Rays

technique
for over 3 years and at the end of the day, the counter is always zero.


I've seen cases where it never fired. And remember that you're not always
checking the counts at the end of the day. :-)

Jul 19 '05 #14
That would be, "...it WON'T fire..."

Ray at work

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
if you go and kill inetinfo.exe or something, it fire then,

Jul 19 '05 #15
> Do you know in what situations it wouldn't fire? I mean, if you go and
kill
inetinfo.exe or something, it fire then, but as soon as you did that, you'd have zero sessions anyway.


I don't know the exact circumstance, but I had a site with a session timeout
of 20 minutes. One time the provider went down, so you couldn't ping the
box from outside (but I was inside, so could see the database, etc). I had
code in session_onEnd that cleaned out sessions from the database, and I had
about 30 active sessions at the time the site went down (easily queried
right after it happened; I was thinking, "oh crap, how many users did that
affect?"). I did a query 10 minutes later, and there were still 12 active
sessions (so 18 of them must have hit session_onEnd). 10 minutes later
(when all of the session_onEnd() calls should have completed), there were
still 5. An hour later, there were still 5. IIS was still running, nothing
had been restarted, etc.

This actually happened the day before I first wrote the "what is wrong with
session_onEnd()?" article. And I had no idea how I would be able to figure
out what was "special" about those 5 sessions; still don't know how I would
differentiate them if it were to happen today. Also, not sure if this is
still possible in the IIS 6.0 world; I think that was IIS 5.0 where I
experienced it.

Watch the new article about tracking sessions (2491) for the SQL Server
methodology mentioned in 2078.
Jul 19 '05 #16

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...
Do you know in what situations it wouldn't fire? I mean, if you go and kill
inetinfo.exe or something, it fire then, but as soon as you did that,

you'd
have zero sessions anyway.


I don't know the exact circumstance, but I had a site with a session

timeout of 20 minutes. One time the provider went down, so you couldn't ping the
box from outside (but I was inside, so could see the database, etc). I had code in session_onEnd that cleaned out sessions from the database, and I had about 30 active sessions at the time the site went down (easily queried
right after it happened; I was thinking, "oh crap, how many users did that
affect?"). I did a query 10 minutes later, and there were still 12 active
sessions (so 18 of them must have hit session_onEnd). 10 minutes later
(when all of the session_onEnd() calls should have completed), there were
still 5. An hour later, there were still 5. IIS was still running, nothing had been restarted, etc.


Interesting. Perhaps you should get a better server. :P So, in Jeff's
particular circumstance, it wouldn't matter, since the application variables
would be gone anyway, but it certainly does matter if the session_onend
needs to really do something the way yours was.

Ray at work
Jul 19 '05 #17
> Interesting. Perhaps you should get a better server. :P

Oh yeah, that was the problem!
So, in Jeff's
particular circumstance, it wouldn't matter, since the application variables would be gone anyway


I don't follow... can you elaborate? The application variables were not
gone in my scenario... the server was still running, but session_onEnd did
not fire for 5 of the 30 sessions. So, application("SessionCount") =
application("SessionCount") - 1 left application("SessionCount") 5 too high.
And this was NOT corrected when the server came back online, because the
only symptom of that was that users could hit the server again (the server
itself wasn't down; the provider's pipe was down).

Anyway, I updated http://www.aspfaq.com/2491 with a slightly more reliable
method using SQL Server (that still, admittedly, can leave sessions to be
counted as "active" until the timeout, when they really aren't truly
active... but it will never let a failed session_onEnd permanently spoil the
count).
Jul 19 '05 #18

"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:Oz*************@TK2MSFTNGP11.phx.gbl...

I don't follow... can you elaborate? The application variables were not
gone in my scenario... the server was still running, but session_onEnd did
not fire for 5 of the 30 sessions. So, application("SessionCount") =
application("SessionCount") - 1 left application("SessionCount") 5 too high. And this was NOT corrected when the server came back online, because the
only symptom of that was that users could hit the server again (the server
itself wasn't down; the provider's pipe was down).
Yeah, never mind. I was reading it that the server went down. So, I guess
what I was saying is if you're using Session_OnEnd to update application
variable and the ~server~ goes down, it doesn't matter about Session_OnEnd
not updating your app variables, since they'll be gone anyway. But if
you're relying on Session_OnEnd to make changes outside of IIS, like update
a database, delete a file, etc., then yeah, it certainly would matter.

Anyway, I updated http://www.aspfaq.com/2491 with a slightly more reliable
method using SQL Server (that still, admittedly, can leave sessions to be
counted as "active" until the timeout, when they really aren't truly
active... but it will never let a failed session_onEnd permanently spoil

the

Nice. That WMI method is hardcore. Good job.

Ray at work
Jul 19 '05 #19
> Nice. That WMI method is hardcore. Good job.

Thanks. I guess you can start to imagine the amount of work that went into
PerfHound, and what a ridiculous bargain it is. :-)

It's too bad that WMI requires an Administrator account to be useful from
ASP. Though, I suppose it would be trivial to have local VBS scripts update
a database every so often (more often for volatile information like CPU
usage, less often for static information like # of CPUs).

Hey, that gives me an idea...
Jul 19 '05 #20

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by jing_li | last post: by
4 posts views Thread by Ollie | last post: by
5 posts views Thread by TheOne | last post: by
Atli
2 posts views Thread by Atli | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.