bmx-routing / bmx7

BMX7 / SEMTOR Securely Entrusted Mesh Routing Protocol
GNU General Public License v2.0
63 stars 15 forks source link

implement "leasetrigger" like function for originators #9

Closed aparcar closed 6 years ago

aparcar commented 6 years ago

odhcpd runs a trigger when new leases are created. If possible I'd like to use such a feature in bmx7 on new originators.

Context is that I'm developing a monitoring setup based on bmx7 and I'd like to trigger the monitoring instance to automatically reload on new originators.

I'd like the use of the following functions:

both could run a user defined shell script supplying the parameters above. The scripts should be non blocking.

axn commented 6 years ago

You can use some inotify library to for being triggered by respective events. From bash for example this may look like (apt-get install inotify-tools): inotifywait -e modify -r --timefmt "%s%u" --format "%T %w%f %e " /var/run/bmx7/json/originators/ which terminates as soon as any file got changed. By default originator files are updated every --jsonUpdateInterval=60000 ms to periodically update the current metric. If you want them to change (and be triggered only) when route changes set --jsonUpdateInterval to its maximum. Setting it to '0' will only notify if the description changed. But in that case you could also watch /var/run/bmx7/json/descriptions. There are respective libraries for most programming language. Please close issue if such approach satisfies your demand.

aparcar commented 6 years ago

@axn I'd rather create a plugin that handles it instead of installing inotifywait on the devices, don't you think?

axn commented 6 years ago

not sure. The mentioned bash programs should be pretty small. Probably at the same size as another bmx7 plugin. Also depends which language you want to use which may come with appropriate binaries already. Calling executables from bmx7 would likely require threading or bmx7 gets blocked while executing the extenal code and then hope that the call eventually returns. In short I am a bit reluctant if other way is also possible.

aparcar commented 6 years ago

Okay let's close this

aparcar commented 6 years ago

I could not find an alternative to inotify for OpenWrt. Another possibility would be to run every n seconds a script to check changes, but that feels somewhat like a hack. Do you see any other options @axn?

axn commented 6 years ago

What about the inotifywait solution you used here: https://github.com/openwrt/packages/pull/5923/files#diff-84e3cba3ad0824677d2bf371741fded1R17 ?

aparcar commented 6 years ago

Should be fixed