I am not able to get the file count monitor to work in APM 3.0
I am trying to monitor this \\ServerNameHere\Foldername\Foldername\Foldername
I want to monitor all files in subfolders in this directory and when trying to create a new template using the File Count Monitor in APM 3.0 I can not get this to work. I need to include all files because I have several different extensions that end up in this directory and I need to alert if more then 500 files are found.
Full path is that above
File extension I left the * cause I want all files
File Attribute filter All Files
Include subdirectories I have checked.
When I test against the server in the UNC path it never completes just says pending and the little test thing just keeps spinning and spinning never finishes.
Now if I use the script below it finishes and depending on what I put in the script argument it returns the correct file count the only problem with this is that I need to specify the file extension and I can't just use .* to get all files.
Script argument for the below vbscript \\ServerNameHere\Foldername\Foldername\Foldername\ .xml
Option Explicit
On Error Resume Next
Const FAIL = 1, SUCCESS = 0
Dim lstArgs, path, extension, oRegEx, fso, objDir, objFiles, fileName, matches
Set lstArgs = WScript.Arguments
If lstArgs.Count = 2 Then
path = Trim( lstArgs( 0 ))
extension = Trim( lstArgs( 1 ))
Else
WScript.Echo "Message: Usage: cscript.exe FileCount.vbs [pathToFiles] [extension]" _
&vbCRLF &" [pathToFiles] Local or UNC Path "_
&vbCRLF &" [extension] File Extension (no ""."" required )"
WScript.Echo "Statistic: 0"
WScript.Quit( FAIL )
End If
Set oRegEx = New RegExp
oRegEx.Pattern = "\."
oRegEx.Global = True
oRegEx.IgnoreCase = True
' Remove all '.' characters from extension string
extension = oRegEx.Replace( extension, "" )
If( Len( extension ) = 0 )Then
WScript.Echo "Message: Invalid Extension."
WScript.Echo "Statistic: 0"
WScript.Quit( FAIL )
End If
Set fso = Wscript.CreateObject( "Scripting.FileSystemObject" )
If fso.FolderExists( path ) Then
Set objDir = fso.GetFolder( path )
If( IsEmpty( objDir ) = True ) Then
WScript.Echo "Message: Object (Directory) not initialized"
WScript.Echo "Statistic: 0"
WScript.Quit( FAIL )
End If
Set objFiles = objDir.Files
If( IsEmpty( objFiles ) = True ) Then
WScript.Echo "Message: Object (Files) not initialized."
WScript.Echo "Statistic: 0"
WScript.Quit( FAIL )
End If
matches = 0
For Each fileName In objFiles
If InStrRev( LCase( fileName ), extension ) = ( Len( fileName ) - Len( extension ) + 1 ) Then
matches = matches + 1
End If
Next
Else
WScript.Echo "Message: Folder not found."
WScript.Quit( FAIL )
End If
WScript.Echo "Message: "& CInt( matches ) & " matches found."
WScript.Echo "Statistic: " & CInt( matches )
WScript.Quit( Success )
any help would be appreciated and thanks to whoever created the script above and made it available in the download content area.