-
Notifications
You must be signed in to change notification settings - Fork 121
Monitoring 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.
chiadog
is compatible with all major operating systems and the basic steps for setting up remote harvesting from your local machine are the same on each platform (the implementation is a little more involved on Windows):
- Set up an SSH key pair on the local machine
- Copy the public SSH key to all remote harvesters
- Test the SSH connection and add the fingerprint
- On the local machine, prepare a config file for each harvester
- Start separate
chiadog
instances for each harvester
Before you get started with remote monitoring, you will have to set up an SSH key pair on your local machine (the one that will run Chiadog).
This step only takes a minute, follow Github's guide
on Generating a new SSH key
. It provides detailed information for Linux, Windows and MacOS. If you specify a 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 agent should remember and manage your password because chiadog
doesn't know it.
Before Chiadog
can connect to your remote harvesters, you will need to copy your local machine's public SSH key to each remote harvester. There are three possible scenarios:
- Both your local and remote machines run Linux or MacOS
- Your local machine is Windows-based
- Your remote harvester is Windows-based
If both your local and remote machines run on Linux or MacOS you can use ssh-copy-id as described below. If you're running a remote harvester on Windows, make sure to follow the steps detailed in Remote Windows Harvester first before continuing with the steps below.
ssh-copy-id <user>@<ip_address>
which will take your default SSH key, or specify it explicitly when you have multiple SSH key pairs:
ssh-copy-id -i "~/.ssh/id_ed25519" <user>@<ip_address>
The OpenSSH Client on Windows/PowerShell does not support ssh-copy-id
. Two methods are available to you:
- Manually copy/paste the public key into the
authorized_keys
file on the remote machine - Use the below PowerShell command to copy your public key to the remote machine (only works if the harvester is Linux or MacOS-based)
type $env:USERPROFILE\.ssh\id_rsa.pub | ssh <user>@<ip_address> "cat >> .ssh/authorized_keys"
Setting up remote monitoring for a Windows-based harvester is a little more involved and requires you to install OpenSSH Server. Follow these steps to enable OpenSSH Server on Windows 10:
- Open the Start Menu
- Open the 'Settings' app (type 'settings' or locate it at the bottom-left side of the Start Menu)
- Click on 'Apps' > 'Optional Features' > 'Add a feature'
- Select
OpenSSH Server
and click 'Install' (if it does not appear, look through the list of already Installed Features.)
Next, you need to start the service and ensure that it is started automatically when the system restarts.
- Open the Start Menu
- Open an elevated 'PowerShell' command prompt (right-click PowerShell and click 'Run as Administrator')
- Run
Start-Service sshd
to start the service - Run
Get-Service sshd
to verify that the service was started successfully - Run
Set-Service -Name sshd -StartupType 'Automatic'
to ensure the service starts at boot.
Finally, you'll need to set up an authorized_keys
file that allows access for your key.
- Open Explorer and navigate to
C:\Users\YOUR-USER\.ssh\
- Create a blank text file and paste in the client's Public SSH Key.
- Save the file as
authorized_keys
(note: make sure to remove the .txt extension)
IMPORTANT
If the user is in the local Administrators group, you will need to place the key in the following file instead:
C:\ProgramData\ssh\administrators_authorized_keys
.
You will also need to set the proper Access-Control List (ACL) permissions for the file. Open another elevated PowerShell and run the following script:
$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys
$acl.SetAccessRuleProtection($true, $false)
$administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule("Administrators","FullControl","Allow")
$systemRule = New-Object system.security.accesscontrol.filesystemaccessrule("SYSTEM","FullControl","Allow")
$acl.SetAccessRule($administratorsRule)
$acl.SetAccessRule($systemRule)
$acl | Set-Acl
Once you've set up both the local and the remote(s), try to SSH into the remote machine with the key to make sure it works. You'll also be prompted to add the remote machine's fingerprint to your known_hosts
file which is a pre-requisite to establish a connection from chiadog
.
Run this command from your local machine where you will be running chiadog
:
ssh -i "~/.ssh/id_ed25519" <user>@<ip_address>
-
On your local machine, 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
- Make sure that
-
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
-
Adjust the
remote_user
andremote_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.
- You can also specify different
-
Adjust the
remote_file_path
for each machine.- On Linux-based machines, you can use the tilde (~) to expand to the user directory. E.g.
~/.chia/mainnet/log/debug.log
- On Windows machines, you need to specify the absolute path to the log file. E.g.
C:\Users\MY-USER\.chia\mainnet\log\debug.log
- On Linux-based machines, you can use the tilde (~) to expand to the user directory. E.g.
Start chiadog
for each harvester in a separate terminal.
- On Linux or MacOS, I recommend tmux as it allows you to split your terminal in multiple windows and have a cockpit-like overview.
- On Windows, there unfortunately isn't a worthy substitute and you are left running multiple command line prompts or PowerShell sessions.
. ./venv/bin/activate
python3 main.py --config config-harvester-1.yaml
. ./venv/bin/activate
python3 main.py --config config-harvester-2.yaml
. ./venv/bin/activate
python3 main.py --config config-harvester-3.yaml