Intégration de la technologie Serveur FILES-CHECK


ServicePilot server-files-check


# Files check

Overview

This package is designed to run a console command to capture information about the status or existence of files in a directory.

Description

This package is designed to run a console command that is parametrized to collect information about the age, size and number of files in a directory.

The output of the console command is then passed back to ServicePilot and presented as indicators that can then have threshold policies applied.

Requirements

  • ServicePilot Requirements

    • ServicePilot Manager minimum version: 9.0
    • ServicePilot Agent minimum version: 9.0 installed and configured
    • The ServicePilot Remote Command agent needs to be sent the server-files-check.ps1 script. Place the server-files-check.ps1 script in the <WorkFolder>\Conf\RemoteCommandAgent directory on the ServicePilot Manager server.

Installation

Before adding a resource to monitor, make certain that all pre-requisites are in place and that the ServicePilot Agent is communicating correctly with the ServicePilot Manager.

Add resource using Views Configuration web interface

  1. As an administrative user of ServicePilot, open the ServicePilot web interface.
  2. Navigate to Administration. The Configuration > Views web page will open.
  3. Click on the view in which to place the new resource in the Views hierarchy on the left of the interface. The View editor section will show the existing view contents.
  4. From the Packages list on the right of the interface, click and drag the server-files-check package into the View editor and let go.
  5. The Resource properties dialog box will open to allow resource configuration.
  6. Click OK to close the Resource properties dialog box. Note that the dialog box will not close if required parameters are not set.
  7. Click Save to apply the new resource to ServicePilot configuration.

License

Object TypeLicense object ConsumedCondition
Files check1

Key field notes

  1. Parameters tab:

    1. Mode: The method run on the files in the directory. Count:Number of files. Sum:Sum all file sizes. Newest:Age of the most recent file found. Oldest:Age of the oldest file found. Smallest:Size of the smallest file found. Biggest:Size of the biggest file found.
    2. Directory: The directory in which to test the file operations.
    3. Recurse: Recurse in to sub-directories.
    4. Include File Mask: A file mask to filter the list of files in the directory before running file tests.
    5. Polling Interval (sec): The polling connection interval. Must be 60 or larger. If greater than around 285 seconds a monitoring policy will be required so extend the no data time-out of the object.
  2. Limiting Options tab:

    1. Ignore files: Enable the ignore file pattern match.
    2. Ignore File Mask: A file mask to filter the list of files in the directory before running file tests.
    3. Limit Type: Limit the files found based on criteria. Older or Newer:Limit by file age. Smaller or Bigger:Limit by file size.
    4. Age: Limit the results to files that are older or newer than this number of seconds in the past.
    5. Size: Limit the results to files that are smaller or bigger than this number of bytes.

Notes

This package works by using the ServicePilot Remote Command Agent to run a script on a Windows computer to return the values required. The server-files-check.ps1 script presented below needs to be placed in the <WorkFolder>\Conf\RemoteCommandAgent directory on the ServicePilot Manager server:

param ( [Parameter(Mandatory=$True)] [ValidateSet('count', 'sum', 'newest', 'oldest', 'smallest', 'biggest')] [string]$mode, [Parameter(Mandatory=$True)] [ValidateNotNullorEmpty()] [string]$dir, [string]$mask, [string]$ignore, [Switch]$recurse, [ValidateRange(0,[int]::MaxValue)] [int]$older, [ValidateRange(1,[int]::MaxValue)] [int]$newer, [ValidateRange(1,[int]::MaxValue)] [int]$smaller, [ValidateRange(-1,[int]::MaxValue)] [int]$larger)$WhereArray=@()if($ignore -ne ''){$WhereArray += '$_.Name -notlike "' + $ignore + '"'}if($mask -ne ''){$WhereArray += '$_.Name -like "' + $mask + '"'}if($older){$WhereArray += '$_.LastWriteTime -lt (Get-Date).AddSeconds(-' + $older + ')'}if($newer){$WhereArray += '$_.LastWriteTime -gt (Get-Date).AddSeconds(-' + $newer + ')'}if($smaller){$WhereArray += '$_.Length -lt ' + $smaller}if($larger){$WhereArray += '$_.Length -gt ' + $larger}$files=@()if($WhereArray.Count -gt 0){ $WhereString = $WhereArray -Join " -and " $WhereBlock = [scriptblock]::Create( $WhereString ) $files=@(Get-ChildItem -Recurse:$recurse -File -Path $dir | Where-Object {Invoke-Expression "$WhereBlock"})}else{ $files=@(Get-ChildItem -Recurse:$recurse -File -Path $dir)}$count=$files.Count$age=''$size=''if($count -gt 0){ $file=$null switch($mode){   sum {$size=($files | Measure-Object -Sum Length).Sum}   newest {$file=($files | Sort-Object -Property LastWriteTime | Select-Object -Last 1)}   oldest {$file=($files | Sort-Object -Descending -Property LastWriteTime | Select-Object -Last 1)}   smallest {$file=($files | Sort-Object -Descending -Property Length | Select-Object -Last 1)}   biggest {$file=($files | Sort-Object -Property Length | Select-Object -Last 1)} } if($mode -ne 'count' -and $mode -ne 'sum'){   $age=[int](Get-Date).Subtract($file.LastWriteTime).TotalSeconds   $size=$file.Length }}Write-Host -NoNewline "size=$size age=$age count=$count"

Comment pouvons-nous vous aider ?

ou appelez-nous au +33 2 40 60 13 30