'**************************************************************************************************************** '** NAME: FilesizeMonitor.vbs '** '** AUTHOR: Mohan Muniswamy - Email-ID: mohan.muniswamy@gmail.com '** '** Parameters - File_name (need to specify the Path and the file Name) and FileSize_Thershold (File size in KB) '** '** Create New Event Rule to Monitor the Event ID 4444 for File Threshold Exceed and Event 4441 for File Not found Error. '** '***************************************************************************************************************** Option Explicit Dim filesize, fs, file Dim Filename, FileSizeThershold Dim objEvt, objParameters Const EVENT_TYPE_SUCCESS = 0 Const EVENT_TYPE_ERROR = 1 Const EVENT_TYPE_WARNING = 2 Const EVENT_TYPE_INFORMATION = 4 Const EVENT_TYPE_AUDITSUCCESS = 8 Const EVENT_TYPE_AUDITFAILURE = 16 On Error Resume next Set objParameters = ScriptContext.Parameters Filename = objParameters.get("File_name") FileSizeThershold = objParameters.get("FileSize_Thershold") Set fs=CreateObject("Scripting.FileSystemObject") Set file=fs.GetFile(Filename) If Err.Number > 0 Then Set objEvt = ScriptContext.CreateEvent objEvt.Message = "Cannot find the file " & Filename & " on the server " & objEvt.LoggingComputer objEvt.EventSource = "FileSizeMonitor" objEvt.EventType = EVENT_TYPE_ERROR objEvt.EventNumber = 4441 ScriptContext.Submit(objEvt) ScriptContext.Quit Else filesize = file.Size / 1024 if filesize < FileSizeThershold then Set objEvt = ScriptContext.CreateEvent objEvt.Message = "The File " & Filename & " on " & objEvt.LoggingComputer & " is less then the specified threshold (threshold =" & FileSizeThershold & ")" objEvt.EventSource = "FileSizeMonitor" objEvt.EventType = EVENT_TYPE_ERROR objEvt.EventNumber = 4444 ScriptContext.Submit(objEvt) ScriptContext.Quit else End If End if