Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Performance tipsPerformance tips
Previous
 
Next
New Post
2/12/2006 2:28 AM
 

Inspired by Paul (in this thread), here are two scripts that take this a step further.  The first script can be stand alone and scheduled (windows scheduler or whatever), the second runs the first one in a loop until a "stop.txt" file is detected.  The second script could be placed in the startup group or Run key in the registry to run when the PC/Server is started.  I wrote the second one so I don't have to have a ton of scheduled tasks, nothing against Paul, just don't like task scheduler that much.  It would be easy enough to write the windows event log for those of you who have an eventlog monitoring tool.  Oh yeah, these scripts are SAMPLE scripts, use at your own discretion.  No warranty as to use or fitness is expressed or implied.  Please read all the TODO comments.

'___________________________________________________________________
'Copy/Paste this script to a file named WebSiteMon_v0.1.vbs
Option Explicit
'TODO:  Change default location and file name if desired
'TODO:  Add sites in the Init section
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim objXMLHTTP   'global xml html object
Dim objFS    'global file system object
Dim objDict    'global dictionary object
Dim strDefaultLocation 'folder log file will be written to; set in Init
Dim strFileName   'log file name; set in Init
 Init
 Main
 Enit
Sub Init()
 Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
 Set objFS = CreateObject ( "Scripting.FileSystemObject")
 Set objDict = CreateObject("Scripting.Dictionary")
 strDefaultLocation = WScript.ScriptFullName 'get the FQN for this script file
 strDefaultLocation = Left(strDefaultLocation,InStrRev(strDefaultLocation,"\")) 'get just the path portion with trailing \
 strFileName = "WebSiteMonLog.csv"
 With objDict

'TODO:
  'Copy and paste the following line once for each site you want to add
  'Change "Site" to be the site you want, leave it in quotes
  'Change "URL" to the actual url, leave it in quotes
  'Uncomment the line (remove the begining ' )
  '.Add "Site", "URL"
 End With
End Sub
Sub Main()
 Dim intCount, intElapsed, intNumSites
 Dim dtmStart, dtmEnd, objItem, strLog
 Dim strErr, intLen
 'Uncomment the following line if you want a fresh log file each time this script runs
 'If objFS.FileExists(strDefaultLocation & strFileName) Then objFS.DeleteFile strDefaultLocation & strFileName
 'WriteLog "Time, URL, Elapsed, Bytes" 'uncommend this if you need a header
 With objXMLHTTP
  intNumSites = objDict.Count
  For Each objItem in objDict
   strLog = ""
   strErr = ""
   intCount = 0
   intLen = 0
   dtmStart = Now()
   With objXMLHTTP
    On Error Resume Next
    .Open "GET", objDict(objItem), FALSE
    If Err.Number <> 0 Then strErr = "Site not found: "
    .Send()
    Do Until .readyState = 4 'loop until page is loaded
        .waitForResponse 1000 'wait one second
        intCount = intCount + 1
        If intCount > 10 Then 'if the site doesn't load after ~10 seconds; continue with next site
      Err.Raise 999
      strErr = "Site not found: "
         Exit Do
        End If
    Loop
    intLen = Len(.responseText)
    On Error GoTo 0
   End With
   dtmEnd = Now()
   intElapsed = DateDiff("s",dtmStart,dtmEnd)
   strLog = dtmStart & ","  & strErr & objDict(objItem) & "," & intElapsed & "," & intLen
   WriteLog strLog
  Next
 End With
End Sub
Sub WriteLog(strLogText)
 Dim objFile
 Set objFile = objFS.OpenTextFile(strDefaultLocation & strFileName,ForAppending,True)
 With objFile
  .WriteLine strLogText
  .close
 End With
 Set objFile = Nothing 
End Sub
Sub Enit()
 Set objXMLHTTP = Nothing
 Set objFS = Nothing
 Set objDict = Nothing
End Sub
'___________________________________________________________________

'___________________________________________________________________
'Copy/Paste this script to a file named RunWebSiteMon_v0.1.vbs
Option Explicit
'To stop the loop, create a file named stop.txt (can be empty)
Dim intInterval, objShell, objFS
Dim varReturn 'could do without but is handy for troubleshooting
Dim strLocation, strRunFile, strStopFile
Set objFS = CreateObject("Scripting.FileSystemObject")
intInterval = 5
strStopFile = "stop.txt"
With WScript
 strLocation = .ScriptFullName 'get the FQN for this script file
 strLocation = Left(strLocation,InStrRev(strLocation,"\")) 'get just the path portion with trailing \
 strRunFile = """" & Replace(.ScriptFullName,"Run","") & """" 'works as long as file names are not changed from original
End With
Set objShell = WScript.CreateObject("WScript.Shell")
Do 'loop until stop file is present
 On Error Resume Next
 varReturn = objShell.Run(strRunFile, 0, TRUE)
 On Error GoTo 0
 If Len(Trim(varReturn)) = 0 Then Exit Do 'if we don't have a valid return code; bail
 If varReturn <> 0 Then Exit Do    'if the app didn't run properly; bail
 If objFS.FileExists(strLocation & strStopFile) Then  'if stop file is present; bail
  objFS.DeleteFile strLocation & strStopFile 'delete stop file
  Exit Do 'exit loop, then script will end
 End If
 WScript.Sleep intInterval * 1000 'convert miliseconds to seconds
Loop
Set objShell = Nothing
Set objFS = Nothing
'___________________________________________________________________

 
New Post
2/12/2006 8:06 AM
 

I use a sevice from host tracker to keep my site alive, yes it does drive the stats, but I don't need to keep a PC on all the time with a specific window open - http://host-tracker.com/. I also use Open_ViewState to store the viewstate on the server, thus reducing download time. Cost me about $10 on snow-covered - http://www.xepient.com/opendnn.aspx

Roger


DNN MVP
Events - Get the latest version - Upgrade now!!
Feedback 6.4.2 - Now available - Give it a go!
Find us on Codeplex - DNN Events, DNN Feedback
Requirements/Bugs - Please submit them on Codeplex
 
New Post
2/13/2006 10:28 PM
 

I would hazard a guess that most people would use a similar service.  I lucky enough to have a server (PC running 2003) on-site that's up 24x7 for testing mods and such.  I'm not advocating one solution over another.  I just thought I would share. 

 
New Post
2/15/2006 12:05 AM
 
Cool! I've never inspired anything before.  :)

Paul Davis
 
New Post
10/5/2009 5:08 AM
 

Robert Martin wrote
 

'TODO:
  'Copy and paste the following line once for each site you want to add
  'Change "Site" to be the site you want, leave it in quotes
  'Change "URL" to the actual url, leave it in quotes
  'Uncomment the line (remove the begining ' )
  '.Add "Site", "URL"
 

 

Hi. in URL, I must indicate www.mysite.com or www.mysite.com/keepalive.aspx?

 

thanks

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Performance tipsPerformance tips


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out