martomi / chiadog

A watch dog providing a peace in mind that your Chia farm is running smoothly 24/7.
MIT License
457 stars 121 forks source link

Add custom frequency config option for daily stats report & add manual trigger #69

Closed centrd closed 3 years ago

centrd commented 3 years ago

Currently, chiadog can send a daily stats report, which is awesome. Request:

  1. Add a config field to set the frequency of this report, e.g. every 5 hours, every 1 hour, etc. This is especially helpful while troubleshooting issues with the farmer.

  2. Add the ability to trigger a stats notifications manually. Again, this is helpful for troubleshooting. It would be extra nice if this were possible to call via CLI, a script, or cron.

bstock84 commented 3 years ago

+1 to this request.

In addition, I'd love to be able to get a notification when a proof is found, especially since chia's debug.log only goes back 8 files, and it rotates every ~20MB (which is my case is every 40 minutes), which means I only end up with 4-5 hours of logs.

pieterhelsen commented 3 years ago

+1 to this request.

In addition, I'd love to be able to get a notification when a proof is found, especially since chia's debug.log only goes back 8 files, and it rotates every ~20MB (which is my case is every 40 minutes), which means I only end up with 4-5 hours of logs.

There is a pull request ready for this functionality. It was briefly disabled due to Chia removing the log line from the debug log. https://github.com/martomi/chiadog/pull/74

pieterhelsen commented 3 years ago

Currently, chiadog can send a daily stats report, which is awesome. Request:

  1. Add a config field to set the frequency of this report, e.g. every 5 hours, every 1 hour, etc. This is especially helpful while troubleshooting issues with the farmer.
  2. Add the ability to trigger a stats notifications manually. Again, this is helpful for troubleshooting. It would be extra nice if this were possible to call via CLI, a script, or cron.

Regarding 1) so basically you'd like to have a user-defined interval for daily stats? Config would look something like this then:

daily_stats:
  enable: true
  start_at: 21:15
  interval: 3600 # interval in seconds or preset: [hourly, daily, weekly]

Regarding 2) I've been thinking of a way to implement this. Since Chiadog keeps its state in memory, I can think of two possible ways:

I'm leaning towards the second implementation... If anyone can think of any other ways, please elaborate on them here.

greimela commented 3 years ago

Regarding 2: How about running main.py normally, wait for a small time (e.g. 30s) to aggregate some logs, and then send the stat report? This would be like your option 1, but without the shared database.

This mode could be triggered by an option --test-stats or so.

martomi commented 3 years ago

@greimela sounds a lot like what I also proposed here https://github.com/martomi/chiadog/pull/82#pullrequestreview-652641997 - maybe the ideas can be combined to some extend. But let's keep it very simple.

Simplest would be to have that option to send notification immediately and to also have interval_hours config that defaults to 24 but people can set it to e.g. 8 for morning, afternoon, evening notifications or to 1 for debugging stuff.

pdoteter commented 3 years ago

Regarding 1) so basically you'd like to have a user-defined interval for ~daily~ stats? Config would look something like this then:

daily_stats:
  enable: true
  start_at: 21:15
  interval: 3600 # interval in seconds or preset: [hourly, daily, weekly]

Maybe use a cron like schedule configuration?

For example (splunk) cron_schedule = /15 6-18

Every fifteen minutes between 6AM and 6PM

Don't know if there is easy support for that in Python

pieterhelsen commented 3 years ago

Cron will be an overcomplication for a lot of the people currently using the tool in my opinion, so I'd prefer to stay away from that.