Om het script aan de praat te krijgen moet je de DLL bestanden in de attachment plaatsen in je Windows/System32 map, en je moet de homeseer settings.ini file aanpassen als volgt:
Code: Select all
ScriptingReferences=System.XML;System.XML.dll,System.Data;System.Data.dll,System.Web;System.web.dll,SNMPDLL;SNMPDll.dll,TableReader;TableReader.dll
Code: Select all
Imports SNMPDll
Sub Main(parm as object)
Dim sUptime As String = "1.3.6.1.2.1.1.3.0"
Dim sTrafficIn As String = "1.3.6.1.2.1.2.2.1.16.1"
Dim sTrafficOut As String = "1.3.6.1.2.1.2.2.1.10.1"
Dim sExternalIP As String = "1.3.6.1.2.1.4.20.1.1.84.197.3.196"
Dim iTrafficIn As Int64
Dim iTrafficOut As Int64
Const EventRefreshRateSecs As Integer = 60
Dim TrafficIn As Decimal
Dim TrafficOut As Decimal
Dim a As SNMPAgent = New SNMPAgent("10.111.0.1", "public", "public")
Dim uptime As SNMPObject = New SNMPObject(sUptime)
Dim externalIP As SNMPObject = New SNMPObject(sExternalIP)
iTrafficIn = CType(New SNMPObject(sTrafficIn).getSimpleValue(a), Int64)
iTrafficOut = CType(New SNMPObject(sTrafficOut).getSimpleValue(a), Int64)
hs.SetDeviceString("V70", uptime.getSimpleValue(a))
hs.SetDeviceLastChange("V70",now)
hs.SetDeviceString("V71", externalIP.getSimpleValue(a))
hs.SetDeviceLastChange("V71",now)
TrafficIn = (iTrafficIn - hs.DeviceValue("V72")) / 1024 / EventRefreshRateSecs
TrafficOut = (iTrafficOut - hs.DeviceValue("V73")) / 1024 / EventRefreshRateSecs
hs.SetDeviceString("V74", TrafficIn.Tostring("0.00") + " KB/sec")
hs.SetDeviceLastChange("V74",now)
hs.SetDeviceString("V75", TrafficOut.Tostring("0.00") + " KB/sec")
hs.SetDeviceLastChange("V75",now)
hs.SetDeviceString("V72", iTrafficIn.ToString)
hs.SetDeviceValue("V72", iTrafficIn)
hs.SetDeviceLastChange("V72",now)
hs.SetDeviceString("V73", iTrafficOut.ToString)
hs.SetDeviceValue("V73", iTrafficOut)
hs.SetDeviceLastChange("V73",now)
End Sub