New Ping Plugin

Questions and comments specific to a particular plugin should go here.
Post Reply
User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

New Ping Plugin

Post by kgschlosser » Fri Apr 17, 2020 8:37 pm

New Ping Plugin
v0.1.0


I made some changes to the ping plugin.

Changes:
  • No longer requires you to run EG as an Administrator
  • No longer uses ping.exe
  • No longer can end up with orphaned ping processes
  • No longer can end up with orphaned sockets
  • Removed the ping delay from the actions
  • Removed the "ping string" from the plugin config
  • Sets event names properly if no event name is given.
  • Adds friendly name to event string if there is no "." in the string, and if no friendly name was supplied then it will add the host name instead
  • Single threaded design, before there was a thread created for each host added. This no longer needs to be done.
  • Dynamic delay in the thread to not cause a high processor time when a small number fo hosts are provided and also allow for optimal performance when many hosts are added.
  • 50ms default ping timeout (If this ends up being an issue I will add the ability for user adjustment)
This plugin is almost a drop in replacement for the original. You might have to rename your events that you have set in your macros to conform to the new naming convention.

Here is an example of the naming convention change

In the Add Host
if you left
"Name of event to fire when host become alive:" blank or
"Name of event to fire when host become dead:" blank
then the program is going to set those to
IS_ALIVE and or IS_DEAD

if there is no "." in either the alive event or the dead event
if "Host Friendly Name" is blank then it will prepend the alive and or dead with the "Host Name" separated by a "."
If there is a "Host Friendly Name" supplied then it will prepend that separated by a "."


Add Host Action Config
Host Name: 192.168.1.1
Host Friendly Name:
Name of event to fire when host become alive:
Name of event to fire when host become dead:


the events you will end up with are
192.168.1.1.IS_ALIVE
192.168.1.1.IS_DEAD



Add Host Action Config
Host Name: 192.168.1.1
Host Friendly Name: TestDevice
Name of event to fire when host become alive: Alive
Name of event to fire when host become dead:

the events you will end up with are
TestDevice.Alive
TestDevice.IS_DEAD

Add Host Action Config
Host Name: 192.168.1.1
Host Friendly Name: TestDevice
Name of event to fire when host become alive: SomeDevice.Alive
Name of event to fire when host become dead:DeviceDead

the events you will end up with are
SomeDevice.Alive
TestDevice.DeviceDead

make sense??

The reason why you no longer have to run EG as Administrator is because only an Administrator is able to handle ARP requests. This is including ping.exe. I am now using WMI to do the work for me. which gets done by the system. and this has the privileges to do what needs to get done.
Attachments
Ping-1.0.egplugin
v0.1.0
(6.83 KiB) Downloaded 60 times
If you like the work I have been doing then feel free to Image

V_J
Experienced User
Posts: 237
Joined: Tue Mar 04, 2014 9:00 am

Re: New Ping Plugin

Post by V_J » Mon Apr 20, 2020 6:25 pm

Interesting! I am too busy with other ones, but I will try this one at one point. And I will report any issues. :)

User avatar
Sem;colon
Plugin Developer
Posts: 753
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: New Ping Plugin

Post by Sem;colon » Mon Apr 20, 2020 9:41 pm

Hi Kevin,

I'll surely check this out!
The orphaned ping.exe processes when EG crashes always annoyed me..
But just for the record:
kgschlosser wrote:
Fri Apr 17, 2020 8:37 pm
The reason why you no longer have to run EG as Administrator is because only an Administrator is able to handle ARP requests. This is including ping.exe.
You don't need admin rights for ping.exe, it works fine without ;)
If you like my work, Image me a drink :wink:

User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New Ping Plugin

Post by kgschlosser » Tue Apr 21, 2020 7:11 am

you may not have to "run as Administrator" because your user name is probably apart of the Administrators group. you can verify this by searching for "lusrmgr.msc" on your computer and running it you will be able to see what groups a user account has attached to it.
If you like the work I have been doing then feel free to Image

User avatar
Sem;colon
Plugin Developer
Posts: 753
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: New Ping Plugin

