Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

xanburzum

[Resolvido] Informação atual do servidor

Recommended Posts

Esse conjunto de scripts reporta informação atual do servidor web, tais como: sessões atuais, as sessões para o dia, sessões de média, e muito mais. Bem como a capacidade de transmitir esta informação para telefones celulares, pagers, e PDAs que são WAP (Wireless Access Protocol) compatível. Através do uso do arquivo Global.asa, ele mantém o controle de estatísticas do servidor. Para acessar as informações através do dispositivo hand held, basta apontar o navegador do aparelho para a página correta (amstatswml.asp) em seu servidor e ver os resultados. Você não precisa carregar nenhuma DLLs servidor, objetos COM, ou serviços NT. Tudo é tratado através de seu arquivo global.asa. ele não usar variáveis ​​de sessão (que pode ser um desperdício) e usa poucos recursos do sistema.

 

amstats.asp

<% response.buffer = true %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
   <title>Estatísticas Atual do Servidor para: <% =request.servervariables("SERVER_NAME") %></title>
   </head>
<body>

<%

vDaysSinceReset = datediff("d", application("vResetTime"), date())
vSecondsSinceReset = datediff("s", application("vResetTime"), now())
vRemainingSeconds = formatnumber((vSecondsSinceReset mod 60),1)
vWholeMinutesSinceReset = ((vSecondsSinceReset - vRemainingSeconds) / 60)
vRemainingMinutes = formatnumber((vWholeMinutesSinceReset mod 60),1)
vWholeHoursSinceReset = ((vWholeMinutesSinceReset - vRemainingMinutes) / 60)
vRemainingHours = formatnumber((vWholeHoursSinceReset mod 24),1)
vWholeDaysSinceReset = ((vWholeHoursSinceReset - vRemainingHours) / 24)

vAvgSessionsPerSec = application("vSessionsSinceReset") / (vSecondsSinceReset + 1)
vAvgSessionsPerMin = vAvgSessionsPerSec * 60
vAvgSessionsPerHour = vAvgSessionsPerMin * 60
vAvgSessionsPerDay = vAvgSessionsPerHour * 24

'*******GET COUNTER TOTAL**********
if application("vUseLogFile") = "yes" then
Set vFileSystem = server.createobject("Scripting.FileSystemObject")
 if vFileSystem.FileExists(server.mappath("/") & application("vCounterFile")) = true then
   'set vFile = vFileSystem.CreateTextFile (server.mappath("/") & application("vCounterFile"))
   set vFile = vFileSystem.getFile(server.mappath("/") & application("vCounterFile"))
   set vTextStrm = vFile.openAsTextStream(1,-2)
   vCount = vTextStrm.readline
   vDate = vTextStrm.readline
   vTextStrm.close
 end if
Set vFileSystem = nothing
else
vCount = "Não está logado"
vDate = "Não está logado"
end if
%>
<font face="arial">
<i><h4> Estatísticas Atual servidor:</h4></i>
<table width = "400">
<tr>
      <td align="right" bgcolor=#b9d6d7 width = "50%"><b><small>Server Name:</small> </b></td>
      <td align="left" bgcolor=#b9d6d7><% =request.servervariables("SERVER_NAME") %></td>
</tr>
</table>
<table width = "400">

<tr>
      <td bgcolor=#e1e8b5 width = "50%" align = "right">Sessões atuais:</td>
      <td bgcolor=#c5dabc><% =application("vSessions") %></td>
</tr>
<tr>
      <td bgcolor=#e1e8b5 width = "50%" align = "right">Sessões de hoje:</td>
      <td bgcolor=#c5dabc><% =application("vSessionsToday") %></td>
</tr>
<tr>
      <td bgcolor=#e1e8b5 width = "50%" align = "right">Sessões de Ontem :</td>
      <td bgcolor=#c5dabc><% =application("vSessionsYesterday") %></td>
</tr>
<tr>
      <td bgcolor=#e1e8b5 width = "50%" align = "right">Sessões desde Reset:</td>
      <td bgcolor=#c5dabc><% =application("vSessionsSinceReset") %></td>
