Skip to main content

Simple and effective server monitoring with easy configuration and multiple notification options

Project description

Server Monitoring Made Easy (SME)

A lightweight, easy-to-configure server monitoring tool that focuses on the metrics that matter most.

Features

  • Monitor critical server metrics:
    • CPU usage
    • Memory consumption
    • Disk space
    • Network latency (ping)
  • Flexible storage options:
    • File-based storage with JSON
    • PostgreSQL database support
  • Advanced alert management:
    • Customizable thresholds
    • Alert count requirements before triggering
    • Automatic alert resolution
    • Alert history and pruning
  • Comprehensive logging:
    • Component-level log configuration
    • Configurable log paths
    • Debug logging support
  • Run modes:
    • Daemon mode with proper PID management
    • Foreground mode for debugging
    • Container support
  • Easy-to-use CLI interface
  • Extensible architecture for custom monitors

Installation

From source:

git clone https://github.com/timmyb824/server-monitoring-made-easy.git
cd server-monitoring-made-easy
pip install -e .

Configuration

Create a configuration file config.yaml. Here's a complete example with all available options (required options are marked with *):

# Logging Configuration
logging:
  level: debug # Global log level (debug, info, warning, error)
  components: # Component-specific log levels (all optional)
    monitors: debug
    alerts: debug
    metrics: debug
    daemon: debug
    storage: debug
    alerts: debug

# Path Configuration (all optional - defaults will be used if not specified)
paths:
  # Log file path - ensure this directory exists and has proper permissions
  log_file: "/path/to/log/server-monitor.log"
  # PID file location
  pid_file: "/path/to/pid/server-monitor.pid"

# Storage Configuration (required *)
storage: # * At least one storage type must be configured
  # Storage type: 'file' or 'postgres' (required *)
  type: file
  # For file storage:
  file_path: "/path/to/alerts.json" # * Required if type is 'file'
  # For PostgreSQL storage:
  # dsn: "postgresql://user:password@localhost:5432/dbname" # * Required if type is 'postgres'

  # Alert pruning configuration (optional)
  pruning:
    enabled: true
    max_age_days: 30 # Remove alerts older than this
    max_alerts: 1000 # Keep only the most recent N alerts

# Monitor Configuration (required *)
monitors: # * At least one monitor must be enabled
  cpu:
    enabled: true # * Required for each monitor
    interval: 60 # Check every 60 seconds (optional, default: 60)
    threshold: 80 # Alert when CPU usage > 80% (optional, default: 80)
    alert_count: 3 # Require 3 consecutive threshold violations (optional, default: 1)

  memory:
    enabled: true
    interval: 60
    threshold: 80
    alert_count: 1 # Alert immediately on threshold violation

  disk:
    enabled: true
    interval: 300 # Check every 5 minutes
    threshold: 85
    alert_count: 2
    path: / # Monitor specific path (optional, default: /)

  ping:
    enabled: true
    interval: 60
    threshold: 200 # Alert when ping > 200ms
    alert_count: 5
    targets: # * Required if ping monitor is enabled
      - 8.8.8.8
      - 1.1.1.1
      - google.com

# Alert Configuration (optional)
alerts:
  # Global alert settings
  default_alert_count: 1 # Default threshold violations before alerting (optional)
  resolution_time: 300 # Seconds to wait before auto-resolving (optional, default: 300)

{{ ... }}

## CLI Commands

- `server-monitor start [-f/--foreground] [-c/--config PATH]`: Start monitoring
  - `-f/--foreground`: Run in foreground instead of as daemon
  - `-c/--config`: Specify config file path
- `server-monitor stop`: Stop the monitoring daemon
- `server-monitor status`: Show daemon status
- `server-monitor metrics`: Display current system metrics
- `server-monitor alerts`: Show current and historical alerts
- `server-monitor config show`: Display current configuration
- `server-monitor config validate`: Validate configuration file
- `server-monitor init PATH`: Create new configuration file with defaults

## Running as a Service

### Using systemd

1. Create a systemd service file at `/etc/systemd/system/server-monitor.service`:

```ini
[Unit]
Description=Server Monitoring Made Easy
After=network.target

[Service]
Type=simple
User=your_user
Environment="SME_CONFIG=/path/to/config.yaml"
ExecStart=/path/to/python/bin/server-monitor start --foreground
Restart=always
RestartSec=30

[Install]
WantedBy=multi-user.target
  1. Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable server-monitor
sudo systemctl start server-monitor

Using Docker

version: "3"
services:
  monitor:
    build: .
    pid: "host" # Required for accurate system metrics
    volumes:
      - /proc:/host/proc:ro # For host metrics
      - ./config.yaml:/app/config.yaml:ro
    restart: unless-stopped

Development

For development and testing:

# Install development dependencies
poetry install

# Run tests
poetry run pytest tests/ -v

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

server_monitoring_made_easy-0.1.3.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

server_monitoring_made_easy-0.1.3-py3-none-any.whl (28.2 kB view details)

Uploaded Python 3

File details

Details for the file server_monitoring_made_easy-0.1.3.tar.gz.

File metadata

File hashes

Hashes for server_monitoring_made_easy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 0e10d8f0faaab5583e72218d6a933e32ba27327b9270750ccc6c418210cbe549
MD5 9339ddfe7aa0869e5207ad2d09318ed3
BLAKE2b-256 dee7a1c6d77b197020141726b02f93b6b6845c18a5bdf17b1e4f2e80254ca1ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for server_monitoring_made_easy-0.1.3.tar.gz:

Publisher: ci.yaml on timmyb824/server-monitoring-made-easy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file server_monitoring_made_easy-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for server_monitoring_made_easy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7f4a7f4f3062301760b108b4b3aa35cfd39063bf02a92e7aec12296b6813db43
MD5 326754cd081f7f881a2ed2a6246d6277
BLAKE2b-256 6a577cb28dd9d2000ca56a544425d07fd7e9f13d2fb1cb55c2ed8914fa9ae019

See more details on using hashes here.

Provenance

The following attestation bundles were made for server_monitoring_made_easy-0.1.3-py3-none-any.whl:

Publisher: ci.yaml on timmyb824/server-monitoring-made-easy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page