Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waitfor/munin and waitfor/port-open use unportable netcat options #11

Open
plambert opened this issue Jun 11, 2018 · 2 comments
Open

waitfor/munin and waitfor/port-open use unportable netcat options #11

plambert opened this issue Jun 11, 2018 · 2 comments

Comments

@plambert
Copy link
Contributor

Many versions of netcat do not have the nc -G <integer> option. On many Linux OS's these will fail as a result.

One alternative is to use the -w option, and this won't have the same functionality so probably isn't a good choice.

Another alternative would be to use timeout from the GNU coreutils, if it is installed. This would help, and would also still leave a lot of POSIX operating systems unsupported.

It can be done by launching an interactive shell, as described here: https://unix.stackexchange.com/questions/10698/timing-out-in-a-shell-script/18711#18711

Perhaps the "right" thing to do is to look for nc in the path, verify it has the -G option, and use it. If it's not there or doesn't support -G, look for timeout and verify it's the GNU program (it's a commonly used name!) and use it if it is.

If that doesn't work, maybe we could try the interactive shell approach… and if that doesn't work, try to use perl or python, etc.

At the very least, though, we need an alternative to nc -G since it's common for nc to not support the -G option.

@jplassnibatt
Copy link

jplassnibatt commented Jun 22, 2018

Another solution could be to set nmap package as mandatory dependency for this plugin and use 'ncat' instead of 'nc'.
UPDATE:
This works on centos7 (Ncat: Version 7.50) and ubuntu18 (Ncat: Version 7.60), but not on ubuntu16 (Ncat: Version 7.01)

@ahonor
Copy link
Contributor

ahonor commented Aug 16, 2018

Here's a solution that uses bash's support for TCP.

    timeout 1 bash -c "</dev/tcp/$hostname/$port && exit 0 || exit 1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants