| Module | Tests Status | Coverage |
|---|---|---|
| Agents | ||
| Monitoring |
PyDataCenter: Smart Monitoring and Remote Ops
Core Idea: Develop a system that simulates a mini data center using VirtualBox. Each virtual machine acts as a "server" with specific roles (e.g., SMTP server, DNS server, NTP server, Web server, etc.). Students will create Python-based agents that:
- Connect via SSH
- Monitor logs
- Manage processes
- Send error alerts
- Perform basic network queries
Technical Objectives:
| Technology | Task Description |
|---|---|
| Python 2.6 / 3.8 | Support both versions (agent in 2.6, client in 3.8) |
| Networking (Sockets) | TCP/UDP connections between agents, network data collection |
| SMTP | Send email alerts when errors are detected |
| Aqarium | Visualize server status (via web interface or logical console dashboard) |
| Sockets | Implement a custom protocol between agents and the central monitor |
| Unix / FreeBSD | Set up VMs with different operating systems |
| Multiprocessing / Multithreading | Parallel data collection from multiple servers |
| VirtualBox | Deploy infrastructure with 3β4 virtual machines |
| Logging / Log Files | Collect and analyze system/webserver logs in real time |
| Core Python | Create a CLI tool for system management |
| NTP / DNS / HTTP/HTTPS / SSH | Interact with relevant services: pinging, requests, connections, attack simulation |
Bonus Features:
- Automatic agent deployment via SSH
- Easy integration with Telegram or Discord for alerts
- Interactive admin console
Project Structure:
agent/β Python agent for server-side monitoringcontroller/β Central monitoring station (GUI or CLI)docs/β Installation and configuration documentationvagrant/β Scripts for setting up the infrastructure
If your
READMEhas a lot of info, section headers might be nice.
- All the
coderequired to get started - Images of what it should look like
- Python 3.8
- PostgreSQL 14
- Install PostgreSQL 14 from the official website
- Open terminal/command prompt and connect to PostgreSQL:
# Connect as postgres user
psql -U postgres
# Create database
CREATE DATABASE your_db_name;
# Create user (replace with your desired username and password)
CREATE USER your_db_user WITH PASSWORD 'your_db_password';
# Grant privileges
GRANT ALL PRIVILEGES ON DATABASE your_db_name TO your_db_user;
# Connect to the new database
\c your_db_name
# Grant schema privileges
GRANT ALL ON SCHEMA public TO your_db_user;- Install pgAdmin 4
- Open pgAdmin 4
- Right-click on "Servers" β "Create" β "Server"
- In the "General" tab:
- Name: Give your server a name
- In the "Connection" tab:
- Host: localhost
- Port: 5432
- Username: postgres
- Password: (your postgres user password)
- Click "Save"
- Right-click on "Databases" β "Create" β "Database"
- Enter database name and owner
- Click "Save"
After setting up the database, update your .env file with the correct credentials:
DB_NAME=your_db_name
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=localhost
DB_PORT=5432Global variables backend and sample filling Django
DEBUG=True or False #Django backend debug mode
DJANGO_ALLOWED_HOSTS= #e.g. localhost,127.0.0.1
API_PREFIX= # e.g. api/v1
# db details
SECRET_KEY= key ... # Use rules for hashed data
PG_DB= Database name
PG_USER= Database user
PG_PASSWORD= Database user password
DB_HOST=sample filling => localhost or '127.0.0.1' # Database host
DB_PORT=sample filling => 5432 # Database port
# Used by Docker
PGADMIN_DEFAULT_PASSWORD= key ... #Use rules for hashed data. Used by Docker
PGADMIN_DEFAULT_EMAIL= "user login" sample filling admin@admin.com . Used by Docker
POSTGRES_DB= database name
ENGINE= #docker-compose.dev.ymlGlobal variables frontend and sample filling
REACT_APP_BASE_API_URL= sample filling => http://localhost:8000 #Path to the backend API server
REACT_APP_PUBLIC_URL= sample filling => http://localhost:8080 #Path to the frontend visualization- Clone this repo to your local machine using
____
- If you want more syntax highlighting, format your code like this:
- Localhost
create virtual environment
py -3.8 -m venv venv38or whatever uses python3.8 version installed
update and install this package first
$ pip install -r requirements.txtnow install npm and bower packages
$ sudo apt update
$ sudo apt install nodejs
$ sudo apt install npm
- Setup .env
Setup .env
#db details
SECRET_KEY= 'key ...'
PG_DB= sample filling => forum
PG_USER= sample filling => postgres
PG_PASSWORD= sample filling => postgres
DB_HOST= sample filling => localhost
DB_PORT= sample filling => 5432
PGADMIN_DEFAULT_PASSWORD= 'key ...'
PGADMIN_DEFAULT_EMAIL= sample filling => admin@admin.com
DEBUG=True or False
ENGINE= # docker-compose.dev.yml
POSTGRES_DB= sample filling => forum # docker-compose
ALLOWED_ENV_HOST=sample filling => "http://localhost:8080" # docker-compose and settings.py
REDIS_URL= sample filling => redis://localhost:6379/0 #local- User, run the local server on port localhost:8000
$ python manage.py makemigrations
$ python manage.py migrate
$ python manage.py runserverCorrect application operation (in terms of moderation autoapprove functionality, to be precise) requires a running Celery worker and a Redis server. The simplest way to start Redis is:
docker run --rm -p 6379:6379 redis:7
Docker will automatically download the image and run the Redis server with the ports exposed. Redis will be available at 127.0.0.1:6379. You should place this host and port in the environment variable REDIS_URL, which Celery uses through Django's settings.py.
Don't forget to install Celery via pip.
pip install -r requirements.txt
Add in BackEnd .env
REDIS_URL= redis://localhost:6379/0The Celery worker itself needs to be started in a separate terminal (in the directory where manage.py is located) with the command:
celery -A forum worker --loglevel=info
On some Windows machines, there might be issues, in that case try:
celery -A forum worker --loglevel=info -P eventlet
- Setup frontend .env
Setup frontend .env
REACT_APP_BASE_API_URL= sample filling => http://localhost:8000 # Path to the backend API server
REACT_APP_PUBLIC_URL= sample filling => http://localhost:8080 # Path to the frontend visualization- User, run the local server on port localhost:8080
PORT=8080 npm start
or
PORT=8080 npm restart- Setup Docker
Setup .env
Run Docker comands
$ docker compose build
$ docker compose up
$ docker exec -i contener-name-exemple python manage.py makemigrations
$ docker exec -i contener-name-exemple python manage.py migrateStop Docker comands
ctrl + c
$ docker stop $(docker ps -q)- User, run test:
$ python manage.py test --settings=forum.test_setting- Running tests from Docker container:
$ docker compose -f docker-compose.dev.yml exec api-dev python manage.py test --settings=forum.test_setting
- Check Test Coverage and make report (from Backend directory):
$ coverage run manage.py test --settings=forum.test_setting
$ coverage report- Check Test Coverage and make report from Docker container:
$ docker compose -f docker-compose.dev.yml exec api-dev coverage run manage.py test --settings=forum.test_setting
$ docker compose -f docker-compose.dev.yml exec api-dev coverage report- π Documentation PyDataCenter5000/wiki.
Or Contributors/People
- You can just grab their GitHub profile image URL
- You should probably resize their picture using
?s=200at the end of the image URL.
Reach out to me at one of the following places!
- MIT license
- Copyright 2020 Β© SoftServe IT Academy.
