It is currently January 20th, 2022, 2:53 pm

CheckNet : Test network / Internet connectivity

Share and get help with Plugins and Addons
User avatar
jsmorley
Developer
Posts: 22449
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

CheckNet : Test network / Internet connectivity

Post by jsmorley »

I wanted a little plugin to check or monitor the connection status of my system. Like the Windows notification area icon, it needs to be able to react to having no network connection at all (LAN) or having no Internet (WAN) connection.

The little CheckNet plugin that is installed with this skin takes the following form:

Code: Select all

[MeasureNetwork]
Measure=Plugin
Plugin=CheckNet
ConnectionType=Network
UpdateRate=5
The ConnectionType option can be:

Network : Tests that you are connected to a network.
Internet : Tests that you can reach the Internet. (default)

The measure will be set to 1 on success, to -1 on failure.

FinishAction can be used to have the measure take actions when the result is returned.

UpdateRate is used to control how often the network resource is checked. The value is in milliseconds, and is multiplied by the value of Update in the [Rainmeter] section of the skin. The default value is 20. With Update=1000, this is equal to every 20 seconds.

Note: Setting a very low UpdateRate for ConnectionType=Network is fine. Checking that status even every second will not use significant resources. However, some care should be taken when using ConnectionType=Internet. The process it uses is a very tiny UDP socket connection to your defined DNS server, and while the amount of traffic generated is very, very small, It could add up over time if you are hitting it every second. I recommend leaving the default of 20, but that is up to you.

Skin requires the latest 3.0.1 release version of Rainmeter from http://rainmeter.net.

The appropriate 32bit or 64bit CheckNet.dll plugin is installed in your APPDATA\Rainmeter\Plugins folder when you install the .rmskin.
CheckNet_2.0.rmskin

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[Metadata]
Name=CheckNet
Author=JSMorley
Information=Demonstrates the CheckNet plugin.|This will allow you to check the status of your network connection (LAN) and / or your connection to the Internet (WAN)||The ConnectionType option can be "Network" or "Internet" (default).||Use UpdateRate to control how often the network and / or internet are checked.  The default for UpdateRate is 20.
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Version=Oct 27, 2013

[MeasureNetwork]
Measure=Plugin
Plugin=CheckNet
ConnectionType=Network
UpdateRate=5
IfBelowValue=0
IfBelowAction=[!SetOption MeterImage ImageName ErrorNetwork.png][!DisableMeasure MeasureInternet][!UpdateMeter *][!Redraw] 
IfAboveValue=0
IfAboveAction=[!SetOption MeterImage ImageName NetworkOk.png][!EnableMeasure MeasureInternet][!UpdateMeter *][!Redraw] 

[MeasureInternet]
Measure=Plugin
Plugin=CheckNet
ConnectionType=Internet
UpdateRate=20
Disabled=1
IfBelowValue=0
IfBelowAction=[!SetOption MeterImage ImageName ErrorInternet.png][!UpdateMeter *][!Redraw] 
IfAboveValue=0
IfAboveAction=[!SetOption MeterImage ImageName NetworkOk.png][!UpdateMeter *][!Redraw] 

[MeterImage]
Meter=Image
ImagePath=#@#Images\
ImageName=NetworkChecking.png
10-27-2013 1-57-47 PM.jpg
Note: Both the 32bit and 64bit plugin .dll files are included in the skin @Resources folder, so you can distribute the plugin with your own .rmskins.
You do not have the required permissions to view the files attached to this post.
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: Work in progress: CheckNet

Post by Seahorse »

Shiny... 8-)
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Work in progress: CheckNet

Post by moshi »

cool, does what it should.
and it seems more reliable than abusing the ping plugin for that. :thumbup:
User avatar
jsmorley
Developer
Posts: 22449
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Work in progress: CheckNet

Post by jsmorley »

moshi wrote:cool, does what it should.
and it seems more reliable than abusing the ping plugin for that. :thumbup:
Yes. It is also orders of magnitude faster than using Ping or WebParser to "test" for connectivity.

In truth there is no "perfect" solution for this, as there are scenarios where this could be fooled. If for instance you are on a corporate network that has implemented a local DNS server on the LAN, this might indicate that you have Internet connectivity when in fact you don't. Another situation is when you are on a WIFI network like in a Starbucks, where you have limited Internet connectivity, probably just enough to get to a login or signup page in your browser, but no further. This would probably indicate that you have Internet connectivity when one could argue that you don't.

http://blog.superuser.com/2011/05/16/windows-7-network-awareness/

The only TRULY reliable way to ever know that the Internet is working for you is to go to a site with HTTP and ensure you get some expected text back. However, for my purposes (and for 99% of users at home, work or school) this is going to be good enough. Having any more robust checking would be fine for something you use very seldom, like WebParserTest, but not something you would want to be running all the time in a "monitoring" role.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: Work in progress: CheckNet

Post by moshi »

i guess one could use dig with Brian's new RunCommand plugin. that should be faster and use less traffic than the webparser plugin.
but it still would be overkill. :)
User avatar
jsmorley
Developer
Posts: 22449
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: CheckNet : Test network / Internet connectivity

Post by jsmorley »

Updated the plugin to version 1.1 in the first post of this thread.

The plugin now always checks the "network" availability, so pointless "internet" checks are not done if there is no network connectivity at all.

So if you set ConnectionType=Network, then just the network test is done. If you set ConnectionType=Internet, then first it will check for network availability, and only if that succeeds, will then check the internet.
User avatar
jsmorley
Developer
Posts: 22449
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: CheckNet : Test network / Internet connectivity

Post by jsmorley »

Updated the plugin to version 2.0 in the first post of the thread.

The plugin is now "threaded" so in the unlikely event that the "internet" checking is slow, Rainmeter is not "blocked" while waiting for the plugin to complete.
FlyingHyrax
Posts: 232
Joined: July 1st, 2011, 1:32 am
Location: US

Re: CheckNet : Test network / Internet connectivity

Post by FlyingHyrax »

Jeff,
I'm not sure, but you might not have updated the plugin in the top post to 2.0. "About" still says the plugin is at 1.1 after using that rmskin.

Edit: You might have just forgotten to update the build number in metadata somewhere; I built it from source in VS and About still says 1.1

EditEdit: Confirmed: @see AssemblyInfo.cs
Last edited by FlyingHyrax on December 20th, 2013, 7:39 pm, edited 3 times in total.
Flying Hyrax on DeviantArt
User avatar
jsmorley
Developer
Posts: 22449
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: CheckNet : Test network / Internet connectivity

Post by jsmorley »

FlyingHyrax wrote:Jeff,
I'm not sure, but you might not have updated the plugin in the top post to 2.0. "About" still says the plugin is at 1.1 after using that rmskin.
I'll look into it. Thanks.

Edit: Should be correct now.
User avatar
AZbor1
Posts: 6
Joined: September 8th, 2012, 6:24 pm
Location: Novosibirsk, Russia

Re: CheckNet : Test network / Internet connectivity

Post by AZbor1 »

Hi :)

I understand that the function of this plugin have been added to the plugin SysInfo?