</tr>
<tr>
      <td bgcolor=#e1e8b5 width = "50%" align = "right">Sessões Média por hora:</td>
      <td bgcolor=#c5dabc><% =formatnumber(vAvgSessionsPerHour,2) %></td>
</tr>
<tr>
      <td bgcolor=#e1e8b5 width = "50%" align = "right">Sessões Média por Dia:</td>
      <td bgcolor=#c5dabc><% =formatnumber(vAvgSessionsPerDay,2) %></td>
</tr>
<tr>
      <td bgcolor=#e1e8b5 width = "50%" align = "right">Sessões de pico:</td>
      <td bgcolor=#c5dabc><% =application("vPeakSessions") %></td>
</tr>
<tr>
      <td bgcolor=#e1e8b5 width = "50%" align = "right">Peak Data/Tempo:</td>
      <td bgcolor=#c5dabc><% =application("vPeakSessionDate") %></td>
</tr>
<tr>
      <td bgcolor=#e1e8b5 width = "50%" align = "right">Hora do Servidor:</td>
      <td bgcolor=#c5dabc><% =now() %></td>
</tr>
<tr>
      <td bgcolor=#e1e8b5 width = "50%" align = "right">Server Reset:</td>
      <td bgcolor=#c5dabc><% =application("vResetTime")%></td>
</tr>
<tr>
      <td bgcolor=#e1e8b5 width = "50%" align = "right">Server Uptime:</td>
      <td bgcolor=#c5dabc><%if vWholeDaysSinceReset > 0 then response.write vWholeDaysSinceReset & "d "
if vRemainingHours > 0 then response.write formatnumber(vRemainingHours,0) & "h "
if vRemainingMinutes > 0 then response.write formatnumber(vRemainingMinutes,0) & "m "
response.write formatnumber(vRemainingSeconds,0) & "s"
%></td>
</tr>
<tr>
      <td bgcolor=#e1e8b5 width = "50%" align = "right">Total de Sessões logadas:</td>
      <td bgcolor=#c5dabc><% =vCount %></td>
</tr>
<tr>
      <td bgcolor=#e1e8b5 width = "50%" align = "right">Log Reset:</td>
      <td bgcolor=#c5dabc><% =vDate %></td>
</tr>
</table>
</font>
</body>
</html>

 

amstatswml.asp

<%
'******DETERMINE BROWSER TYPE********************
response.buffer="true"
dim accstring
dim uastring
dim deliverType
uastring = request.serverVariables("HTTP_USER_AGENT")
accstring = request.serverVariables("HTTP_ACCEPT")
if instr(accstring,"wml") then
Response.ContentType = "text/vnd.wap.wml"
if instr(uastring,"Nokia") then
 deliverType = "nokiawml"
elseif instr(uastring,"UP.Browser") then
 deliverType = "upwml"
else
 deliverType = "genwml"
end if
else

Response.ContentType = "text/html"
 deliverType="html"
 response.write "<html><head><title>Browser não compatível</title></head>"
 response.write "<body>Esta página é para ser vista usando um WML compatível <br>"
 response.write "browser. <a href='amstats.asp'>Click aqui</a> para ver no seu navegador. </body>"

end if
if deliverType <> "html" then

' Reservados para caracteres WML terá de ser precedido de texto formatado.
 Dim apostrophe, quote, less_than, greater_than, ampersand
 apostrophe    = Chr(39)
 quote         = Chr(34)
 less_than     = Chr(60)
 greater_than  = Chr(62)
 ampersand     = Chr(38)
 dollar_sign   = Chr(36)
 nl            = Chr(10)

'******* COUNTER TOTAL**********
Set vFileSystem = server.createobject("Scripting.FileSystemObject")
 if vFileSystem.FileExists(server.mappath("/") & application("vCounterFile")) = true then
   'set vFile = vFileSystem.CreateTextFile (server.mappath("/") & application("vCounterFile"))
   set vFile = vFileSystem.getFile(server.mappath("/") & application("vCounterFile"))
   set vTextStrm = vFile.openAsTextStream(1,-2)
   vCount = vTextStrm.readline
   vDate = vTextStrm.readline
   vTextStrm.close
 end if
Set vFileSystem = nothing

