Skip to content

n-elie7/Coding-lab_Group14

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

Python Bash License

Hospital Log Management System

An automated log management system for collecting, archiving, and analyzing real-time patient health metrics and resource usage data.

Project Overview

This system demonstrates proficiency in:

  • Interactive shell scripting
  • Log file processing
  • Data analysis with Linux tools
  • Automated monitoring and reporting

System Architecture

Components

  1. Data Collection Simulators (Python)

    • heart_rate_monitor.py - Simulates 2 heart rate monitors
    • temperature_recorder.py - Simulates 2 temperature sensors
    • water_consumption.py - Simulates water usage meter
  2. Management Scripts (Bash)

    • archive_logs.sh - Interactive log archival with timestamp
    • analyze_logs.sh - Intelligent log analysis and reporting

Directory Structure

.
├── 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

Getting Started

Prerequisites

  • Python 3.x
  • Bash shell
  • Linux/Unix environment

Installation

  1. Clone the repository:
git clone https://github.com/n-elie7/Coding-lab_Group14.git
cd Coding-lab_Group14/hospital-data
  1. Make scripts executable:
chmod +x archive_logs.sh analyze_logs.sh

Initialization

Start 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 start

Verify data collection:

tail -f active_logs/heart_rate_log.log

Usage Guide

Archive Logs Script

The archive_logs.sh script provides an interactive menu to archive selected log files.

Run the script:

./archive_logs.sh

Example 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

Analyze Logs Script

The analyze_logs.sh script analyzes device occurrences and generates detailed reports.

Run the script:

./analyze_logs.sh

Example 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

Technical Details

Log File Format

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

Key Commands Used

Task Commands
Archival date, mv, touch, case, mkdir
Analysis awk, grep, sort, uniq, head, tail, wc
Reporting echo, >>, date

Error Handling

Both scripts include comprehensive error handling:

  • Invalid user input validation
  • Missing file detection
  • Empty file warnings
  • Directory creation safeguards

Stopping Monitors

To stop the monitoring devices:

python3 heart_rate_monitor.py stop
python3 temperature_recorder.py stop
python3 water_consumption.py stop

Sample Report Output

========================================
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

========================================

Contributing

This is an academic project. For modifications or improvements, please follow standard git workflow practices.

License

This project is part of an academic assignment.

Authors

Group 14 - Coding Lab Project

  • Niyubwayo Irakoze Elie (Software Engineer)
  • Ganza Gavin (Software Engineer)
  • Dalynah Uwase Gasarasi (Software Engineer)
  • Olivier Dusabamahoro (Software Engineer)

Acknowledgments

  • Project specifications provided by the institution
  • Python simulators for realistic data generation
  • Linux shell scripting best practices

About

Automated hospital log management system with interactive archival and analysis scripts. Monitors patient health metrics (heart rate, temperature) and resource usage (water consumption) in real-time.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors