Monitoring a folder 
Author Message
 Monitoring a folder

I am hoping someone could help me with this.  I need a script that will do
the following:

 I need to setup monitoring of a fileupload directory for files that exceed
a threshold of time existing without being processed every 15 minutes.  If a
file is in this folder longer than 15 min I want to send an email to someone
using sendmail or some other appropriate means.

The background of this is that we have a folder that recieves files then
another process pushes these files out.  If a file is in this folder longer
than 15 min there is a problem and usually a build up of files accumulates.
We want a sort of early warning system..  Any help here would be greatly
appriciated.

Bob



Tue, 06 Dec 2005 06:37:26 GMT  
 Monitoring a folder
put the "monitor" into the upload page.

each time a new upload is received, check the folder for time expired files
and act on findings.
 It won't happen every 15 minutes but the effect is the same.

================================
 http://www.ASPkey.net/
A Resource Site for Web Developers
*Free OnLine web Tools
*Free development services
================================

Quote:

>I am hoping someone could help me with this.  I need a script that will do
>the following:

> I need to setup monitoring of a fileupload directory for files that exceed
>a threshold of time existing without being processed every 15 minutes.  If
a
>file is in this folder longer than 15 min I want to send an email to
someone
>using sendmail or some other appropriate means.

>The background of this is that we have a folder that recieves files then
>another process pushes these files out.  If a file is in this folder longer
>than 15 min there is a problem and usually a build up of files accumulates.
>We want a sort of early warning system..  Any help here would be greatly
>appriciated.

>Bob



Tue, 06 Dec 2005 10:54:55 GMT  
 Monitoring a folder
I think On windows 2000 or later, it is possible to receive notification of
changes to a folder using explorer shell. Sorry I don't know how, you may
want to look that up in google.com or msdn

Another way would be using timer event of 15 minute interval ( something
like a loop with Wscript.Sleep 15000
), and check for all files in the folder older than 15 mindute ( (current
date time - modified date time) > 15 minute). how to check for files and
their attributes? see file system object under collections of folders and
files

here is some pseudo code
  ' setup fso
' go to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/scri...
' click on the left pane  Script RunTime, FileSystem Object
   Set fso = CreateObject("Scripting.FileSystemObject")

' also set up the folder object ftpFoldr
ftpFoldr=fso.GetFolder("yourFTPfolderspec");
while true
 Wscript.Sleep 15000
  fc = new Enumerator(ftpFoldr.files);
   s = "";
   for (; !fc.atEnd(); fc.moveNext())
   {

      if ( now() - fc.item().DateCreated > 15 minute) then ' note that I
used pseduo code for time diference
        ' you should look up Now(),
        '
              ' DateAdd Function Returns a date to which a specified time
interval has been added.
              ' DateDiff Function
              ' etc
              mailto .... ' again you have to look this up
          loop

      loop Returns the number of intervals between two dates.

      s += "<br>";
   }

I know  one way for getting the vbs script help and reference  lcoally on
your PC is
windows start, programs, microsoft windows script,  windows script 5.6
documentation
(the last part may have a different version for you if you don't run XP)

Failing that

open word xp , tools, macro, script editor and then F1 key, finally vbs
script help.

failing that use msdn or google search. on the internet.


Quote:
> I am hoping someone could help me with this.  I need a script that will do
> the following:

>  I need to setup monitoring of a fileupload directory for files that
exceed
> a threshold of time existing without being processed every 15 minutes.  If
a
> file is in this folder longer than 15 min I want to send an email to
someone
> using sendmail or some other appropriate means.

> The background of this is that we have a folder that recieves files then
> another process pushes these files out.  If a file is in this folder
longer
> than 15 min there is a problem and usually a build up of files
accumulates.
> We want a sort of early warning system..  Any help here would be greatly
> appriciated.

> Bob



Tue, 06 Dec 2005 10:45:50 GMT  
 Monitoring a folder
Thanks for the reply... but.... I was hoping someone could give me a hand scripting this.  I have searched numerous sites for similar scripts and being new to this I am at a loss.  Any help with this script would be greatly appriciated.

Bob

**********************************************************************

Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...



Tue, 06 Dec 2005 21:53:50 GMT  
 Monitoring a folder
Hope this helps

Sub montorFileCreate(sFolder)
     'Monitor File Creation
     Dim strComputer, strPath
     strPath = Replace(sFolder,"/","\\")
     If strPath = Null Then Exit Sub
     strComputer = "."
     Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & _
 strComputer & "\root\cimv2")
     Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
 ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
 & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
 & "TargetInstance.GroupComponent= " _
 & "'Win32_Directory.Name=" & strPath & "'")
     Do
          Set objLatestEvent = colMonitoredEvents.NextEvent
          Wscript.Echo objLatestEvent.TargetInstance.PartComponent
     Loop
End Sub

Sub monitorFileDelete(sFolder)
     'Monitor File Deletion
     Dim strComputer, strPath
     strPath = Replace(sFolder,"/","\\")
     If strPath = Null Then Exit Sub
     strComputer = "."
     Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & _
 strComputer & "\root\cimv2")
     Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
 ("SELECT * FROM __InstanceDeletionEvent WITHIN 10 WHERE " _
 & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
 & "TargetInstance.GroupComponent= " _
 & "'Win32_Directory.Name=" & strPath & "'")
     Do
          Set objLatestEvent = colMonitoredEvents.NextEvent
          Wscript.Echo objLatestEvent.TargetInstance.PartComponent
     Loop
End Sub

Sub monitorFileModify(sFile)
     'Monitor File Modification
     Dim strComputer, strPath
     strPath = Replace(sFolder,"/","\\")
     If strPath = Null Then Exit Sub
     strComputer = "."
     Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & _
 strComputer & "\root\cimv2")
     Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
 ("SELECT * FROM __InstanceModificationEvent WITHIN 10 WHERE " _
 & "TargetInstance ISA 'CIM_DataFile' and " _
 & "TargetInstance.Name='" & " & strPath & " & "'")
     Do
          Set objLatestEvent = colMonitoredEvents.NextEvent
          Wscript.Echo "File: " & objLatestEvent.TargetInstance.Name
          Wscript.Echo "New size: " & objLatestEvent.TargetInstance.FileSize
          Wscript.Echo "Old size: " &
objLatestEvent.PreviousInstance.FileSize
     Loop
End Sub

Bob S.


Quote:
> Thanks for the reply... but.... I was hoping someone could give me a hand

scripting this.  I have searched numerous sites for similar scripts and
being new to this I am at a loss.  Any help with this script would be
greatly appriciated.
Quote:

> Bob

> **********************************************************************

> Comprehensive, categorised, searchable collection of links to ASP &

ASP.NET resources...


Tue, 06 Dec 2005 22:30:08 GMT  
 Monitoring a folder
Thanks guys


Quote:
> I am hoping someone could help me with this.  I need a script that will do
> the following:

>  I need to setup monitoring of a fileupload directory for files that
exceed
> a threshold of time existing without being processed every 15 minutes.  If
a
> file is in this folder longer than 15 min I want to send an email to
someone
> using sendmail or some other appropriate means.

> The background of this is that we have a folder that recieves files then
> another process pushes these files out.  If a file is in this folder
longer
> than 15 min there is a problem and usually a build up of files
accumulates.
> We want a sort of early warning system..  Any help here would be greatly
> appriciated.

> Bob



Wed, 07 Dec 2005 20:49:21 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Control for monitoring a folder

2. Monitoring a folder using WaitforSingleObject...??

3. Monitoring a Folder

4. Monitor a folder

5. Monitor New file Creation in a specific Folder

6. Help with script to Monitor Folder Creation

7. GUI programmed on 14inch monitor is different on 19inch Monitor

8. Performance Monitor , eh Monitor

9. Usinig 2 monitors: IDE problem on secondary monitor

10. folder in a folder in a folder...

11. Build XML of folders, sub folders and files from specified folder

12. Determining if a folder is a local pst folder or a imap (server folder)

 

 
Powered by phpBB® Forum Software