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

Daily report data does not survive a script restart #135

Closed Gregwolf3030 closed 3 years ago

Gregwolf3030 commented 3 years ago

If for some reason, like a bug or some other reason that you need to restart the script, the totals it was keeping track of for the day gets reset. So when the daily report gets sent, it is not accurate. I am not sure if this is a bug report or a feature request. But it sure would be more useful if the data being tracked for the day would survive a restart and continue to be updated when it comes back online. Maybe even include the number of times the service was started that day. If you think about it, if the service was writing to a file to track this information, it could also write a heartbeat that would include the date/time. With that information, it could even produce a statistic telling the user how much time during that day Swar was not monitoring their system. If the time between the new heartbeat and the last heartbeat was longer than expected, it could be calculated as a gap in monitoring and added to the offline total.

Thank you. Keep up the great work.

pieterhelsen commented 3 years ago

This is potentially related to #106.

Basically, Chiadog keeps its state in memory. A simple workaround would be to use a simple datastore like SQLite

However, conceptually, it would be good to keep stat aggregation/accumulation out of the scope of Chiadog altogether and move this into a separate project (I stand by the name I coined earlier, Chialog 😄).

This separate project could provide a more generic approach to log statistics by analyzing all log files without needing to keep state. This would address feature requests such as:

Chiadog could then remove the daily_stats logic and trigger Chialog as a pluggable component.

The hardest part will be getting this performant (running this on a raspberry pi will be tough) and handling rotated files (you won't be able to go 5 days into the past on a full node, since the logs will be gone)