I've created a script that will monitor a Folder size for MOM 2005 if the file size is Greater then the specified threshold then an Event will be raised in MOM.
Parameters - Folder_name (need to specify the Path and the Folder Name), FolderSize_Threshold (Folder size in KB) and GenerateEvent (1 to Generate Success Event and 0 to Disable Success Event)
Create New Event Rule to Monitor the Event ID 4446 for Folder size is greater then the specified Threshold.
Create New Event Rule to Monitor the Event ID 4447 for Success Event.
Create New Event Rule to Monitor the Event ID 4442 for Folder Not found Error.
If you want to change the folder size to be smaller then Specified threshold then find the below line in the script "if foldersize > FolderSizeThreshold then" and change it to "if foldersize < FolderSizeThreshold then"
'********************************************************************************
Option Explicit
Dim foldersize, fs, folder, bGenerateEvent
Dim Foldername, FolderSizeThreshold
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
Foldername = objParameters.get("Folder_name")
FolderSizeThreshold = objParameters.get("FolderSize_Threshold")
bGenerateEvent = objParameters.get("GenerateEvent")
Set fs=CreateObject("Scripting.FileSystemObject")
Set folder=fs.GetFolder(Foldername)
If Err.Number > 0 Then
Set objEvt = ScriptContext.CreateEvent
objEvt.Message = "Cannot find the folder " & Err.Number & " on the server " & objEvt.LoggingComputer
objEvt.EventSource = "FolderSizeMonitor"
objEvt.EventType = EVENT_TYPE_ERROR
objEvt.EventNumber = 4442
ScriptContext.Submit(objEvt)
ScriptContext.Quit
Else
foldersize = folder.Size / 1024
if foldersize > FolderSizeThreshold then
Set objEvt = ScriptContext.CreateEvent
objEvt.Message = "The Folder " & Foldername & " on " & objEvt.LoggingComputer & " is greater then the specified threshold (threshold =" & FolderSizeThreshold & ")"
objEvt.EventSource = "FolderSizeMonitor"
objEvt.EventType = EVENT_TYPE_ERROR
objEvt.EventNumber = 4446
ScriptContext.Submit(objEvt)
ScriptContext.Quit
Else
if bGenerateEvent = 1 then
Set objEvt = ScriptContext.CreateEvent
objEvt.Message = "The Folder " & Foldername & " on " & objEvt.LoggingComputer & " is less then the specified threshold (threshold =" & FolderSizeThreshold & ")"
objEvt.EventSource = "FolderSizeMonitor"
objEvt.EventType = EVENT_TYPE_SUCCESS
objEvt.EventNumber = 4447
ScriptContext.Submit(objEvt)
ScriptContext.Quit
End if
End If
End if
Thursday, May 24, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment