Skip to main content

Predict system resource exhaustion before it happens.

Project description

๐Ÿ”ญ Foresight

Predict system resource exhaustion before it happens.

PyPI Python License: MIT Open Source Made at DTU


Traditional monitoring tools tell you what is happening. Foresight tells you what will happen โ€” before it does.


๐Ÿ“– What is Foresight?

Foresight is a lightweight, CLI-native system resource forecaster built in Python. It collects CPU, RAM, and disk metrics locally, stores them in SQLite, and applies time-series ML models (ARIMA, Holt-Winters, Ensemble) to predict resource exhaustion before it happens.

No cloud. No dashboard. No subscription. Just your terminal.

foresight healthcheck --horizon 1h
System Health Check โ€” next 1h via ENSEMBLE

  โœ…  cpu_percent    OK          now: 18.4%   threshold: 75.0%   trend: stable
  ๐Ÿšจ  ram_percent    CRITICAL    now: 87.4%   threshold: 80.0%   trend: rising
  โœ…  disk_percent   OK          now: 17.4%   threshold: 85.0%   trend: stable

  ๐Ÿšจ  Overall: CRITICAL

โœจ Features

Feature Description
Live Monitor Real-time resource usage with color-coded health indicators
ARIMA Forecasting AutoRegressive model for trend-based prediction
Holt-Winters Forecasting Exponential smoothing โ€” weights recent data more heavily
Ensemble Forecasting Blends ARIMA + Holt-Winters for more robust predictions
Threshold Alerting Warns when a metric is predicted to breach safe limits
Health Check Full system overview across all metrics in one command
ASCII Charts Visualize metric history directly in the terminal
Smart Defaults Per-metric health thresholds based on industry standards
Horizon-based Think in time: --horizon 30m, --horizon 1h, --horizon 2h

๐Ÿš€ Quick Start

Install via pip

pip install foresight-cli

That's it. The foresight command is now available globally.

Collect Data

# Collect 60 snapshots every 60 seconds (1 hour of data)
foresight collect

# Quick test โ€” 10 snapshots every 5 seconds
foresight collect --rounds 10 --interval 5

โš ๏ธ Important: Forecasting requires historical data. For reliable 30-minute forecasts, collect at least 2-3 hours of data first. The more data, the better the predictions.

Check Your System

foresight healthcheck --horizon 30m

๐Ÿ“‹ All Commands

foresight collect

Collect system metrics and save to local SQLite database.

foresight collect                           # 60 rounds ร— 60s = 1 hour
foresight collect --rounds 30 --interval 5  # 30 snapshots every 5 seconds

foresight status

Single live snapshot with color-coded health indicators.

foresight status

foresight watch

Live refreshing monitor. Clears screen and updates every N seconds.

foresight watch                    # every 5s, 50 rounds
foresight watch --interval 2 --rounds 30

foresight show

Display recent snapshots as a color-coded formatted table.

foresight show               # last 10 snapshots
foresight show --limit 50    # last 50 snapshots

foresight chart

ASCII line chart of any metric rendered directly in the terminal.

foresight chart                               # default: cpu_percent
foresight chart --metric ram_percent
foresight chart --metric disk_percent --limit 100

Available metrics: cpu_percent, ram_percent, ram_used_mb, disk_percent, disk_used_gb

foresight forecast

Forecast future resource usage over a time horizon.

foresight forecast                                     # CPU, 30m, ensemble
foresight forecast --metric ram_percent --horizon 1h
foresight forecast --metric cpu_percent --horizon 2h --model arima
foresight forecast --metric disk_percent --model holtwinters

Models:

  • ensemble (default) โ€” Blends ARIMA + Holt-Winters. Most robust.
  • arima โ€” Better for data with clear, consistent trends
  • holtwinters โ€” Better when recent data matters more than history

foresight alert

Check if a metric is predicted to breach its health threshold.

foresight alert                                         # CPU, 30m, smart threshold
foresight alert --metric ram_percent --horizon 1h
foresight alert --metric cpu_percent --threshold 70     # custom threshold

foresight healthcheck

Full system health check across CPU, RAM, and Disk at once.

foresight healthcheck              # 30m horizon, ensemble
foresight healthcheck --horizon 1h
foresight healthcheck --model arima

