Logging to Windows evet log |
This script code logs values of rules counters before they resetted.
Can be modified for writing counters values to database or to XML-file or to LOG-file.
Must be used as module or as part of exiting module.
Note:
When you add new event with ScriptModuleEvents.Add or ScriptModuleEvents.AddEx methods via GetRef function - protoype of you'r function must be like this (VBScript):
Function ScriptEvent(CallType, Params)
End Function
Name of function can be any.
When this function called:
CallType equal to ScriptModuleEvent.CallType
Params depends on ScriptModuleEvent.CallType of event:
• | 8 (before counters resetted): params contains 1-element array. This element contain Rule object. |
• | Other values: params equal to NULL and not used. |
Return value ignored at this moment (reserved for future using).
To install this script copy code below into the new or into the end of exiting VBScript module (see Modules).
'================== START ===============
'Declare call type, see ScriptModuleEvent.CallType
Const BeforeCountersResetEvent = 8
'Event function, be called later by service
Function ScriptEvent(CallType, Params)
Dim S, ObjRule
'Make string
'Params(0) contains rule which counters will be resetted
If CallType = BeforeCountersResetEvent Then
Set ObjRule = Params(0)
S = ObjRule.Name & ":" & vbCRLF & _
"Incoming: " & ObjRule.CurrentIn & vbCRLF & _
"Outgoing: " & ObjRule.CurrentOut
'Send maked string to windows event log
TrafficFilter.LogInfo S
End If
End Function
'Add event to the Events list of module
'In this case last parameter ignored (used only in timed events)
'but required and cannot be equal to 0
CurrentModule.Events.Add GetRef("ScriptEvent"), BeforeCountersResetEvent, 1
'=================== END ================