Collection of scripts for demonstrating HemoStat's autonomous container health monitoring and remediation capabilities. These scripts are designed for hackathon demos, testing, and verification of the end-to-end agent workflow.
Enable Docker BuildKit for 95% faster rebuilds!
Choose your platform:
- Windows:
.\scripts\windows\enable_buildkit.ps1 - Linux:
./scripts/linux/enable_buildkit.sh - macOS:
./scripts/macos/enable_buildkit.zsh
See BUILDKIT_SETUP.md for detailed instructions.
Scripts are organized by platform for easier navigation:
windows/- PowerShell scripts (.ps1) for Windowsmacos/- Zsh scripts (.zsh) for macOSlinux/- Bash scripts (.sh) for Linux/WSL
- Docker and Docker Compose installed and running
- HemoStat services started:
docker-compose up -d - curl installed (for HTTP requests)
All scripts are available in all three platform directories:
Triggers high CPU usage on test-api service to demonstrate CPU spike detection and remediation.
Usage:
./demo_trigger_cpu_spike.sh [duration] [intensity]Parameters:
duration: Spike duration in seconds (default: 60)intensity: CPU intensity 0.0-1.0 (default: 0.9 = 90%)
Example:
./demo_trigger_cpu_spike.sh 45 0.95Expected Outcome:
- Monitor detects CPU >85% threshold
- Analyzer recommends container restart
- Responder executes restart (if not in cooldown)
- Alert sends Slack notification
- Dashboard shows event in timeline
Triggers high memory usage to demonstrate memory leak detection.
Usage:
./demo_trigger_high_memory.sh [duration] [size_mb]Parameters:
duration: Spike duration in seconds (default: 60)size_mb: Memory to allocate in MB (default: 500)
Example:
./demo_trigger_high_memory.sh 45 600Expected Outcome:
- Monitor detects memory >80% threshold
- Analyzer recommends container restart
- Responder executes restart
- Alert sends notification
- Dashboard updates
Demonstrates cleanup remediation action (remove stopped containers, prune resources).
Usage:
./demo_trigger_cleanup.shNo parameters required
Expected Outcome:
- Script creates stopped test containers
- Manually publishes cleanup remediation request
- Responder removes stopped containers
- Alert logs cleanup completion
Automated verification of end-to-end message flow through all agents.
Usage:
./verify_message_flow.shNo parameters required
Expected Outcome:
- Checks all services are running
- Triggers test scenario
- Monitors Redis pub/sub channels
- Verifies each agent responds correctly
- Prints verification summary
Clears all HemoStat data from Redis for a fresh start between test runs.
Usage:
./clear_redis_data.sh # Bash
./clear_redis_data.zsh # Zsh.\scripts\clear_redis_data.ps1 # PowerShellWhat gets cleared:
- All events (timeline, history)
- Remediation state and cooldowns
- Circuit breaker state
- Alert history
- Audit logs
Note: Prompts for confirmation before clearing data.
Exports all HemoStat data to a JSON file for later analysis or archival.
Usage:
# Default timestamped file
./backup_redis_data.sh
# Custom filename
./backup_redis_data.sh my_backup.json# Default timestamped file
.\scripts\backup_redis_data.ps1
# Custom filename
.\scripts\backup_redis_data.ps1 -OutputFile "my_backup.json"Output:
- Timestamped JSON file (e.g.,
hemostat_backup_20251103_052000.json) - Includes all events, state, and metadata
- Can be used for debugging or demo replay
cd scripts/linux
chmod +x *.sh # Make executable (first time only)
# 1. Start HemoStat
docker-compose up -d
sleep 30
# 2. Verify system
./verify_message_flow.sh
# 3. Run demos
./demo_trigger_cpu_spike.sh
./demo_trigger_high_memory.shcd scripts/macos
chmod +x *.zsh # Make executable (first time only)
# 1. Start HemoStat
docker-compose up -d
sleep 30
# 2. Verify system
./verify_message_flow.zsh
# 3. Run demos
./demo_trigger_cpu_spike.zsh
./demo_trigger_high_memory.zshcd scripts\windows
# 1. Start HemoStat
docker-compose up -d
Start-Sleep -Seconds 30
# 2. Verify system
.\verify_message_flow.ps1
# 3. Run demos
.\demo_trigger_cpu_spike.ps1
.\demo_trigger_high_memory.ps1# All agents
docker-compose logs -f monitor analyzer responder alert
# Specific agent
docker-compose logs -f monitor
# Last 100 lines
docker-compose logs --tail=100 monitor# Subscribe to all HemoStat channels
docker exec hemostat-redis redis-cli SUBSCRIBE 'hemostat:*'
# Subscribe to specific channel
docker exec hemostat-redis redis-cli SUBSCRIBE hemostat:health_alert
# View stored events
docker exec hemostat-redis redis-cli LRANGE hemostat:events:all 0 -1
# View remediation events
docker exec hemostat-redis redis-cli LRANGE hemostat:events:remediation_complete 0 -1# View test-api metrics
curl http://localhost:5001/metrics
# View Docker stats
docker stats hemostat-test-api
# Check all containers
docker statsRun docker-compose up -d to start all services.
docker-compose up -d
docker-compose psWait 30 seconds for services to initialize, then check service status:
docker-compose ps
docker-compose logs- Increase wait time in scripts
- Check Monitor polling interval (default 30s)
- Verify Monitor is running:
docker-compose logs monitor
- Check cooldown period (default 1 hour): May need to wait or adjust
RESPONDER_COOLDOWN_SECONDSin.env - Verify dry-run mode is disabled: Set
RESPONDER_DRY_RUN=falsein.env - Check Responder logs:
docker-compose logs responder
Make scripts executable:
# On Linux/macOS
chmod +x scripts/*.sh
# On Windows (Git Bash)
# Scripts should be executable by default- Start with
verify_message_flow.shto show system is working - Open Dashboard in browser before triggering scenarios
- Run
demo_trigger_cpu_spike.shand narrate the workflow - Show Dashboard updating in real-time
- Show Slack notifications (if configured)
- Explain safety mechanisms (cooldown, circuit breaker)
- "HemoStat autonomously detects container health issues"
- "AI-powered analysis distinguishes real problems from false alarms"
- "Safe remediation with cooldown periods prevents restart loops"
- "Real-time dashboard provides visibility into system health"
- "All actions logged for audit trail and compliance"
- Setup (30s): Show Dashboard, explain architecture
- Trigger (1m): Run CPU spike demo, explain what's happening
- Monitor (2m): Show Monitor detection in logs
- Analyze (30s): Show Analyzer decision
- Respond (30s): Show Responder execution
- Dashboard (30s): Show event timeline and metrics
HTTP API with stress test endpoints.
- Endpoint:
http://localhost:5001 - Health check:
GET /health - Trigger CPU spike:
POST /stress/cpu - Trigger memory spike:
POST /stress/memory - Stop stress:
POST /stress/stop - View metrics:
GET /metrics
Example Usage:
# Trigger CPU spike
curl -X POST http://localhost:5001/stress/cpu \
-H "Content-Type: application/json" \
-d '{"duration": 60, "intensity": 0.9}'
# Check metrics
curl http://localhost:5001/metrics
# Stop stress
curl -X POST http://localhost:5001/stress/stopBackground worker with random spikes.
- Automatically spikes CPU or memory periodically
- Configurable via environment variables in
docker-compose.yml:WORKER_INTERVAL: Time between work cycles (default: 60s)WORKER_SPIKE_PROBABILITY: Chance of spike per cycle (default: 0.1 = 10%)WORKER_SPIKE_DURATION: Spike duration (default: 30s)
- Useful for continuous demo scenarios
View Logs:
docker-compose logs -f test-worker- Main README: ../README.md
- Architecture: ../docs/ARCHITECTURE.md
- API Protocol: ../docs/API_PROTOCOL.md
- Troubleshooting: ../docs/TROUBLESHOOTING.md
- Quick Start Guide: ../docs/QUICKSTART.md
- Phase 5: Formal test suite (pytest) for comprehensive testing
Note: These scripts are designed for demonstration and testing purposes. For production deployment, see ../docs/DEPLOYMENT.md.