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

Ftp Sensor | Filter on Filetype

Votes:

0

I would like to count the number of files in a folder on a ftp server of certain types, e.g. count all xml files. As far as I can see the "FTP SERVER FILE COUNT SENSOR" can not filter by filename. Is there another sensor I can use?

filename filetype filter ftp ftp-files

Created on Jul 20, 2020 8:22:10 AM



3 Replies

Votes:

0

Hello Johannes,

I'm afraid there is no native sensor for this. I would recommend to take a look here if this is an option for you.


Kind regards

Felix Wiesneth - Team Tech Support

Created on Jul 20, 2020 12:40:52 PM by  Felix Wiesneth [Paessler Support]



Votes:

0

I created a custom sensor using Powershell, Nuttercode-Prtg and PSFTP.

Param (
    [Parameter(Mandatory=$True,Position=0)][String]$Hostname,
    [Parameter(Mandatory=$True,Position=1)][String]$Username,
    [Parameter(Mandatory=$True,Position=2)][String]$Password,
    [Parameter(Mandatory=$True,Position=3)][String]$Path,
    [Parameter(Mandatory=$False,Position=4)][String]$Filter = "*",
    [Parameter(Mandatory=$False,Position=5)][switch]$Recurse = $false
)

$ErrorActionPreference = "Stop"
Import-Module PSFTP

$sensor = New-PRTGSensor
[int]$itemCount = 0

try {
    $garbage = Set-FTPConnection -Session Session -Server $Hostname -Credentials (New-Object -TypeName System.Management.Automation.PSCredential -Argumentlist $Username, ($Password | ConvertTo-SecureString -AsPlainText -Force))
    $session = Get-FtpConnection -Session Session
    $itemCount = @(
        $(
            if( $Recurse ) {
                Get-FTPChildItem -Session $Session -Path $Path -Recurse
            }
            else {
                Get-FTPChildItem -Session $Session -Path $Path
            }
        ) | ? { $_.Name -like $Filter }
    ).Count
}
catch {
    $sensor.has_error = $true
    $sensor.error_code = 1
    $sensor = $sensor | Set-PRTGSensorText -text "An error occurend while running this sensor. Message: $_"
}

$sensor |
    Add-PRTGChannel -name "File Count" -value $itemCount -unit Count |
Convert-PRTGSensorToXML

Created on Jul 21, 2020 1:19:58 PM

Last change on Jul 22, 2020 6:25:39 AM by  Felix Wiesneth [Paessler Support]



Votes:

0

Hello Johannes,

thank you for sharing your solution.


Kind regards

Felix Wiesneth - Team Tech Support

Created on Jul 22, 2020 6:26:30 AM by  Felix Wiesneth [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.