Skip to content
/ chiadog Public
forked from martomi/chiadog

A watch dog providing a peace in mind that your Chia farm is running smoothly 24/7.

License

Notifications You must be signed in to change notification settings

7e4/chiadog

 
 

Repository files navigation

Photo by Zoltan Tukacs on Unsplash


Watchdog for your Chia farm

So you've become a Chia farmer and want to maximize the probability of getting a reward? Chiadog helps with automated monitoring and sends you a mobile notification in case something appears to malfunction.

Supported Notifications

Subsystem Notification (example values) Priority
Harvester Your harvester appears to be offline! No events for the past 400 seconds. HIGH
Harvester Disconnected HDD? The total plot count decreased from 100 to 40. HIGH
Harvester Experiencing networking issues? Harvester did not participate in any challenge for 120 seconds. It's now working again. NORMAL
Harvester Seeking plots took too long: 40 seconds! NORMAL
Full Node Experiencing networking issues? Skipped 42 signage points! NORMAL
Daily Stats Hello farmer! 👋 Here's what happened in the last 24 hours:

Proofs 🧾: 2 found
Search 🔍: 0.46s average, 15.31s max
Plots 🌱: 42, new: 2
Eligible plots 🥇: 0.08 average
Skipped SPs ⚠️: 7 (0.01%)
LOW

How it works?

It parses the debug.log generated by the chia process and runs various checks to determine the health of your farmer. Among others, it can detect if your node has lost sync and the farmer is no longer participating in challenges, or if one of your external HDDs disconnected and your harvester doesn't have access to the full amount of plots you have.

It only requires read-access to your debug.log file and internet connection to send out notifications. Refer to the advanced section on running chiadog in a sandboxed environment further below if you'd like to enforce that.

Supported Integrations for Notifications

You may use one (or more) of the following integrations to receive notifications from chiadog.

Integration Advantages Cost
Pushover High priority notifications that can override your phone's silent mode. $5 one time purchase after 30 day trial.
E-mail You probably already have an email. No additional apps. Free
Slack Quick & easy setup. Free
Discord Quick & easy setup. Free
Telegram Quick & easy setup. Free
Shell script (beta) Execute anything in your own script. Free

For detailed guide on how to test and configure, please refer to INTEGRATIONS.md.

Getting started

Pre-requisites

  • UNIX-based OS (Linux/Mac) - for Windows, try this.
  • Python 3.7+
  • Enabled INFO logs on your chia farmer

How to enable INFO logs on chia farmer?

First configure the log level to INFO. This ensures that all logs necessary for chiadog to operate are available under ~/.chia/mainnet/log/debug.log.

chia configure -log-level=INFO

Then restart your farmer to apply the changes:

chia start --restart farmer

Check that logs are coming in:

cat ~/.chia/mainnet/log/debug.log

Installation

For updating from previous version, see section below.

  1. Clone the repository
git clone https://github.com/martomi/chiadog.git
cd chiadog
  1. Create virtual env (Recommended)
python3 -m venv venv
. ./venv/bin/activate
  1. Update pip3 to latest version
python3 -m pip install --upgrade pip
  1. Install the dependencies:
pip3 install wheel && pip3 install -r requirements.txt
  1. Copy the example config file
cp config-example.yaml config.yaml
  1. Open up config.yaml in your editor and configure it to your preferences.

Updating to the latest release

Skip this if you followed the above section.

cd chiadog
. ./venv/bin/activate

git fetch
git checkout main
git pull

pip3 install -r requirements.txt

Important: Automated migration of config is not supported. Please check that your config.yaml has all new fields introduced in config-example.yaml and add anything missing. If correctly migrated, you shouldn't get any ERROR logs.

Monitoring a local harvester / farmer

  1. Open config.yaml and configure file_log_consumer:

    • You need to enable the file log consumer to read local chia log files
    • Double-check that the path to your chia logs is correct
  2. Start the watchdog

