This wasn't designed to do that but I think others have set it up for that purpose. Check back in this thread to see how they may have done it.
ok- will do.
@markbellkosel84- Thanks for your input. How do you have the "Time between pings" and "False alarm safety net" setup?
Just double-checking -- while it's called a "pinger", it actually makes an HTTP request to the URL given, right? Hence the "web" in the name I presume .
Has anybody managed to do an actual real ping (ICMP ping) from an HE? I'm sure there are Java libraries that can but don't know if there's any way to use them in Hubitat. The systems I need to monitor don't expose any web functions, but they do respond to pings. I can tell with a dozen or so well-chosen targets if it's my router, or something in my ISP, or bits of the Internet backbone that are down, and I was hoping to funnel that information into HE.
Oh my; this might work, depending on what the underlying environment in HE is:
def proc = 'ping -c 3 localhost'.execute()
proc.waitFor()
println "Ping ${proc.exitValue() == 0 ? 'OK' : 'NOT OK'}"
According to the [Wiki] Hidden Features thread this endpoint should give you the functionality:
I can't connect to anything there, either using the IP or that pseudo-dns name. Is the ":ip" supposed to be that, or should it be the actual ip address to ping instead of the letters "i" and "p"?
(I get redirected to a login page which always fails.)
Should be the actual IP address. For 192.168.1.47 (http://hubitat.local/hub/networkTest/ping/192,168,1,47) it returns:
PING 192.168.1.47 (192.168.1.47) 1250(1278) bytes of data. 1258 bytes from 192.168.1.47: icmp_seq=1 ttl=64 time=265 ms 1258 bytes from 192.168.1.47: icmp_seq=2 ttl=64 time=6.34 ms 1258 bytes from 192.168.1.47: icmp_seq=3 ttl=64 time=6.63 ms 1258 bytes from 192.168.1.47: icmp_seq=4 ttl=64 time=3.45 ms 1258 bytes from 192.168.1.47: icmp_seq=5 ttl=64 time=4.51 ms --- 192.168.1.47 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4009ms rtt min/avg/max/mdev = 3.454/57.181/264.987/103.909 ms
Do you know of a way to get this into a true false rule?
You’d have to parse the response to validate, so a little work to create a true/false but doable.
I would target the % packet loss, and make your call based on it. So locate the % in the string, back up 2 positions if that character isn’t a space then you can either evaluate further or say false (i.e. if you have 33% packet loss is it a good test or a bad test).
Funny you should ask!
The obvious regexp is (to turn the switch off if the ping worked; so the off regexp) would be just "0% packet loss".
I think maybe this is not usable with hub security on. Does anybody actually run with hub security off? Esepcially anybody with say locks controlled by the hub?
And also maybe incompatible with https-always? If I access the url via http I get redirected to the login page (and then returned there each time I click login), if I access it via https I just get a single line of text returned saying "error".
Yeah, the question of where to draw the line is (as it often is in real-world testing!) the interesting one.
For local ping I think I would argue that any packet loss was an error; it just shouldn't be happening. Then I'd monitor for a few months and see if the real world agreed with me.
If security is enabled you’ll need to log into the hub before the call. Ran into the same issue with a driver I wrote, and we borrowed the code from dman2306’s Rebooter app.
I already am logged into the hub in my browser; but when I access that URL I get redirected away anyway?
Do see how to go through login and get the cookie, anyway, but Firefox or Chrome should be handling that automatically once I'm logged in and it's not happening. Grrrr.
Nope, even with hub security and https-everywhere turned off I just get errors? (one line appears in the browser window, the word "error")
@dd-b Threw this together real quick, but might work for you:
https://raw.githubusercontent.com/thebearmay/hubitat/main/hubPing.groovy
cant open
I fat fingered the link, try it now.
Ok, it works and it pings internal device. Now how do I use this in RM to cause a device to turn off.
And thanks for your assistance