What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Folder sensor

Votes:

0

Hello

I'm trying the "Folder sensor". I want to make sure that a folder is empty. I cannot see a way to not count hiden files like Thumbs.db. At this point I cannot use the default sensor, it does not fit my needs. Why isn't there a setting to allow to not scan hidden files ? :-( It seems to me really basic setting.

https://www.paessler.com/manuals/prtg/folder_sensor "The Folder sensor counts all files in a folder, including hidden files."

I suppose I'll have to write my own script?

Thank you

Yann

folder-sensor hidden-file settings

Created on Jan 26, 2018 2:29:01 PM



Best Answer

Accepted Answer

Votes:

1

Custom Sensor NetworkFileCount allows you to count files in a folder and optional subfolders while skipping hidden files.

Created on Jan 30, 2018 9:51:24 AM



4 Replies

Votes:

0

Hello,

Thank you for the KB-Post. I'm afraid indeed, as of now this can only be solved with a script running as a custom sensor. I'll forward the improvement request to our dev team though.

best regards.

Created on Jan 29, 2018 1:19:11 PM by  Torsten Lindner [Paessler Support]



Accepted Answer

Votes:

1

Custom Sensor NetworkFileCount allows you to count files in a folder and optional subfolders while skipping hidden files.

Created on Jan 30, 2018 9:51:24 AM



Votes:

0

Well thank you for this last answer.

I already spent hours to setup "Folder sensor" :-( I'll try for antoher case and I probably swtich later to this sensor if it works as expected.

Created on Feb 1, 2018 2:49:38 PM



Votes:

0

As NetworkFileCount is a custom script, I prefered use my own. Really simple, do exactly what I need and no more. Can be easily modified to suit your needs.

Get-ChildItem by default does not return hidden file.

param(
	[string]$computerName,
	[string]$p_folderToCheck
)

$session = New-PSSession -computerName $computerName -Authentication Kerberos 

$scriptBlock = {
	param(
		$p_folderToCheck
	)
    $fileCount = gci -File $p_folderToCheck
	$fileCount = $fileCount.count

    $result= "<?xml version=`"1.0`" encoding=`"Windows-1252`" ?>`r`n"
    $result+="<prtg>`r`n"
	
    $result+="   <result>`r`n"   
    $result+="   	<channel>Nb fichier</channel>`r`n"
	$result+="      <Unit>count</Unit>`r`n"		
    $result+="      <value>$fileCount</value>`r`n"
    $result+="   </result>`r`n"

    $result+="   <text>OK</text>`r`n"
    $result+="</prtg>`r`n"
    $result
}

Invoke-Command -computerName $computername -scriptBlock $scriptBlock -ArgumentList $p_folderToCheck	
Remove-PSSession -computerName $computername
Exit 0

Created on Feb 9, 2018 10:35:34 AM

Last change on Feb 9, 2018 3:07:34 PM by  Torsten Lindner [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.