openwrt / openwrt/packages

watchcat: add support for TCP port checking

Open
#20,102 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Makefile
Stars
4.6k
Forks
4k
Avg merge
3d 12h
Merged PRs (30d)
134

Description

Maintainer: @mips171 (original Roger D <rogerdammit [at] gmail.com>)

Description:

This is an idea to incorporate in the watchcat package the support to check for open TCP ports. The reasons are:

  • This package is very small (few text/script files), so it doesn't depends on third party large binaries/libraries.
  • The tool has support to execute user scripts. Therefore it could be useful to execute some actions (restart a service for example) if some TCP port is not active (aka not opened).

Based on this I have the objective of use the netcat applet from the busybox tool (nc -z <addr>:<port>) for checking if a TCP port is open. To implement this we only need to add a new "ping" mode and add the port value, and add some code in the script.

My proposal for the configuration:

config watchcat
        option mode 'run_script'
        option script '/etc/watchcat.user.sh'
        option period '6h'
        option pinghosts '127.0.0.1'
        option pingperiod '30s'
        option pingsize 'tcpport'  # new value
        option pingport '80'       # new option

And then regarding the script code it will be necessary only to execute the command nc -z ${pinghosts}:${pingport} instead of the the ping if the "pingsize" option is "tcpport".

You agree with this idea?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the watchcat package and its script code, then read the proposed configuration options and the existing ping behavior. Check how the BusyBox nc command is invoked and how ping failures trigger user scripts. Done means supporting the tcpport value and pingport option while preserving existing modes and checking the documented TCP endpoint.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
embedded-iot, networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.