2. Sprint 1 Tasks - ITA-Dnipro/PyDataCenter5000 GitHub Wiki
Issue 1: Initialize Django Project and Monitoring App
Description:
Create the Django project pydata_center
and the app monitoring
. Configure it to run with Python 3.8.
Tasks:
- Set up virtual environment
- Create project and app
- Add app to
INSTALLED_APPS
- Test default runserver
Issue 2: Create ServerStatus Model and Run Migrations
Description:
Define a model to store server monitoring data (hostname, IP, uptime, timestamp) in models.py
.
Tasks:
- Add
ServerStatus
model - Run migrations
- Register in Django Admin
- Add test record manually in Admin
Issue 3: Build Serializer and POST API Endpoint
Description: Expose an API endpoint to receive server data via POST. Use Django REST framework.
Tasks:
- Create
ServerStatusSerializer
- Implement view and route in
urls.py
- Test using Postman or curl
Issue 4: Create and Test Agent Script (Python 2.6) for System Info
Description: Develop a standalone Python 2.6 script that gathers basic server info: hostname, IP, and uptime.
Tasks:
- Use
os
,socket
,subprocess
- Print as formatted string
- Save locally to
agent_log.txt
Issue 5: Extend Agent with HTTP POST Functionality
Description: Modify the agent to send collected system data to the Django endpoint using HTTP (from Python 2.6).
Tasks:
- Use
urllib2
orhttplib
(Python 2.6) - Format data as JSON
- Log response and handle errors
Issue 6: Set Up One Virtual Machine in VirtualBox
Description: Install and configure a VM (FreeBSD or Linux). Enable SSH access and assign static IP.
Tasks:
- Install OS
- Enable OpenSSH
- Assign static IP address
- Test SSH from host
Issue 7: Deploy and Test Agent Inside the VM
Description: Run the agent on the configured VM, verify system info collection and HTTP request to Django.
Tasks:
- Move
agent.py
to VM - Run and check local logs
- Confirm POST request received on Django side
Issue 8: Create Basic Controller Logging in Django
Description: Ensure that each POST received by the controller is logged with time, hostname, and IP.
Tasks:
- Update view to print/save log message
- Format:
[timestamp] Received from hostname/IP
- Use
logging
orprint
with timestamps
Issue 9: Add Agent Error Handling and Retry Logic
Description: Enhance the agent with basic fault tolerance: if Django is unreachable, retry 3 times with delay.
Tasks:
- Wrap POST in try-except
- Retry on
URLError
ortimeout
- Log all failures and retries
Issue 10: Test Agent Behavior with Invalid/Incomplete Data
Description: Simulate bad data from the agent to test Django validation (e.g., missing hostname, wrong IP).
Tasks:
- Send malformed JSON manually or via agent
- Observe API response (400 errors)
- Confirm that invalid records are not saved