vDaysSinceReset = datediff("d", application("vResetTime"), date())
vSecondsSinceReset = datediff("s", application("vResetTime"), now())
vRemainingSeconds = formatnumber((vSecondsSinceReset mod 60),1)
vWholeMinutesSinceReset = ((vSecondsSinceReset - vRemainingSeconds) / 60)
vRemainingMinutes = formatnumber((vWholeMinutesSinceReset mod 60),1)
vWholeHoursSinceReset = ((vWholeMinutesSinceReset - vRemainingMinutes) / 60)
vRemainingHours = formatnumber((vWholeHoursSinceReset mod 24),1)
vWholeDaysSinceReset = ((vWholeHoursSinceReset - vRemainingHours) / 24)
if vWholeDaysSinceReset > 0 then vServerUptime = vWholeDaysSinceReset  & "d "
if vRemainingHours > 0 then vServerUptime = vServerUptime & formatnumber(vRemainingHours,0) & "h "
if vRemainingMinutes > 0 then vServerUptime = vServerUptime & formatnumber(vRemainingMinutes,0) & "m "
vServerUptime = vServerUptime & formatnumber(vRemainingSeconds,0) & "s"
vAvgSessionsPerSec = application("vSessionsSinceReset") / (vSecondsSinceReset + 1)
vAvgSessionsPerMin = vAvgSessionsPerSec * 60
vAvgSessionsPerHour = vAvgSessionsPerMin * 60
vAvgSessionsPerDay = vAvgSessionsPerHour * 24

 deckA =         "<wml>" & nl
 deckA = deckA & "  <card>" & nl
 deckA = deckA & "    <p>" & nl
 deckA = deckA & "    <b>Server Name:</b> " & nl
 deckA = deckA & " <br/>" & request.servervariables("SERVER_NAME") & nl
 deckA = deckA & "    <br/><b>Sessões atuais:</b> " & nl
 deckA = deckA & " <br/>" & application("vSessions") & nl
 deckA = deckA & "    <br/><b>Sessões de hoje:</b> " & nl
 deckA = deckA & " <br/>" & application("vSessionsToday") & nl
 deckA = deckA & "    <br/><b>Sessões de Ontem:</b> " & nl
 deckA = deckA & " <br/>" & application("vSessionsYesterday") & nl
 deckA = deckA & "    <br/><b>Sessions desde Reset:</b> " & nl
 deckA = deckA & " <br/>" & application("vSessionsSinceReset") & nl
 deckA = deckA & "    <br/><b>Sessões Média por hora:</b> " & nl
 deckA = deckA & " <br/>" & formatnumber(vAvgSessionsPerHour,2) & nl
 deckA = deckA & "    <br/><b>Sessões Média por Dia:</b> " & nl
 deckA = deckA & " <br/>" & formatnumber(vAvgSessionsPerDay,2) & nl
 deckA = deckA & "    <br/><b>Sessions de Pico:</b> " & nl
 deckA = deckA & " <br/>" & application("vPeakSessions") & nl
 deckA = deckA & "    <br/><b>Pico Data/Tempo:</b> " & nl
 deckA = deckA & " <br/>" & application("vPeakSessionDate") & nl
 deckA = deckA & "    <br/><b>Server Time:</b> " & nl
 deckA = deckA & " <br/>" & now() & nl
 deckA = deckA & "    <br/><b>Reset Date:</b> " & nl
 deckA = deckA & " <br/>" & application("vResetTime")  & nl
 deckA = deckA & "    <br/><b>Server Uptime:</b> " & nl
 deckA = deckA & " <br/>" & vServerUptime & nl
 deckA = deckA & "       <br/><b>Sessões Logadas:</b> " & nl
 deckA = deckA & " <br/>" & vCount & nl
 deckA = deckA & "       <br/><b>Log Reset:</b> " & nl
 deckA = deckA & " <br/>" & vDate & nl
 deckA = deckA & " <br/>"
 deckA = deckA & " <br/><i>acmemalicron.com</i>" & nl
 deckA = deckA & "    </p>" & nl
 deckA = deckA & " </card>" & nl
 deckA = deckA & "</wml>" & nl

response.write deckA
end if
%>

 

global.asa

