Open Smegheid opened 2 years ago
As far as I can tell, on debian-based systems we have a couple of options in the repositories:
inotify-tools
: command-line programs providing a simple interface to inotify.iwatch
: realtime filesystem monitoring program using inotify.The former provides inotifywait
, which waits for events on a given file (or files) and then exits. This is conducive to writing our own script that loops endlesly.
The latter adds iwatch
, which is similar but different. While it also watches for events on a given set of files, it differs in that it runs endlessly. Instead, it gets provided a callback script that is executed on each event. Implementing things this way would require a shim between the existing status script and the iwatch call to make sure the event makes sense.
Either approach is valid, and I don't think there would be much difference in their overall operation. Both seem lightweight in their installed footprintIs, and I really don't see major advantages to one approach over the other. 'll probably just pick the former; a quick look at it on the current system looks fairly simple:
cray@raspberrypi:~ $ inotifywait /tmp/water_heater/status
Setting up watches.
Watches established.
/tmp/water_heater/status MODIFY
cray@raspberrypi:~ $ echo $?
0
165d5017368141060156309b9889a6ef2b3da840 is a first stab at a script based on inotifywait
. Just started testing, but it's working so far.
Edit: still learning how to github. So long as I reference the ticket in the checkin comment, it looks like these sort of manual ticket updates are unnecessary.
For the control process to have as few dependencies as possible, it writes its status as a file in tmpfs. This is then turned into statserv values for graphing by the intermediate
water_heater_status
script.While concentrating on getting the control script up to scratch, this has been picked up by repeatedly calling the status script from a loop in the dumbest way possible:
We could live with this, but it feels wrong. Instead, the system should probably be set up to lean on
inotify
to trigger the status script.Not currently sure how to do this without a lot of work. I seem to remember something called
iwatch
that would give this capability for free?