br101 / pingcheck

Check connectivity of interfaces in OpenWRT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use command line argument parsing instead of / in addition to UCI

jonesmz opened this issue · comments

Instead of using a UCI driven configuration for pingcheck, I would rather be able to provide it a series of commandline arguments to describe the behavior that I want from it.

This doesn't need to mean the UCI parsing is removed, they can both live side by side.

As pingcheck will always be running on OpenWRT (it uses ubus), there will always be UCI, so I don't see a real usecase for that. Let me know it there is a real reason besides personal preference...

Here's some personal preference reasons:

  1. Good engineering practice, it increases the test-ability of the tool by providing for an additional interface that can be used to drive the tools behavior.
  2. OpenWRT may not use uBus or UCI in the future.
  3. The UCI api is a pile of hot garbage, though it does technically work (most of the time). Honestly it'd be less of a concern to me if pingcheck talked to UCI over ubus via rpcd. But rpcd crashes a lot, so that might not be a good choice either.

Here's my real reason:

I have a program that runs on my device and actively monitors various conditions. I don't always want pingcheck running continuously, and instead bring it up and down based on changing environmental conditions. Sometimes it stays online for more than 10 minutes, sometimes less than a minute. It all depends on what the end-user does with the thing.

So ideally I would be able to do the following:

  1. Be able to run pingcheck with the list of interfaces I want to talk to without first writing to UCI. Among other things, this reduces the wear and tear on flash.
  2. Be able to tell pingcheck to, e.g. ping all the interfaces in question some specific number of times.
  3. Be able to ask Pingcheck for machine readable output.

E.g. json. Both with live output mode, and also with single summary output mode. E.g. something like: pingcheck --itf=wan --itf=wwan --tcp --port=80 --host=google.com --interval=1 --count=2 --json-output --summary-only, and then get output like:
{ "global" : "ONLINE", "wan" : "OFFLINE", "wwan" : "ONLINE" }

Hey, your real reason is valid, but I personally don't have the time/motivation to do the changes. Patches are welcome, though