mftp-doctor.py periodically monitors the latest runtime logs of mftp.py. Analyses the logs and looks for errors. On encountering any errors it sends a notification to configured e-mail and ntfy topic, both done utilising ntfy.
Table of Contents
To set up a local instance of the application using docker, follow the steps below.
The following requirements are to be satisfied for the project to function properly:
-
Get the docker image
You can get the docker image from either docker-hub or by buiilding it locally:
- Pull from docker-hub
sudo docker pull metakgporg/mftp-doctor
- Build from Dockerfile
- Clone the repository and cd into it
git clone https://github.com/metakgp/mftp cd mftp/mftp-doctor
- Build the image
sudo docker build -t metakgporg/mftp-doctor .
- Clone the repository and cd into it
- Pull from docker-hub
-
Create a directory which will contain your env.py, name it as
doctor_config
-
Follow the steps to configure env variables
It is mandatory to provide the following env variable
before the docker-compose command.
DOCTOR_CONFIG
: Absolute path todoctor_config
directory
sudo DOCTOR_CONFIG=/path/to/doctor_config docker-compose up -d
This container requires access to hosts' docker.sock
to check logs of mftp
container running on host and the env.py file:
sudo docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /path/to/doctor_config/env.py:/mftp-doctor/env.py \
--name mftp-doctor \
metakgporg/mftp-doctor
It is also possible to run these docker containers as a cronjob:
-
- Provide
--cron
as theDOCTOR_MODE
env variable. For example:sudo DOCTOR_CONFIG=/path/to/doctor_config DOCTOR_MODE=--cron docker-compose up -d
- Provide
-
- Append
--cron
at the end of this commands, as follows:sudo docker run -d \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /path/to/doctor_config/env.py:/mftp-doctor/env.py \ --name mftp-doctor \ metakgporg/mftp-doctor --cron
- Append
- Add the updated command with desired cron expression into your cronjob using crontab -e
To set up a local instance of the application without using docker, follow the steps below.
The following requirements are to be satisfied for the project to function properly:
- python3
>=python3.10
sudo apt update sudo apt install python3
Now that the environment has been set up and configured to properly compile and run the project, the next step is to download and configure the project locally on your system.
-
Clone the repository
git clone https://github.com/metakgp/mftp cd mftp/mftp-doctor
-
Install required dependencies
pip3 install -r requirements.txt
-
- Copy
env.example.py
asenv.py
. It looks like this:TOPIC_URL = "https://ntfy.sh/metakgp-mftp" # NTFY topic to send doctors' notifications on EMAIL = "abc@xyz.com" # Email to send doctors' notifications on
You can read about you can learn about ntfy from their docs: https://docs.ntfy.sh/
- Update the values inside the
double quotes
("). DO NOT CHANGE VAR NAMES.
- Copy
It is straight forward to use this script, just run it using supported version of python interpreter:
python3 mftp-doctor.py
It is also possible to bypass the continuous loop - which executes the code after every 2 minutes - using the --cron
argument:
python3 mftp-doctor.py --cron