The ServerUptime project consists of three main files: beacon.py
, watch_tower.py
, and database_adapter.py
. The run.py
file provides two functions: beacon
and watch_tower
, which are used to run the project based on the environment. The project is designed to monitor server uptimes using RabbitMQ and store the data in a PostgreSQL database.
- Python 3.7+
- RabbitMQ server
- PostgreSQL database
-
Clone this repository to your local machine:
git clone <repository_url> cd <repository_directory>
-
Install the required dependencies:
pip install -r requirements.txt
Before running the project, make sure to configure the settings in the server_uptime/config/settings_file.py
file. Update the RabbitMQ and PostgreSQL connection settings according to your environment.
-
Setup Postgres in your Watch Tower Server
- Use steps provided in the Packages and Installers from Postgres
- Setup the Database or use the default postgres db
CREATE DATABASE <name>
- Setup a user and password to use when accessing the DB or use postgres if you prefer the default db
-
Setup RabbitMQ server
-
Use steps installation guides from RabbitMQ
-
rabbitmqctl add_vhost <vhost_name>
-
rabbitmqctl add_user <username> <password> rabbitmqctl set_permissions -p <vhost> <username> ".*" ".*" ".*"
-
- Install the package in the server(s) you want to monitor
pip install ServerUptime
- Run the program from the servers to be monitored first to start sending uptime pings
start_beacon -q <queue_name> -s <server_name>
<queue_name>
: The name of the RabbitMQ queue to which the ping messages will be sent.<server_name>
: The name of the server being monitored (optional). If not provided, thequeue_name
will be used as the server name.
The beacon
function will continuously send ping messages to the specified RabbitMQ queue every 1 second.
- Install the package
pip install ServerUptime
- Run the program from the monitoring server to start consuming the messages
start_watch_tower -q <queue_name>
<queue_name>
: The name of the RabbitMQ queue to which the ping messages will be sent.
The watch_tower
function will start listening for messages from the specified RabbitMQ queue and update the server uptime in the PostgreSQL database accordingly.
- It is preferred to set up and run the
beacon
functions first before starting thewatch_tower
. This ensures that the server uptimes are being sent to the RabbitMQ queue before the WatchTower consumes and updates them.
This project is licensed under the MIT License.