An automated log management system for collecting, archiving, and analyzing real-time patient health metrics and resource usage data.
This system demonstrates proficiency in:
- Interactive shell scripting
- Log file processing
- Data analysis with Linux tools
- Automated monitoring and reporting
-
Data Collection Simulators (Python)
heart_rate_monitor.py- Simulates 2 heart rate monitorstemperature_recorder.py- Simulates 2 temperature sensorswater_consumption.py- Simulates water usage meter
-
Management Scripts (Bash)
archive_logs.sh- Interactive log archival with timestampanalyze_logs.sh- Intelligent log analysis and reporting
.
├── hospital_data/
│ ├── active_logs/ # Current log files
│ │ ├── heart_rate.log # Format: TIMESTAMP DEVICE VALUE
│ │ ├── temperature_log.log
│ │ └── water_usage_log.log
│ ├── archived_logs/ # Archived data
│ │ ├── heart_data_archive/
│ │ ├── temperature_data_archive/
│ │ └── water_usage_data_archive/
│ └── reports/ # Analysis reports
│ └── analysis_report.txt
├── heart_rate_monitor.py
├── temperature_recorder.py
├── water_consumption.py
├── archive_logs.sh
├── analyze_logs.sh
└── README.md
- Python 3.x
- Bash shell
- Linux/Unix environment
- Clone the repository:
git clone https://github.com/n-elie7/Coding-lab_Group14.git
cd Coding-lab_Group14/hospital-data- Make scripts executable:
chmod +x archive_logs.sh analyze_logs.shStart the monitoring devices in separate terminals:
# Terminal 1 - Heart Rate Monitor
python3 heart_rate_monitor.py start
# Terminal 2 - Temperature Sensor
python3 temperature_recorder.py start
# Terminal 3 - Water Meter
python3 water_consumption.py startVerify data collection:
tail -f active_logs/heart_rate_log.logThe archive_logs.sh script provides an interactive menu to archive selected log files.
Run the script:
./archive_logs.shExample Output:
======================================
Hospital Log Archival System
======================================
Select log to archive:
1) Heart Rate
2) Temperature
3) Water Usage
4) Exit
Enter choice (1-4): 1
Archiving heart_rate.log...
==============================================================================
Successfully archived to heart_data_archive/heart_rate_2024-06-18_15:22:10.log
==============================================================================
New empty log file created at active_logs/heart_rate_log.log
==============================================================================
Features:
- Interactive menu for log selection
- Automatic timestamp generation (YYYY-MM-DD_HH:MM:SS)
- Creates new empty log files for continued monitoring
- Error handling for missing files and invalid input
- Color-coded output for better visibility
The analyze_logs.sh script analyzes device occurrences and generates detailed reports.
Run the script:
./analyze_logs.shExample Output:
======================================
Hospital Log Analysis System
======================================
Select log file to analyze:
1) Heart Rate (heart_rate_log.log)
2) Temperature (temperature_log.log)
3) Water Usage (water_usage_log.log)
4) Exit
Enter choice (1-4): 1
Analyzing Heart Rate log...
===============================================
Report appended to: reports/analysis_report.txt
===============================================
Features:
- Device-specific statistics (occurrence count, first/last entry timestamp)
- Summary statistics (total entries, unique devices)
- Results appended to persistent report file
All log files follow this format:
YYYY-MM-DD HH:MM:SS DEVICE_NAME VALUE
Examples:
2024-06-18 14:30:45 HeartRate_Monitor_A 72
2024-06-18 14:30:45 Temp_Recorder_A 37.2
2024-06-18 14:30:45 Water_Consumption_Meter 5
| Task | Commands |
|---|---|
| Archival | date, mv, touch, case, mkdir |
| Analysis | awk, grep, sort, uniq, head, tail, wc |
| Reporting | echo, >>, date |
Both scripts include comprehensive error handling:
- Invalid user input validation
- Missing file detection
- Empty file warnings
- Directory creation safeguards
To stop the monitoring devices:
python3 heart_rate_monitor.py stop
python3 temperature_recorder.py stop
python3 water_consumption.py stop========================================
Analysis Report: Heart Rate
Generated: 2024-06-18 15:25:30
========================================
Device Statistics:
-----------------
Device: HeartRate_Monitor_A
Total Entries: 150
First Entry: 2024-06-18 14:30:45
Last Entry: 2024-06-18 15:20:10
Device: HeartRate_Monitor_B
Total Entries: 150
First Entry: 2024-06-18 14:30:45
Last Entry: 2024-06-18 15:20:10
Summary:
--------
Total Log Entries: 300
Unique Devices: 2
========================================
This is an academic project. For modifications or improvements, please follow standard git workflow practices.
This project is part of an academic assignment.
- Niyubwayo Irakoze Elie (
Software Engineer) - Ganza Gavin (
Software Engineer) - Dalynah Uwase Gasarasi (
Software Engineer) - Olivier Dusabamahoro (
Software Engineer)
- Project specifications provided by the institution
- Python simulators for realistic data generation
- Linux shell scripting best practices