Page 1 of 1

Router Traffic

Posted: April 10th, 2015, 9:34 pm
by Jaerin
So in the network monitoring tool Networx there is an option to have it monitor the WANCommonInterface of the UPNP to pull network statistics directly from the router and not your local machine.

Does anyone know if there would be a similar option to allow this in Rainmeter?

Here is information on the UPNP interface I'm talking about:
http://upnp.org/specs/gw/UPnP-gw-WANCommonInterfaceConfig-v1-Service.pdf

Re: Router Traffic

Posted: February 10th, 2017, 10:18 pm
by DollarD
Something like this, perhaps?

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

....................................................................................................................................................

[Variables]
CurrTime=0

....................................................................................................................................................

[MeasureDownload]
Measure=NetIn
Interface=0
MaxValue=1840000
AverageSize=4

[MeasureUpload]
Measure=NetOut
Interface=0
MaxValue=720000
AverageSize=4

[MeasureUsage]
Measure=NetTotal
Interface=0
Cumulative=1

[MeasureTimer]
Measure=Uptime
OnUpdateAction=[!SetVariable LastTime #CurrTime#][!SetVariable CurrTime [MeasureTimer:]][!CommandMeasure MeasureRouter Run]
UpdateDivider=5
DynamicVariables=1

[MeasureRouter]
Measure=Plugin
Plugin=Plugin\RunCommand.dll
Parameter=C:\Windows\System32\cscript.exe /nologo C:\Root\upnp_getinfo.vbs
OutputType=ANSI
FinishAction=[!UpdateMeasure "MeasureBytesReceived"][!UpdateMeasure "MeasureBytesSent"]
DynamicVariables=1
UpdateDivider=-1

[MeasureTimePassed]
Measure=Calc
Formula=(#CurrTime# - #LastTime#)
DynamicVariables=1

[MeasureBytesReceived]
Measure=String
String=[MeasureRouter]
DynamicVariables=1
RegExpSubstitute=1
Substitute="(?siU).*<NewTotalBytesReceived>(\d*)<\/NewTotalBytesReceived>.*$":"\1"
OnUpdateAction=[!SetVariable PrevRec #CurrRec#][!SetVariable CurrRec [MeasureBytesReceived]]
UpdateDivider=-1

[MeasureBytesSent]
Measure=String
String=[MeasureRouter]
DynamicVariables=1
RegExpSubstitute=1
Substitute="(?siU).*<NewTotalBytesSent>(\d*)<\/NewTotalBytesSent>.*$":"\1"
OnUpdateAction=[!SetVariable PrevSent #CurrSent#][!SetVariable CurrSent [MeasureBytesSent]]
UpdateDivider=-1

[MeasureRouterRec]
Measure=Calc
Formula=(#CurrRec# - #PrevRec#) / [MeasureTimePassed]
MaxValue=230000
DynamicVariables=1

[MeasureRouterSent]
Measure=Calc
Formula=(#CurrSent# - #PrevSent#) / [MeasureTimePassed]
MaxValue=88000
DynamicVariables=1
With upnp_getinfo.vbs as follows:

Code: Select all

On Error Resume Next

host = "192.168.10.1"

If host <> False Then
 Set http = Nothing
 Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
 If http Is Nothing Then Set http = CreateObject("WinHttp.WinHttpRequest.5")
 If http Is Nothing Then Set http = CreateObject("WinHttp.WinHttpRequest")
 If http Is Nothing Then Set http = CreateObject("MSXML2.ServerXMLHTTP")
 If http Is Nothing Then Set http = CreateObject("Microsoft.XMLHTTP")
 If http Is Nothing Then
  MsgBox "No HTML Object",16,"Error"
 Else
  body = "<?xml version=""1.0"" encoding=""utf-8""?>" _
   & "<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/"" s:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"">" _
   & "<s:Body><u:GetAddonInfos xmlns:u=""urn:schemas-upnp-org:service:WANIPConnection:1"" /></s:Body></s:Envelope>"
  url = "igdupnp/control/WANCommonIFC1"
   With http
    .Open "POST", "http://" & host & ":49000/" & url,false
    .setRequestHeader "Content-Type", "text/xml; charset=""utf-8"""
    .setRequestHeader "Connection", "close"
    .setRequestHeader "Content-Length", Len(body)
    .setRequestHeader "HOST", host & ":49000"
    .setRequestHeader "SOAPACTION", """urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1#GetAddonInfos"""
    .Send body
   End With

  WScript.Echo http.responseText
    
  WScript.Quit

 End If
End If