Consider dtrace to monitor commands being executed to refresh service status #5

Open
opened 2024-05-23 13:06:45 +02:00 by hiway · 0 comments
Owner

Using dtrace to monitor commands being run on the host will allow Freedive to refresh services that are started or stopped directly from CLI. The other option is to poll each service at some interval, but that approach is slow to catch up or adds load to the host without providing justifiable benefit.

A similar approach is implemented by monitoring /etc/rc.conf, /etc/rc.d/ ad /usr/local/etc/rc.d/ for any changes to files that trigger service status refresh.

def handle_info(
{:file_event, watcher_pid, {path, _events}},
%{watcher_pid: watcher_pid} = state
) do
name = Path.basename(path)
Logger.debug("Service.Server: handle_info file_event name: #{name}")

This will add a dependency ( https://hex.pm/packages/erlexec ) to monitor the dtrace command's output as a stream.

The feature can be implemented to internally broadcast the commands being run, which other features like services can subscribe to and react to relevant commands. Optionally log the commands to a separate log file such as /var/log/freedive/commands

Using dtrace to monitor commands being run on the host will allow Freedive to refresh services that are started or stopped directly from CLI. The other option is to poll each service at some interval, but that approach is slow to catch up or adds load to the host without providing justifiable benefit. A similar approach is implemented by monitoring `/etc/rc.conf`, `/etc/rc.d/` ad `/usr/local/etc/rc.d/` for any changes to files that trigger service status refresh. https://brew.bsd.cafe/hiway/freedive/src/commit/d2e31dbbbd220fcaef4f1ef027bf6ca151f12d99/lib/freedive/api/service/server.ex#L114-L119 This will add a dependency ( https://hex.pm/packages/erlexec ) to monitor the dtrace command's output as a stream. The feature can be implemented to internally broadcast the commands being run, which other features like services can subscribe to and react to relevant commands. Optionally log the commands to a separate log file such as `/var/log/freedive/commands`
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: hiway/freedive#5
No description provided.