NetworkHealth : Unable to detect some devices?

I use the NetworkHealth binding to monitor up time of various Servers, PCs and Devices… It works great… Except I have a couple of desktop PCs that always appear offline…

I can ping these devices via IP and get a response. I have double checked their IP address is correct in the item files but still no luck.

Anyone got any other suggestions I should check?

I haven’t seen this issue myself (yet), but apparently there are issues with Java’s InetAddress.isReachable method, described in the following link:

Apparently, if the user running the Java process (openhab, in this case) doesn’t have the required permissions, Java will failover to connecting to the echo service on the remote machine using TCP. If there is no echo service running on the remote computer, then the pseudo-ping fails.

If there are any TCP ports listening for connections on the “offline” PCs (http, ssh, ftp, telnet, etc.), you could try using that port number in the network health binding.

So i’m just looking at this trying to get it working properly again…

OpenHAB is running on a Windows 7 machine and from that machine I can happily ping all devices on my network from the command line and they all reply.

But there are 2 computers that the Network Health binding just will not see as online… ever…

If I can ping them from the windows command line and OpenHAB is running as the same user, is there anything else I can be looking at to try get this working fully?

  1. Check if TCP port 7 is open on those two machines in case Java is failing to do ICMP and is using the echo service.

  2. Use Wireshark to record and analyze the packet traffic between the openHAB server and those two hosts.

First off networking is NOT my forte so I apologize if I misstate something.

I’m having this problem as well. I can ping the devices, etc. I’ve narrowed it down to the firewall. If I completely disable the firewall everything works fine. Re-enable computer disappears.

Enabled I can see what I believe is the ‘conversation’ between the Windows computer and openHAB (openHAB is on a pi).

Disabled I can see the information coming from the pi but the computer never responds.

Here are a few of the things I’ve tried (far to many things to remember them all but these were the memorable steps)

  • I tried creating a firewall rule that would allow port 7 but either I set it up incorrectly or it doesn’t work.
  • In fact I can go into the Firewall Properties and enable all inbound connections and it doesn’t work yet turning the firewall state off does.
  • I updated my rule to allow any port. Still doesn’t work.

Here is a screenshot of various things. Any assistance is appreciated.

If you google “icmp ping port,” it returns: “If you are running network management software that uses ICMP Destination Unreachable messages, you need to enable the Allow outbound destination unreachable setting. If you configure Windows Firewall so that traffic is allowed through TCP port 445, Windows Firewall will allow incoming ICMP Echo messages automatically.” (Mar 28, 2005)

Perhaps that ancient bit of advice will make a difference?

Hi watou,

A bit! It got me down the right rabbit hole. I found a wiki page for a different piece of software with steps to fix it for their software which seems to have worked for me. (Note: This does involve some registry editing, please be very careful)

Call this complete for me, maybe it’ll work for the OP.

I was experiencing a close issue as you; some devices detected or not.
Nevertheless when I was launching openhab 1.8.0 with the start.sh, instead off automaticaly at start, all my devices were detected normaly.
By searching on the net I found your post and the suggestion of steve1 regarding user running the process put me on the way. It was due to the openhab user used by the startup script.
I changed the /etc/default/openhab by putting root:root instead of openhab:openhab, done a chown on the openhab installation folders and all went as with the start.sh script.
Please note that at contrary to the statement in /etc/default/openhab if there is no user:group specified the script use openhab:openhab and not root:root

Thanks for the help steve1

Hi all,

how i have to define the item when no port spezified but the timeout must be set?

if is use: nh=“My-Device::50000” i get an error in the log but
when i use: nh=“My-Device:50000” the binding try to ping port 50000 ??

What is the right syntax here?

Thank you!

It’s usually not a good idea to run applications as root, so instead of starting openhab as root you can also grant java the permission to use raw and packet sockets. Install setcap (sudo apt-get install libcap2-bin) and figure out where the java binary is located on the filesystem:
pi@rpi-openhab ~ $ which java
/usr/bin/java
pi@rpi-openhab ~ $ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 jan 31 2015 /usr/bin/java -> /etc/alternatives/java
pi@rpi-openhab ~ $ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 51 jan 31 2015 /etc/alternatives/java -> /usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/bin/java

then execute:
sudo setcap cap_net_raw=ep /usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/bin/java
and restart openhab
Now openhab (java) can do ICMP.

9 Likes

Thank you Dirk, this is exactly what helped me. Now all my PCs are detected :slight_smile:
I still struggle with Windows Phone though (Lumia 735). I can ping it only when the phone is awake.
Did you have any issues with that?

Thanks again!
Kuba

Hey @kubawolanin not sure if you got this figured out or not, it’s been a while. But I use something like this for my iPhone, might also work with your Windows phone: Working Iphone wifi presence locator

Best of luck!

Hello, I have solution for Ping in openhab 1.8.3 at windows 7
Its very easy to use.

in the item i use this for example:
Switch Network_Moni “Moni” (Status, Network)
{exec="<[pingtest.cmd 192.168.0.182:30000:MAP(ping.map)]" }

the map file:
ein=ON
aus=OFF

and as pingtest.cmd file:
@echo off
ping -w 2000 -n 2 %1 | find “TTL=” >nul && echo ein|| echo aus

so it do ping every 30 seconds and if it ok then it sends the word ein to openhab if not the word aus.
With the MAP i do translate in ON OFF for switch item.

I use this for Presence and Ping the Smartphones

Good Luck

1 Like