๐ŸŽฏ Smart Health Thresholds

Foresight uses industry-standard thresholds by default:

Metric Warning Critical Reasoning
CPU 75% 90% Above 75% sustained โ†’ thermal throttling risk
RAM 80% 90% Above 80% โ†’ heavy memory swapping begins
Disk 85% 95% Above 85% โ†’ write performance degrades

Override any threshold with --threshold flag.


๐Ÿ“Š How Much Data Do You Need?

Forecast Horizon Minimum Snapshots Recommended
30 minutes 30 snapshots 2โ€“3 hours of data
1 hour 60 snapshots 4โ€“6 hours of data
2 hours 120 snapshots 8โ€“12 hours of data

Rule of thumb: Collect at least 3โ€“5ร— more history than your forecast horizon for reliable predictions.


๐Ÿง  How Forecasting Works

Foresight uses three time-series forecasting models:

ARIMA (AutoRegressive Integrated Moving Average) Predicts future values based on patterns in past values and past prediction errors. Parameters: AR (past values), I (differencing to remove trend), MA (error correction). Best for data with a clear, consistent long-term trend.

Holt-Winters Exponential Smoothing Weights recent data more heavily than older data โ€” exponentially decreasing influence. The model continuously updates its estimate of level and trend as new data arrives. Best for data where recent behaviour matters more than long-term history.

Ensemble (Default) Averages ARIMA and Holt-Winters predictions step by step. Two models with different assumptions tend to make different errors โ€” averaging cancels individual mistakes out. Consistently more robust than either model alone.


๐Ÿ› ๏ธ Tech Stack

Layer Technology
Language Python 3.10+
Metrics collection psutil
Local storage SQLite (built-in)
Forecasting statsmodels (ARIMA + Holt-Winters)
Data handling pandas
CLI framework Typer
Terminal UI Rich
ASCII charts plotext
Packaging setuptools + pyproject.toml

๐Ÿ“ Project Structure

foresight/
โ”œโ”€โ”€ foresight/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ collector.py    # psutil metrics collection
โ”‚   โ”œโ”€โ”€ storage.py      # SQLite database layer
โ”‚   โ”œโ”€โ”€ forecaster.py   # ARIMA, Holt-Winters, Ensemble, alerting
โ”‚   โ””โ”€โ”€ cli.py          # Typer CLI โ€” all 8 commands
โ”œโ”€โ”€ tests/
โ”œโ”€โ”€ data/               # SQLite database (gitignored, created locally)
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ README.md

๐Ÿค Contributing

Contributions are welcome. Please read CONTRIBUTING.md first.


๐Ÿ—บ๏ธ Roadmap

  • Export forecasts to CSV
  • Cron job integration for automated collection
  • Network metrics (bandwidth usage)
  • Multi-machine support
  • Weighted ensemble based on historical model accuracy
  • GitHub Actions CI pipeline
  • Seasonal detection when sufficient data is available

๐Ÿ‘จโ€๐Ÿ’ป Author

Built by Rishi Garg 2nd Year AIML Student, Delhi Technological University Member, AIMS-DTU โ€” AI/ML Society of DTU

Built as a portfolio and learning project with a focus on time-series forecasting, system programming, and open-source contribution.


๐Ÿ“„ License

MIT License โ€” see LICENSE for details.


If this helped you, give it a โญ on GitHub

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

foresight_cli-0.1.1.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

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

foresight_cli-0.1.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file foresight_cli-0.1.1.tar.gz.

File metadata

  • Download URL: foresight_cli-0.1.1.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for foresight_cli-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3bee50e295f4bdd9bd279541700a25db1ae9935addf08f505866fa88d8d9edc2
MD5 0a16e0861b89005362a1b55083708026
BLAKE2b-256 a7ef030a860fdbb8983cc71937f7d344c1d642c8f1d61f999eae3f91de74e71f

See more details on using hashes here.

File details

Details for the file foresight_cli-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: foresight_cli-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for foresight_cli-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c22c77d5113625f80b89e83024fc7a490a272f548f884b3bdf994c52915aea9
MD5 4ec0046215a8d285b804221041e1a1c0
BLAKE2b-256 b321995846fcb146d7636aa9700bc948e4f8c3cead1c882bdb571ff98e784330

See more details on using hashes here.

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