python3 main.py --config config.yaml
  1. Verify that your plots are detected. Within a few seconds you should see INFO log:
Detected new plots. Farming with 42 plots.

Note: You can also monitor multiple remote harvesters and run chiadog on a separate machine. Please refer to the advanced section of the README.

Troubleshooting

The best way to check that everything works on your system is to run the unit tests:

python3 -m unittest

All tests are expected to complete with an OK status. It's highly recommended to also run the notification specific tests described in the notification section above.

You can enable more verbose logging from config.yaml by changing INFO to DEBUG. You should see logs for every keep-alive event from the harvester.

Advanced Usage

Redundant monitoring for chiadog

There are failure-cases in which chiadog is helpless. For example, your computer completely freezes or shuts down. Perhaps your entire home network goes down. chiadog won't be able to send you a notification.

There's a way however: in the config under the section of keep_alive_monitor, you can enable pinging to a remote service that will act as a watchdog of chiadog. A second level of redundancy, if you wish!

You may chose your favourite service for that, I've tested it with HealthChecks.io. It's free to signup and create an endpoint that expects to receive pings every 10 minutes. If it does not, it will notify you. It has integrations with Pushover, Email, Slack, Discord and more.

Running chiadog in the background

nohup python3 -u main.py --config config.yaml > output.log &

To stop chiadog, you can find the Process ID (PID) via ps aux | grep main.py and then softly interrupt the process with kill -SIGINT <pid_here>.

Running chiadog in sandboxed environment

We're in the early stages of exploring the best way to provide easy to setup sandboxed environment where the chiadog process is completely isolated from potentially accessing your private keys. Contributions in that direction are very welcome. Meanwhile you can check out @ajacobson repository for chiadog-docker.

Alternatively, as suggested here you can run chiadog from a unix user with limited permissions.

Remote monitoring of multiple harvesters

You can run multiple instances of chiadog on a single machine and monitor all your harvesters remotely. The logs on remote machines are accessed through SSH, so you'll have to setup ssh-key based authentication with your harvesters.

Setting up SSH keys

This step only takes a minute, follow Github's guide on Generating a new SSH key . If you specify password for your key, you'll also need to follow the second step in the guide and add your SSH key to the ssh-agent. The ssh-agent should remember and manage your password because chiadog doesn't know it.

Copy SSH key to all machines running a harvester

On Linux you can use ssh-copy-id:

ssh-copy-id <user>@<ip_address>

which will take your default SSH key, or specify it explicitly:

ssh-copy-id -i "~/.ssh/id_ed25519" <user>@<ip_address>

Try to SSH with the key to make sure it works. You'll be also prompted to add the fingerprint which is required before proceeding.

ssh -i "~/.ssh/id_ed25519" <user>@<ip_address>

Prepare configs for each harvester

  1. Open config.yaml in your editor and enablenetwork_log_consumer.

    • Make sure that file_log_consumer is disabled (or delete that section)
    • Configure remote_user for your remote harvester machine
    • Configure remote_host for your remote harvester machine
    • Double check that remote_file_path exists on the remote machine
  2. Copy config.yaml into multiple configs for each remote harvester, e.g.:

  • cp config.yaml config-harvester-1.yaml
  • cp config.yaml config-harvester-2.yaml
  • cp config.yaml config-harvester-3.yaml
  1. Adjust the remote_user and remote_host for each machine.

    • You can also specify different notification_title_prefix so that you can more easily distinguish between notification from each of your harvesters.
  2. Start chiadog for each harvester in a separate terminal. I recommend tmux as it allows you to split your terminal in multiple windows and have a cockpit-like overview.

python3 main.py --config config-harvester-1.yaml
python3 main.py --config config-harvester-2.yaml
python3 main.py --config config-harvester-3.yaml

Contributing

Contributions are always welcome! Please refer to CONTRIBUTING documentation.

About

A watch dog providing a peace in mind that your Chia farm is running smoothly 24/7.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.9%
  • Shell 0.1%