New Question
 
 
PRTG Network Monitor

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.

Free PRTG
Download >>

 

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!

Learn more

 

Top Tags


View all Tags


Ftp Sensor | Filter on Filetype

Votes:

0

Your Vote:

Up

Down

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 by  Johannes B. Latzel ([email protected]) (24) 1



3 Replies

Votes:

0

Your Vote:

Up

Down

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

Your Vote:

Up

Down

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 by  Johannes B. Latzel ([email protected]) (24) 1

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



Votes:

0

Your Vote:

Up

Down

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]



Please log in or register to enter your reply.


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.