<script language=vbscript runat=server>

SUB Application_OnStart
'********INITIALIZE VARIABLES FOR amSTATS*****************************
application("vSessions") = 0
application("vResetDate") = date()
application("vResetTime") = now()
application("vToday") = now()
application("vSessionsToday") = 0
application("vSessionsYesterday") = 0
application("vSessionsSinceReset") = application("vSessions")
application("vPeakSessions") = application("vSessions")
application("vPeakSessionsDate") = now()
application("vSessionTimeout") = 20
'set vUseCounterFile to no to turn logging off
'set vLogFile and vCounterFile to the path and filename of the log files
application("vUseLogFile") = "yes" ' yes or no
application("vLogFile") = "\amstats.log"
application("vCounterFile") = "\amcounter.log"
if application("vUseLogFile") = "yes" then
Set vFileSystem = server.createobject("Scripting.FileSystemObject")
 if vFileSystem.FileExists(server.mappath("/") & application("vCounterFile")) = false then
   set vFile = vFileSystem.CreateTextFile (server.mappath("/") & application("vCounterFile"))
   vFile.WriteLine("0")
   vFile.WriteLine(now())
   vFile.Close
 end if
Set vFileSystem = nothing
end if
END SUB

SUB Application_OnEnd
END SUB


SUB Session_OnStart

'*********LOG FILE and INFO FOR amSTATS***************

application.lock
if application("vUseLogFile") = "yes" then
 Set vFileSystem = server.createobject("Scripting.FileSystemObject")
 if vFileSystem.FileExists(server.mappath("/") & application("vLogFile")) = false then
   set vFile = vFileSystem.CreateTextFile (server.mappath("/") & application("vLogFile"))
   vFile.Close
 end if
'abrir counter file
 Set vFileSystem = server.createobject("Scripting.FileSystemObject")
 if vFileSystem.FileExists(server.mappath("/") & application("vCounterFile")) = true then
   set vFile = vFileSystem.getFile(server.mappath("/") & application("vCounterFile"))
   set vTextStrm = vFile.openAsTextStream(1,-2)
   vCount = vTextStrm.readline
   vDate = vTextStrm.readline
   vTextStrm.close
   set vTextStrm = vFile.openAsTextStream(2,-2)
   vTextStrm.writeline vCount + 1
   vTextStrm.writeline vDate
   vTextStrm.close
 end if
 set vFile = vFileSystem.OpenTextFile((server.mappath("/") & application("vLogFile")), 8)
 vLogString = ("[" & now & "]") & vbcrlf
 vLogString = vLogString & request.servervariables("SERVER_NAME") & vbcrlf
 vLogString = vLogString & request.servervariables("SERVER_PORT") & vbcrlf
 vLogString = vLogString & request.servervariables("SCRIPT_NAME") & vbcrlf
 vLogString = vLogString & request.servervariables("HTTP_REFERER") & vbcrlf  
 vLogString = vLogString & request.servervariables("HTTP_USER_AGENT") & vbcrlf
 vLogString = vLogString & request.servervariables("REMOTE_ADDR") & vbcrlf
 vLogString = vLogString & request.servervariables("SERVER_PROTOCOL") & vbcrlf
 vLogString = vLogString & request.servervariables("HTTPS") & vbcrlf
 vFile.writeline vLogString
 vFile.Close
 Set vFileSystem = nothing
end if
session.timeout = application("vSessionTimeout")
application("vSessionsSinceReset") = application("vSessionsSinceReset") + 1
application("vSessions") = application("vSessions") + 1
application("vSessionsToday") = application("vSessionsToday") + 1
if application("vSessions") >= application("vPeakSessions") then
application("vPeakSessions") = application("vSessions")
application("vPeakSessionDate") = now()
end if
if not datepart("d", application("vToday")) = datepart("d", date()) then
 application("vToday") = date()
 application("vSessionsYesterday") = application("vSessionsToday")
 application("vSessionsToday") = application("vSessions")
end if
application.unlock

END SUB

SUB Session_OnEnd
'**********INFO FOR amSTATS*****************
application.lock
application("vSessions") = application("vSessions") - 1
application.unlock               
END SUB


</script>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.