Экспорт значений счетчиков в XML-файл |
Добавьте VBScript модуль в список модулей службы:
Option Explicit
'полный путь к файлу XML
Const XMLFileName = "c:\routix.netcom.counters.xml"
'Интервал сохранения (сек)
Const SaveInterval = 60
'===========================================================
Sub SaveToXML(AFileName)
Dim I, oXML, oNode, oCountersNode, oPi, oRules, oRule, oAttr
Set oXML = CreateObject("Microsoft.XMLDOM")
oXML.async = False
Set oPi = oXML.createProcessingInstruction("xml", "version='1.0'")
oXML.appendChild oPi
Set oCountersNode = oXML.createNode(1, "counters", "")
oXML.appendChild oCountersNode
Set oRules = TrafficFilter.Rules
With oRules
If .Count = 0 Then
Exit Sub
End If
For I = 0 To .Count - 1
Set oRule = .Items(I)
Set oNode = oXML.createNode(1, "rule", "")
Set oAttr = oXML.createAttribute("name")
oAttr.Value = oRule.Name
oNode.Attributes.SetNamedItem oAttr
Set oAttr = oXML.createAttribute("in")
oAttr.Value = Round(oRule.CurrentIn, 4)
oNode.Attributes.SetNamedItem oAttr
Set oAttr = oXML.createAttribute("out")
oAttr.Value = Round(oRule.CurrentOut, 4)
oNode.Attributes.SetNamedItem oAttr
oCountersNode.appendChild oNode
Next
End With
oXML.LoadXML Replace(oXML.XML, "><", ">" & vbNewLine & "<")
oXML.Save AFileName
End Sub
Function SaveCountersToXML(CallType, Params)
SaveToXML XMLFileName
End Function
Const EveryNSeconds = 1
CurrentModule.Events.Add GetRef("SaveCountersToXML"), EveryNSeconds, SaveInterval