Skip to content

feat: server monitoring metrics - #76

Closed
loadinglucian wants to merge 3 commits into
mainfrom
feat/server-monitoring-metrics
Closed

feat: server monitoring metrics#76
loadinglucian wants to merge 3 commits into
mainfrom
feat/server-monitoring-metrics

Conversation

@loadinglucian

@loadinglucian loadinglucian commented Nov 10, 2025

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Server now displays Caddy and PHP-FPM metrics (version, uptime, requests, process information).
    • Added Bun installation support.
    • Enhanced deployer user and SSH key setup during installation.
  • Improvements

    • Improved installation reliability with package manager lock handling and retry logic.
    • Reorganized demo site setup with prerequisite checks and structured configuration.
    • Enhanced repository and package management for better dependency handling.

- Create modular Caddy configuration with conf.d/sites/ directory
- Add localhost-only monitoring endpoints (PHP-FPM status)
- Enable PHP-FPM status page in pool configuration
- Update demo-site to use new modular config structure
- Improve code organization with better section headers
- Query Caddy admin API for version, uptime, requests, memory
- Query PHP-FPM status endpoint for pool stats and performance metrics
- Extract metrics using curl and text parsing (no jq dependency)
- Output metrics in YAML format for server info command
- Display Caddy metrics: version, uptime, requests, memory
- Display PHP-FPM metrics: pool, processes, queue, performance indicators
- Add formatUptime helper for human-readable uptime display
- Highlight warnings for queue backlog and performance issues
@coderabbitai

coderabbitai Bot commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

This PR extends server deployment and monitoring capabilities by adding Caddy and PHP-FPM metrics collection, implementing server information display enhancements, establishing deployer user management, creating deployment infrastructure setup workflows, and introducing package manager lock handling with repository configuration logic.

Changes

Cohort / File(s) Summary
Server Info Display
app/Traits/ServersTrait.php
Added conditional display sections for Caddy metrics (version, uptime formatted, requests, memory) and PHP-FPM metrics (pool, processes, queue with highlighting, connections). Introduced formatUptime() helper to convert seconds into human-readable format (s, m, h m, d h).
Server Info Collection
playbooks/server-info.sh
Implemented get_caddy_metrics() and get_php_fpm_metrics() functions to collect service metrics. Integrated metrics into YAML output under caddy and php_fpm sections with availability flags. Added orchestration to invoke collectors and parse tab-separated outputs during execution.
Deployment Infrastructure Setup
playbooks/server-install.sh
Added wait_for_dpkg_lock() for package manager lock handling with retry logic. Introduced setup_repositories() for distro-specific Caddy/PHP repo configuration. Created setup_caddy_structure() for Caddy config scaffolding with localhost proxy. Implemented deployer user management via ensure_deployer_user(), setup_deploy_user(), configure_deployer_groups(), and setup_deploy_directories(). Added install_bun() and setup_deploy_key() for deployment tooling. Integrated all new functions into main execution flow.
Demo Site Configuration
playbooks/demo-site.sh
Refactored configuration from dedicated Caddyfile to site-specific setup with new configure_demo_site() function. Added explicit prerequisites checks for deployer user and home directory. Restructured site directory creation with proper ownership/permissions. Updated output YAML key from caddy_configured to demo_site_configured.

Sequence Diagrams

sequenceDiagram
    participant main as Main Script
    participant caddy as Caddy Metrics<br/>(get_caddy_metrics)
    participant phpfpm as PHP-FPM Metrics<br/>(get_php_fpm_metrics)
    participant yaml as YAML Output
    
    main->>caddy: Execute metrics collection
    caddy-->>main: Return tab-separated data<br/>(version, uptime_s, requests, etc.)
    main->>phpfpm: Execute metrics collection
    phpfpm-->>main: Return tab-separated data<br/>(pool, processes, queue, etc.)
    
    main->>main: Parse outputs into variables
    main->>yaml: Emit caddy section with availability flag
    main->>yaml: Emit php_fpm section with availability flag
    
    rect rgb(200, 220, 240)
    Note over main,yaml: New metrics integrated into<br/>server-info YAML output
    end
Loading
sequenceDiagram
    participant main as Main Install Script
    participant prereq as Prerequisites
    participant repos as Repositories
    participant caddy as Caddy Setup
    participant deploy as Deployer Setup
    participant key as SSH Key Setup
    
    main->>prereq: Check prerequisites (distro/family)
    prereq-->>main: Validation complete
    
    main->>repos: setup_repositories()
    repos-->>main: Add Caddy & PHP repos with GPG keys
    
    main->>caddy: setup_caddy_structure()
    caddy-->>main: Create config dirs, Caddyfile, localhost proxy
    
    main->>deploy: ensure_deployer_user()
    deploy->>deploy: setup_deploy_user()
    deploy->>deploy: configure_deployer_groups()
    deploy->>deploy: setup_deploy_directories()
    deploy-->>main: Deployer account configured with permissions
    
    main->>key: setup_deploy_key()
    key-->>main: SSH key generated for git operations
    
    rect rgb(200, 240, 200)
    Note over main,key: New orchestrated setup flows<br/>for infrastructure & deployment
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • playbooks/server-install.sh: Most substantial changes with nine new functions handling package locks, repository setup, Caddy scaffolding, deployer account management, SSH key generation, and modified installation flow. Requires careful verification of deployment user permissions, SSH key handling, and repository configuration syntax across distros.
  • playbooks/server-info.sh: New metric collection functions with shell command parsing and YAML output integration. Verify metric extraction logic and fallback handling for unavailable services.
  • playbooks/demo-site.sh: Workflow restructuring with ownership/permissions logic; verify deployer user integration and path correctness.
  • app/Traits/ServersTrait.php: New display formatting and helper function; validate uptime formatting edge cases and conditional display logic.

Possibly related PRs

  • refactor: playbooks file output #63: Modifies playbooks/server-info.sh with server metrics collection and output restructuring, overlapping with this PR's metrics integration.
  • feat: server management commands #68: Extends app/Traits/ServersTrait.php with server info display helpers; includes similar formatUptime and display logic additions.
  • feat: server info command #62: Adds server-info command infrastructure and trait methods alongside playbooks/server-info.sh modifications, directly foundational to these metrics changes.

Poem

🐰 Hops through the code with glee and care,
Caddy metrics now float through the air,
PHP-FPM stats dance in the display,
Deployer users setup their way,
Infrastructure dreams come alive today!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/server-monitoring-metrics

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94eb2f9 and fc6e4b3.

📒 Files selected for processing (4)
  • app/Traits/ServersTrait.php (1 hunks)
  • playbooks/demo-site.sh (9 hunks)
  • playbooks/server-info.sh (9 hunks)
  • playbooks/server-install.sh (15 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@loadinglucian
loadinglucian deleted the feat/server-monitoring-metrics branch November 10, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant