### What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Intuitive to Use. Easy to manage.
300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

View all Tags

# Monitor a pickup folder

#### 0

Looking to monitor a pickup folder or file inbox. The normal folder & file share sensors won't work as needed.

New files are dropped into
server\share Another process polls this location every x minutes, pulls files out and removes from the share if this process breaks, files back up in this location.

There could be any number of files in the share at any given moment. The files could have new or old creation dates. Basically need to ensure that no file name continues to exist from one check period as this would indicate that the import process is not functioning.

Created on Jun 22, 2017 6:06:28 PM by

3 Replies

#### 0

Hi Jonathan,

You're right here, none of our sensors is able to check for that. You could however write a small PowerShell script that checks a directory for its childitems and creates a list of them. In the next run, it gets the childitems again and compares them to the list - if they're identical, the sensor throws a warning or error with the corresponding message.

Unfortunately, we can't assist in writing custom script sensors for customers as it is too time consuming. Further information about the sensors and what the expected output of the script/exe has to look like, can be found in the manual:

Maybe some of the forum members once needed a similar script and don't mind to share it? :)

Kind regards,

Created on Jun 23, 2017 10:14:36 AM by

#### 0

OK, I wrote the script. You can use the parameters field in the sensor settings to pass a folder path to monitor and path +filename where we can store results. Like this: '
path\to\foler' '
path\to\results.xml'

#checks a pickup folder or dropbox for files that haven't been processed.
$filepath =$Args[0]     #path to folder to monitor
$previousfile =$Args[1]  #path to previous xml file

#pull current directory listing
$current = Get-ChildItem "$filepath" | select Name     #you can add -Exclude if you need to ignore some files
$count =$current.count

#check if there are actaully any files in the directory.  no need to continue if folder is empty
if ($count -eq 0) { #no files in the dir return "0:OK" } #check if previous listing exists If ((Test-Path "$previousfile") -eq $false) { #file doesn't exist, create a new one. don't compair until next check$current | Export-Clixml "$previousfile" return "0:OK" } #load preivous listing$previous = Import-Clixml "$previousfile" #compare and count to find stuck files$count = (Compare-Object -ReferenceObject $previous -DifferenceObject$current -ExcludeDifferent -IncludeEqual).count

#save the current list as the new "previous" list
$current | Export-Clixml "$previousfile"

#make sure count isn't null so that we get a numerical value returned.
if ($count -eq$null) { $count = 0 } return "$count:OK"
`

Created on Jun 23, 2017 11:31:05 AM by

Last change on Jun 27, 2017 10:25:18 AM by

#### 0

You want to know the easier way to do it? or the coolest?

The easiest is what is listed above (dump folder list, wait till next run, look for dupes, delete, start again).

The coolest way is look at the USN Journal, it will show you when a file gets moved or copied to a certain folder (even though the modified date does not change.)

Or another simple way that might work, look at the create date, no the modified date. (When a file gets copied it gets a new create date, this applies most of the time, but worth checking in your case). So copy and delete the file, rather than move. If a file gets moved it creates the original timestamp.

Please let us know what way worked best.

Created on Jun 27, 2017 5:00:22 AM by AndrewG (1,783) 2 2