#data #system #optimization #monitoring #alert #service #notifications

bin+lib data-guardian

System service for monitoring and optimizing app data usage

1 stable release

new 1.0.1 Feb 21, 2025

#161 in Configuration

38 downloads per month

MIT license

44KB
817 lines

Data Guardian

License: MIT Rust Version Platform Support CI

Data Guardian is a system service for monitoring and optimizing application data usage. It provides real-time monitoring, alerts, and insights into how applications consume data on your system.

Features

  • Real-time Monitoring: Track data usage across all running applications
  • Smart Alerts: Receive notifications when applications exceed data thresholds
  • Local-First: All data processing happens locally for maximum privacy
  • Efficient Storage: Compressed historical data for trend analysis
  • Cross-Platform: Supports Linux, macOS, and Windows
  • Low Overhead: Minimal system resource usage
  • Configurable: Flexible settings for thresholds and intervals

Installation

Prerequisites

  • Rust 1.78 or higher
  • Cargo package manager
  • Platform-specific dependencies:
    • Linux: libdbus-1-dev
    • macOS: None
    • Windows: None

From Source

# Clone the repository
git clone https://github.com/xosnrdev/data-guardian.git
cd data-guardian

# Build and install
cargo install --path .

From Cargo

cargo install data-guardian

Usage

Quick Start

  1. Start the service:

    dg
    
  2. The service will run in the background and monitor data usage

  3. Receive notifications when applications exceed thresholds

Configuration

The service can be configured in three ways (in order of precedence):

  1. Environment variables:

    DATAGUARDIAN_DATA_LIMIT=1073741824
    DATAGUARDIAN_CHECK_INTERVAL_SECONDS=60
    DATAGUARDIAN_PERSISTENCE_INTERVAL_SECONDS=300
    
  2. User configuration file at:

    • Linux: ~/.config/DataGuardian/config.toml
    • macOS: ~/Library/Application Support/DataGuardian/config.toml
    • Windows: %APPDATA%\DataGuardian\config.toml

    Example config.toml:

    # Data limit in bytes before triggering alerts
    data_limit = 1073741824  # 1 GB
    
    # How often to check process data usage (in seconds)
    check_interval_seconds = 60
    
    # How often to save usage data to disk (in seconds)
    persistence_interval_seconds = 300  # 5 minutes
    
  3. Default values:

    • data_limit: 1 GB (1073741824 bytes)
    • check_interval_seconds: 60 seconds
    • persistence_interval_seconds: 300 seconds (5 minutes)

Environment Variables

  • DATAGUARDIAN_DATA_LIMIT: Override data limit
  • DATAGUARDIAN_CHECK_INTERVAL_SECONDS: Override check interval
  • DATAGUARDIAN_PERSISTENCE_INTERVAL_SECONDS: Override persistence interval
  • RUST_LOG: Set logging level (error, warn, info, debug, trace)

Development

Building

# Build debug version
cargo build

# Build release version
cargo build --release

Testing

# Run all tests
make test

# Run specific test
cargo test test_name

# Run with logging
cargo test -- --nocapture

Code Quality

# Run all checks
make all

# Format code
make fmt

# Run lints
make lint

License

Licensed under the MIT License

Acknowledgments

Roadmap

  • Web interface for data visualization
  • Application grouping and categories
  • Network interface filtering
  • Custom alert rules
  • Data usage predictions
  • Export and reporting features

Dependencies

~17–45MB
~691K SLoC