Post by Sem;colon » Tue Apr 21, 2020 12:42 pm

Negative, my user is surely not part of any admin group :wink:
If you like my work, Image me a drink :wink:

User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New Ping Plugin

Post by kgschlosser » Wed Apr 22, 2020 3:26 am

well then that would strange. because in order to produce an arp request (ping does this) it requires administrative privileges. Unless there is a permission somewhere that can be changed that provides the permissions to use arp.. Are you running Windows 10? They may have changed the permission requirements for arp. who knows.

Any rate. set aside the permissions aspect of it.. It doesn't create a new process for each host you want to check. and it only uses a single thread. That in it's self has got to worth something yes/no? and then the added bonus of not ending up with orphaned processes is something goes south and EG crashes or doesn't close properly.
If you like the work I have been doing then feel free to Image

Snowbird
Experienced User
Posts: 374
Joined: Fri Jul 03, 2009 10:04 am

Re: New Ping Plugin

Post by Snowbird » Wed Apr 29, 2020 5:17 pm

50ms default ping timeout (If this ends up being an issue I will add the ability for user adjustment)
it would be nice to adjust this value, if you're planning to ping servers that are located far on the internet, then this 50ms limit could be short :)

is there a way to add some features to test services instead of a simple ping to monitor a remote server ? such as web server, sql server, and some other useful services, or simply by checking a specific keyword on a webpage, if the keyword is not detected while loading the web page then most likely the webserver is down. I know it goes beyond the ping utility, I'm just suggesting, it might be useful.

By the way, thanks for the rewrite of this Ping plugin, I stopped using it because of the reasons you mentioned above, but now I can try this new one, looks much better and complete :)

User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New Ping Plugin

Post by kgschlosser » Wed Apr 29, 2020 6:57 pm

why would someone be pinging a server on the other side of the world from EG?. If it is not your server it is a good way to get your IP banned form the server for 1 for 2 you can simply connect to the server using whatever mechanism you are using to normally communicate with the thing, If you are unable to connect to it then guess what?? it's offline. The ping program is more for checking if a cell phone has connected to your local network via WiFi. Or checking the power state of say.. a Samsung TV.

HTTP is easy to check from a script.

Code: Select all

import requests

try:
    response = requests.get('http://google.com/blah')
    if response.status_code != 200:
        print 'webpage down (' + response.reason + ')'
except requests.ConnectionError:
    print 'webserver is offline'


I can add an adjustment for the packet timeout and that would not be an issue to do. It really doesn't make any sense to do it tho. if you have more then 50 milliseconds latency on your home network then there is something really wrong and that needs to be looked into.

Up to you folks I can add whatever is wanted.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New Ping Plugin

Post by kgschlosser » Wed Apr 29, 2020 6:59 pm

Oh I also wanted to touch base on the keyword thing

Code: Select all


import requests

try:
    response = requests.get('http://google.com/blah')
    if response.status_code != 200:
        print 'webpage down (' + response.reason + ')'
    elif 'KEYWORD' not in response.content:
        print 'webpage has bad content'
except requests.ConnectionError:
    print 'webserver is offline'

If you like the work I have been doing then feel free to Image

User avatar
Sem;colon
Plugin Developer
Posts: 753
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: New Ping Plugin

Post by Sem;colon » Wed Apr 29, 2020 7:54 pm

kgschlosser wrote:
Wed Apr 29, 2020 6:57 pm
why would someone be pinging a server on the other side of the world from EG?
For the reasons I, and maybe Snowbird are using the ping plugin - to monitor the reachability of servers in a large (company) network and to perform actions when they are not reachable.

Sounds rather simple, but believe it or not, there are lots of "professional" tools out there doing not much more than that but cost a fortune!
If you like my work, Image me a drink :wink:

User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New Ping Plugin

Post by kgschlosser » Thu Apr 30, 2020 1:40 am

OK i can add the latency to it. I am gong to add it to the action to add a host and not to the plugin config this way you can set a different latency for each host.
If you like the work I have been doing then feel free to Image

Snowbird
Experienced User
Posts: 374
Joined: Fri Jul 03, 2009 10:04 am

Re: New Ping Plugin

Post by Snowbird » Thu Apr 30, 2020 7:00 am

For the reasons I, and maybe Snowbird are using the ping plugin - to monitor the reachability of servers in a large (company) network and to perform actions when they are not reachable.
exactly, I couldn't have said it better
Sounds rather simple, but believe it or not, there are lots of "professional" tools out there doing not much more than that but cost a fortune!
soooo true ! :)


Kevin, if the ping plugin is only intended for use at home in the local network, then for sure 50ms is more than enough, I'm not arguing at all about that, and I thank you again for this ! but if you want to give this plugin a much greater dimension, then the outside world must be taken into account, ping can do so much, it's the most basic tool to check if a server respond, but it doesn't mean that all services are working fine, it just gives a rough sign that the server has some kind of connectivity and that's all, hence my other questions regarding the services. There could be a tool that monitors servers more deeply than just a ping with some notifications when a problem occurs, etc. the sky's the limit LOL :)

User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New Ping Plugin

Post by kgschlosser » Thu Apr 30, 2020 8:48 am

I was keeping the single threaded nature of the plugin in mind when i set the maximum latency to 50ms. The reason for this is say you have 3 hosts added to the ping plugin. if you have the latency set to 500 milliseconds that it is going to stall the whole work for 500 milliseconds if the host is not available. This is going to slow down detection for the other hosts. Now this is the kick in the satchel, if you have 10 hosts added and 7 of them are not available. then 7 * 500ms = 3.5 seconds. This means that if a host is now available it can be up to 3.5 seconds before an event gets triggered.

The single threaded is also for a purpose. Because of using Windows COM objects to access WMI so we can get Windows to do the pinging for us without launching additional processes there ends up being a crap stick of issues with it. one of them being using a COM object in a thread that is different then the one that originally opened the damned thing. So here is a howdy do ya.. Most plugins that utilize COM objects have them created when the plugin starts.. So the thread that created it is the action thread. In most cases the com object is going to get accessed form that plugins actions... and guess what thread an action gets run in??.. The action thread. Now because I have a need to keep on polling a com object I am not able to do it from the action thread., I need to do it from it's own thread. Because....


Crap never mind that last paragraph. It just dawned on me what I need to do to get the blasted com object to initialize properly outside of the action thread. It still ends up being a coding mess if we wanted to use a separate thread for each of the hosts. creating the WMI COM object is expensive and not the most fantastic idea to have multiple threads creating and destroying these COM objects. It still ends up in a snafu if i create a single thread to handle the querying we end up with the exact same deal as before.

I really do hate Windows sometimes!!! The whole thing is I am not sure how many concurrent WMI COM's can be opened before Windows shits a brick. I guess we are going to have to find out. I will have to rewrite the plugin so a new thread will get created for each host that gets added. and that thread is going to have to initialize it's own WMI COM.

This is the part I do not like. I am going to have to wait for multiple threads to exit properly and if an abnormally large timeout is set or there are a bunch of hosts that are not connected we are going to have to stall the exit of EG until everything closes up nice and tidy. The maximum amount of time I can stall the close of EG is 5 seconds. and that is 5 seconds total for all plugins to close up not just this plugin.

ho hum.... I am going to have to mess about and see what will happen. I am not sure if there is something I can do to force the timeout to expire prematurely
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 5504
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: New Ping Plugin

Post by kgschlosser » Thu Apr 30, 2020 8:52 am

maybe what I will do is go down the line of threads. trip the flag to exit. and then go back over the threads and join the ones that are still active. At least this way while I am waiting for one to close the others can exit cleanly. when i get to a thread that has already exited I will skip it and move onto the next.
If you like the work I have been doing then feel free to Image

tias
Posts: 2
Joined: Sat May 30, 2020 8:21 pm
Location: Europe

Re: New Ping Plugin

Post by tias » Sat Jul 11, 2020 10:04 am

I installed but I get every 3 - 5 hours these errors.
How can this be fixed?
Attachments
EG Ping ERROR.png
EventGhost (curr.: 0.5.0-rc4), Tasker (=Automation)

Post Reply