oxzi / gosh

Authenticationless HTTP file upload server
GNU General Public License v3.0
16 stars 2 forks source link

Alerting #39

Closed riotbib closed 11 months ago

riotbib commented 1 year ago

I'd be desired to have some kind of alerting mechanism for gosh.

I.e. for events such as a new upload, a premature deletion, expiry.

This could be done via a web-hook or allowing implementing a custom script.

Thanks a lot if possible!

riotbib commented 11 months ago

For what it's worth, I wrote this systemd service in Nix, that's alerting all events of gosh.service to IRC.

{
  systemd.user = {
    services.gosh-observer = {
      wantedBy = [ "multi-user.target" ];
      path = [
        pkgs.coreutils
        pkgs.systemd
        ircsink
      ];
      serviceConfig = {
        Restart = "always";
        ExecStart = pkgs.writers.writeBash "gosh-observer" ''
          ${pkgs.systemd}/bin/journalctl -fqn0 -u gosh | \
          while read line
          do
            message=$(echo $line | ${pkgs.coreutils}/bin/cut -f6- -d ' ')
            echo $message | ${ircsink}/bin/ircsink \
              --nick "gosh" \
              --server "redacted" \
              --port 6667 \
              --target "#gosh" \
              --command notice
          done
        '';
      };
    };
  };
}

It uses ircsink.

This would be fine enough for me, even though I am curious what you think.

oxzi commented 11 months ago

Thanks for following up on this issue. I like your approach as it uses already available data from the logs.

Due to the privseped architecture of gosh, it wouldn't be so easy to have a generic callback without losing all the privsep benefits. I thought about some kind of channel - maybe an Unix domain socket or a FIFO -, but all this would just be reading the logs, just with extra steps.

Thus, I would support your suggestion as it already works on all supported operating systems, either through journald or by tail -fing the log files.

If you are happy with your solution - and I think you can definitely be -, feel free to close the issue.