foresight-cli 0.1.0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- foresight_cli-0.1.2/LICENSE +21 -0
- foresight_cli-0.1.2/PKG-INFO +342 -0
- foresight_cli-0.1.2/README.md +290 -0
- foresight_cli-0.1.2/foresight_cli.egg-info/PKG-INFO +342 -0
- {foresight_cli-0.1.0 → foresight_cli-0.1.2}/foresight_cli.egg-info/SOURCES.txt +1 -0
- {foresight_cli-0.1.0 → foresight_cli-0.1.2}/pyproject.toml +60 -51
- foresight_cli-0.1.0/PKG-INFO +0 -27
- foresight_cli-0.1.0/README.md +0 -0
- foresight_cli-0.1.0/foresight_cli.egg-info/PKG-INFO +0 -27
- {foresight_cli-0.1.0 → foresight_cli-0.1.2}/foresight/__init__.py +0 -0
- {foresight_cli-0.1.0 → foresight_cli-0.1.2}/foresight/cli.py +0 -0
- {foresight_cli-0.1.0 → foresight_cli-0.1.2}/foresight/collector.py +0 -0
- {foresight_cli-0.1.0 → foresight_cli-0.1.2}/foresight/forecaster.py +0 -0
- {foresight_cli-0.1.0 → foresight_cli-0.1.2}/foresight/storage.py +0 -0
- {foresight_cli-0.1.0 → foresight_cli-0.1.2}/foresight_cli.egg-info/dependency_links.txt +0 -0
- {foresight_cli-0.1.0 → foresight_cli-0.1.2}/foresight_cli.egg-info/entry_points.txt +0 -0
- {foresight_cli-0.1.0 → foresight_cli-0.1.2}/foresight_cli.egg-info/requires.txt +0 -0
- {foresight_cli-0.1.0 → foresight_cli-0.1.2}/foresight_cli.egg-info/top_level.txt +0 -0
- {foresight_cli-0.1.0 → foresight_cli-0.1.2}/setup.cfg +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rishi Garg
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: foresight-cli
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Predict system resource exhaustion before it happens.
|
|
5
|
+
Author: Rishi Garg
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Rishi Garg
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/TECHSCHOLAR777/foresight
|
|
29
|
+
Project-URL: Repository, https://github.com/TECHSCHOLAR777/foresight
|
|
30
|
+
Project-URL: Issues, https://github.com/TECHSCHOLAR777/foresight/issues
|
|
31
|
+
Keywords: cli,monitoring,forecasting,devops,time-series,arima,machine-learning,psutil,system-monitoring,resource-forecasting,holt-winters,ensemble
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Operating System :: OS Independent
|
|
37
|
+
Classifier: Environment :: Console
|
|
38
|
+
Classifier: Topic :: System :: Monitoring
|
|
39
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
40
|
+
Classifier: Intended Audience :: Developers
|
|
41
|
+
Classifier: Intended Audience :: System Administrators
|
|
42
|
+
Requires-Python: >=3.10
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
License-File: LICENSE
|
|
45
|
+
Requires-Dist: psutil>=5.9.0
|
|
46
|
+
Requires-Dist: rich>=13.0.0
|
|
47
|
+
Requires-Dist: typer>=0.9.0
|
|
48
|
+
Requires-Dist: plotext>=5.2.0
|
|
49
|
+
Requires-Dist: pandas>=2.0.0
|
|
50
|
+
Requires-Dist: statsmodels>=0.14.0
|
|
51
|
+
Dynamic: license-file
|
|
52
|
+
|
|
53
|
+
<div align="center">
|
|
54
|
+
|
|
55
|
+
# 🔭 Foresight
|
|
56
|
+
|
|
57
|
+
**Predict system resource exhaustion before it happens.**
|
|
58
|
+
|
|
59
|
+
[](https://pypi.org/project/foresight-cli/)
|
|
60
|
+
[](https://www.python.org/)
|
|
61
|
+
[](LICENSE)
|
|
62
|
+
[](https://github.com/TECHSCHOLAR777/foresight)
|
|
63
|
+
[](https://dtu.ac.in)
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
*Traditional monitoring tools tell you what **is** happening.*
|
|
68
|
+
*Foresight tells you what **will** happen — before it does.*
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
## 📖 What is Foresight?
|
|
75
|
+
|
|
76
|
+
Foresight is a lightweight, CLI-native system resource forecaster built in Python.
|
|
77
|
+
It collects CPU, RAM, and disk metrics locally, stores them in SQLite, and applies
|
|
78
|
+
time-series ML models (ARIMA, Holt-Winters, Ensemble) to predict resource exhaustion
|
|
79
|
+
**before** it happens.
|
|
80
|
+
|
|
81
|
+
No cloud. No dashboard. No subscription. Just your terminal.
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
foresight healthcheck --horizon 1h
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
System Health Check — next 1h via ENSEMBLE
|
|
89
|
+
|
|
90
|
+
✅ cpu_percent OK now: 18.4% threshold: 75.0% trend: stable
|
|
91
|
+
🚨 ram_percent CRITICAL now: 87.4% threshold: 80.0% trend: rising
|
|
92
|
+
✅ disk_percent OK now: 17.4% threshold: 85.0% trend: stable
|
|
93
|
+
|
|
94
|
+
🚨 Overall: CRITICAL
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## ✨ Features
|
|
100
|
+
|
|
101
|
+
| Feature | Description |
|
|
102
|
+
|---|---|
|
|
103
|
+
| **Live Monitor** | Real-time resource usage with color-coded health indicators |
|
|
104
|
+
| **ARIMA Forecasting** | AutoRegressive model for trend-based prediction |
|
|
105
|
+
| **Holt-Winters Forecasting** | Exponential smoothing — weights recent data more heavily |
|
|
106
|
+
| **Ensemble Forecasting** | Blends ARIMA + Holt-Winters for more robust predictions |
|
|
107
|
+
| **Threshold Alerting** | Warns when a metric is predicted to breach safe limits |
|
|
108
|
+
| **Health Check** | Full system overview across all metrics in one command |
|
|
109
|
+
| **ASCII Charts** | Visualize metric history directly in the terminal |
|
|
110
|
+
| **Smart Defaults** | Per-metric health thresholds based on industry standards |
|
|
111
|
+
| **Horizon-based** | Think in time: `--horizon 30m`, `--horizon 1h`, `--horizon 2h` |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 🚀 Quick Start
|
|
116
|
+
|
|
117
|
+
### Install via pip
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
pip install foresight-cli
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
That's it. The `foresight` command is now available globally.
|
|
124
|
+
|
|
125
|
+
### Collect Data
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Collect 60 snapshots every 60 seconds (1 hour of data)
|
|
129
|
+
foresight collect
|
|
130
|
+
|
|
131
|
+
# Quick test — 10 snapshots every 5 seconds
|
|
132
|
+
foresight collect --rounds 10 --interval 5
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
> ⚠️ **Important:** Forecasting requires historical data. For reliable 30-minute
|
|
136
|
+
> forecasts, collect at least 2-3 hours of data first. The more data, the better
|
|
137
|
+
> the predictions.
|
|
138
|
+
|
|
139
|
+
### Check Your System
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
foresight healthcheck --horizon 30m
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 📋 All Commands
|
|
148
|
+
|
|
149
|
+
### `foresight collect`
|
|
150
|
+
Collect system metrics and save to local SQLite database.
|
|
151
|
+
```bash
|
|
152
|
+
foresight collect # 60 rounds × 60s = 1 hour
|
|
153
|
+
foresight collect --rounds 30 --interval 5 # 30 snapshots every 5 seconds
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### `foresight status`
|
|
157
|
+
Single live snapshot with color-coded health indicators.
|
|
158
|
+
```bash
|
|
159
|
+
foresight status
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### `foresight watch`
|
|
163
|
+
Live refreshing monitor. Clears screen and updates every N seconds.
|
|
164
|
+
```bash
|
|
165
|
+
foresight watch # every 5s, 50 rounds
|
|
166
|
+
foresight watch --interval 2 --rounds 30
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### `foresight show`
|
|
170
|
+
Display recent snapshots as a color-coded formatted table.
|
|
171
|
+
```bash
|
|
172
|
+
foresight show # last 10 snapshots
|
|
173
|
+
foresight show --limit 50 # last 50 snapshots
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### `foresight chart`
|
|
177
|
+
ASCII line chart of any metric rendered directly in the terminal.
|
|
178
|
+
```bash
|
|
179
|
+
foresight chart # default: cpu_percent
|
|
180
|
+
foresight chart --metric ram_percent
|
|
181
|
+
foresight chart --metric disk_percent --limit 100
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Available metrics:** `cpu_percent`, `ram_percent`, `ram_used_mb`, `disk_percent`, `disk_used_gb`
|
|
185
|
+
|
|
186
|
+
### `foresight forecast`
|
|
187
|
+
Forecast future resource usage over a time horizon.
|
|
188
|
+
```bash
|
|
189
|
+
foresight forecast # CPU, 30m, ensemble
|
|
190
|
+
foresight forecast --metric ram_percent --horizon 1h
|
|
191
|
+
foresight forecast --metric cpu_percent --horizon 2h --model arima
|
|
192
|
+
foresight forecast --metric disk_percent --model holtwinters
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Models:**
|
|
196
|
+
- `ensemble` *(default)* — Blends ARIMA + Holt-Winters. Most robust.
|
|
197
|
+
- `arima` — Better for data with clear, consistent trends
|
|
198
|
+
- `holtwinters` — Better when recent data matters more than history
|
|
199
|
+
|
|
200
|
+
### `foresight alert`
|
|
201
|
+
Check if a metric is predicted to breach its health threshold.
|
|
202
|
+
```bash
|
|
203
|
+
foresight alert # CPU, 30m, smart threshold
|
|
204
|
+
foresight alert --metric ram_percent --horizon 1h
|
|
205
|
+
foresight alert --metric cpu_percent --threshold 70 # custom threshold
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### `foresight healthcheck`
|
|
209
|
+
Full system health check across CPU, RAM, and Disk at once.
|
|
210
|
+
```bash
|
|
211
|
+
foresight healthcheck # 30m horizon, ensemble
|
|
212
|
+
foresight healthcheck --horizon 1h
|
|
213
|
+
foresight healthcheck --model arima
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 🎯 Smart Health Thresholds
|
|
219
|
+
|
|
220
|
+
Foresight uses industry-standard thresholds by default:
|
|
221
|
+
|
|
222
|
+
| Metric | Warning | Critical | Reasoning |
|
|
223
|
+
|---|---|---|---|
|
|
224
|
+
| CPU | 75% | 90% | Above 75% sustained → thermal throttling risk |
|
|
225
|
+
| RAM | 80% | 90% | Above 80% → heavy memory swapping begins |
|
|
226
|
+
| Disk | 85% | 95% | Above 85% → write performance degrades |
|
|
227
|
+
|
|
228
|
+
Override any threshold with `--threshold` flag.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## 📊 How Much Data Do You Need?
|
|
233
|
+
|
|
234
|
+
| Forecast Horizon | Minimum Snapshots | Recommended |
|
|
235
|
+
|---|---|---|
|
|
236
|
+
| 30 minutes | 30 snapshots | 2–3 hours of data |
|
|
237
|
+
| 1 hour | 60 snapshots | 4–6 hours of data |
|
|
238
|
+
| 2 hours | 120 snapshots | 8–12 hours of data |
|
|
239
|
+
|
|
240
|
+
**Rule of thumb:** Collect at least 3–5× more history than your forecast horizon
|
|
241
|
+
for reliable predictions.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## 🧠 How Forecasting Works
|
|
246
|
+
|
|
247
|
+
Foresight uses three time-series forecasting models:
|
|
248
|
+
|
|
249
|
+
**ARIMA (AutoRegressive Integrated Moving Average)**
|
|
250
|
+
Predicts future values based on patterns in past values and past prediction errors.
|
|
251
|
+
Parameters: AR (past values), I (differencing to remove trend), MA (error correction).
|
|
252
|
+
Best for data with a clear, consistent long-term trend.
|
|
253
|
+
|
|
254
|
+
**Holt-Winters Exponential Smoothing**
|
|
255
|
+
Weights recent data more heavily than older data — exponentially decreasing influence.
|
|
256
|
+
The model continuously updates its estimate of level and trend as new data arrives.
|
|
257
|
+
Best for data where recent behaviour matters more than long-term history.
|
|
258
|
+
|
|
259
|
+
**Ensemble (Default)**
|
|
260
|
+
Averages ARIMA and Holt-Winters predictions step by step. Two models with different
|
|
261
|
+
assumptions tend to make different errors — averaging cancels individual mistakes out.
|
|
262
|
+
Consistently more robust than either model alone.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## 🛠️ Tech Stack
|
|
267
|
+
|
|
268
|
+
| Layer | Technology |
|
|
269
|
+
|---|---|
|
|
270
|
+
| Language | Python 3.10+ |
|
|
271
|
+
| Metrics collection | psutil |
|
|
272
|
+
| Local storage | SQLite (built-in) |
|
|
273
|
+
| Forecasting | statsmodels (ARIMA + Holt-Winters) |
|
|
274
|
+
| Data handling | pandas |
|
|
275
|
+
| CLI framework | Typer |
|
|
276
|
+
| Terminal UI | Rich |
|
|
277
|
+
| ASCII charts | plotext |
|
|
278
|
+
| Packaging | setuptools + pyproject.toml |
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 📁 Project Structure
|
|
283
|
+
|
|
284
|
+
```
|
|
285
|
+
foresight/
|
|
286
|
+
├── foresight/
|
|
287
|
+
│ ├── __init__.py
|
|
288
|
+
│ ├── collector.py # psutil metrics collection
|
|
289
|
+
│ ├── storage.py # SQLite database layer
|
|
290
|
+
│ ├── forecaster.py # ARIMA, Holt-Winters, Ensemble, alerting
|
|
291
|
+
│ └── cli.py # Typer CLI — all 8 commands
|
|
292
|
+
├── tests/
|
|
293
|
+
├── data/ # SQLite database (gitignored, created locally)
|
|
294
|
+
├── pyproject.toml
|
|
295
|
+
├── requirements.txt
|
|
296
|
+
├── CONTRIBUTING.md
|
|
297
|
+
├── LICENSE
|
|
298
|
+
└── README.md
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## 🤝 Contributing
|
|
304
|
+
|
|
305
|
+
Contributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) first.
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## 🗺️ Roadmap
|
|
310
|
+
|
|
311
|
+
- [ ] Export forecasts to CSV
|
|
312
|
+
- [ ] Cron job integration for automated collection
|
|
313
|
+
- [ ] Network metrics (bandwidth usage)
|
|
314
|
+
- [ ] Multi-machine support
|
|
315
|
+
- [ ] Weighted ensemble based on historical model accuracy
|
|
316
|
+
- [ ] GitHub Actions CI pipeline
|
|
317
|
+
- [ ] Seasonal detection when sufficient data is available
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## 👨💻 Author
|
|
322
|
+
|
|
323
|
+
Built by **Rishi Garg**
|
|
324
|
+
2nd Year AIML Student, Delhi Technological University
|
|
325
|
+
Member, [AIMS-DTU](https://aimsdtu.in) — AI/ML Society of DTU
|
|
326
|
+
|
|
327
|
+
*Built as a portfolio and learning project with a focus on
|
|
328
|
+
time-series forecasting, system programming, and open-source contribution.*
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## 📄 License
|
|
333
|
+
|
|
334
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
<div align="center">
|
|
339
|
+
|
|
340
|
+
**If this helped you, give it a ⭐ on GitHub**
|
|
341
|
+
|
|
342
|
+
</div>
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# 🔭 Foresight
|
|
4
|
+
|
|
5
|
+
**Predict system resource exhaustion before it happens.**
|
|
6
|
+
|
|
7
|
+
[](https://pypi.org/project/foresight-cli/)
|
|
8
|
+
[](https://www.python.org/)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](https://github.com/TECHSCHOLAR777/foresight)
|
|
11
|
+
[](https://dtu.ac.in)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
*Traditional monitoring tools tell you what **is** happening.*
|
|
16
|
+
*Foresight tells you what **will** happen — before it does.*
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
## 📖 What is Foresight?
|
|
23
|
+
|
|
24
|
+
Foresight is a lightweight, CLI-native system resource forecaster built in Python.
|
|
25
|
+
It collects CPU, RAM, and disk metrics locally, stores them in SQLite, and applies
|
|
26
|
+
time-series ML models (ARIMA, Holt-Winters, Ensemble) to predict resource exhaustion
|
|
27
|
+
**before** it happens.
|
|
28
|
+
|
|
29
|
+
No cloud. No dashboard. No subscription. Just your terminal.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
foresight healthcheck --horizon 1h
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
System Health Check — next 1h via ENSEMBLE
|
|
37
|
+
|
|
38
|
+
✅ cpu_percent OK now: 18.4% threshold: 75.0% trend: stable
|
|
39
|
+
🚨 ram_percent CRITICAL now: 87.4% threshold: 80.0% trend: rising
|
|
40
|
+
✅ disk_percent OK now: 17.4% threshold: 85.0% trend: stable
|
|
41
|
+
|
|
42
|
+
🚨 Overall: CRITICAL
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## ✨ Features
|
|
48
|
+
|
|
49
|
+
| Feature | Description |
|
|
50
|
+
|---|---|
|
|
51
|
+
| **Live Monitor** | Real-time resource usage with color-coded health indicators |
|
|
52
|
+
| **ARIMA Forecasting** | AutoRegressive model for trend-based prediction |
|
|
53
|
+
| **Holt-Winters Forecasting** | Exponential smoothing — weights recent data more heavily |
|
|
54
|
+
| **Ensemble Forecasting** | Blends ARIMA + Holt-Winters for more robust predictions |
|
|
55
|
+
| **Threshold Alerting** | Warns when a metric is predicted to breach safe limits |
|
|
56
|
+
| **Health Check** | Full system overview across all metrics in one command |
|
|
57
|
+
| **ASCII Charts** | Visualize metric history directly in the terminal |
|
|
58
|
+
| **Smart Defaults** | Per-metric health thresholds based on industry standards |
|
|
59
|
+
| **Horizon-based** | Think in time: `--horizon 30m`, `--horizon 1h`, `--horizon 2h` |
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 🚀 Quick Start
|
|
64
|
+
|
|
65
|
+
### Install via pip
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install foresight-cli
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
That's it. The `foresight` command is now available globally.
|
|
72
|
+
|
|
73
|
+
### Collect Data
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Collect 60 snapshots every 60 seconds (1 hour of data)
|
|
77
|
+
foresight collect
|
|
78
|
+
|
|
79
|
+
# Quick test — 10 snapshots every 5 seconds
|
|
80
|
+
foresight collect --rounds 10 --interval 5
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
> ⚠️ **Important:** Forecasting requires historical data. For reliable 30-minute
|
|
84
|
+
> forecasts, collect at least 2-3 hours of data first. The more data, the better
|
|
85
|
+
> the predictions.
|
|
86
|
+
|
|
87
|
+
### Check Your System
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
foresight healthcheck --horizon 30m
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 📋 All Commands
|
|
96
|
+
|
|
97
|
+
### `foresight collect`
|
|
98
|
+
Collect system metrics and save to local SQLite database.
|
|
99
|
+
```bash
|
|
100
|
+
foresight collect # 60 rounds × 60s = 1 hour
|
|
101
|
+
foresight collect --rounds 30 --interval 5 # 30 snapshots every 5 seconds
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### `foresight status`
|
|
105
|
+
Single live snapshot with color-coded health indicators.
|
|
106
|
+
```bash
|
|
107
|
+
foresight status
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### `foresight watch`
|
|
111
|
+
Live refreshing monitor. Clears screen and updates every N seconds.
|
|
112
|
+
```bash
|
|
113
|
+
foresight watch # every 5s, 50 rounds
|
|
114
|
+
foresight watch --interval 2 --rounds 30
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### `foresight show`
|
|
118
|
+
Display recent snapshots as a color-coded formatted table.
|
|
119
|
+
```bash
|
|
120
|
+
foresight show # last 10 snapshots
|
|
121
|
+
foresight show --limit 50 # last 50 snapshots
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### `foresight chart`
|
|
125
|
+
ASCII line chart of any metric rendered directly in the terminal.
|
|
126
|
+
```bash
|
|
127
|
+
foresight chart # default: cpu_percent
|
|
128
|
+
foresight chart --metric ram_percent
|
|
129
|
+
foresight chart --metric disk_percent --limit 100
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Available metrics:** `cpu_percent`, `ram_percent`, `ram_used_mb`, `disk_percent`, `disk_used_gb`
|
|
133
|
+
|
|
134
|
+
### `foresight forecast`
|
|
135
|
+
Forecast future resource usage over a time horizon.
|
|
136
|
+
```bash
|
|
137
|
+
foresight forecast # CPU, 30m, ensemble
|
|
138
|
+
foresight forecast --metric ram_percent --horizon 1h
|
|
139
|
+
foresight forecast --metric cpu_percent --horizon 2h --model arima
|
|
140
|
+
foresight forecast --metric disk_percent --model holtwinters
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Models:**
|
|
144
|
+
- `ensemble` *(default)* — Blends ARIMA + Holt-Winters. Most robust.
|
|
145
|
+
- `arima` — Better for data with clear, consistent trends
|
|
146
|
+
- `holtwinters` — Better when recent data matters more than history
|
|
147
|
+
|
|
148
|
+
### `foresight alert`
|
|
149
|
+
Check if a metric is predicted to breach its health threshold.
|
|
150
|
+
```bash
|
|
151
|
+
foresight alert # CPU, 30m, smart threshold
|
|
152
|
+
foresight alert --metric ram_percent --horizon 1h
|
|
153
|
+
foresight alert --metric cpu_percent --threshold 70 # custom threshold
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### `foresight healthcheck`
|
|
157
|
+
Full system health check across CPU, RAM, and Disk at once.
|
|
158
|
+
```bash
|
|
159
|
+
foresight healthcheck # 30m horizon, ensemble
|
|
160
|
+
foresight healthcheck --horizon 1h
|
|
161
|
+
foresight healthcheck --model arima
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 🎯 Smart Health Thresholds
|
|
167
|
+
|
|
168
|
+
Foresight uses industry-standard thresholds by default:
|
|
169
|
+
|
|
170
|
+
| Metric | Warning | Critical | Reasoning |
|
|
171
|
+
|---|---|---|---|
|
|
172
|
+
| CPU | 75% | 90% | Above 75% sustained → thermal throttling risk |
|
|
173
|
+
| RAM | 80% | 90% | Above 80% → heavy memory swapping begins |
|
|
174
|
+
| Disk | 85% | 95% | Above 85% → write performance degrades |
|
|
175
|
+
|
|
176
|
+
Override any threshold with `--threshold` flag.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 📊 How Much Data Do You Need?
|
|
181
|
+
|
|
182
|
+
| Forecast Horizon | Minimum Snapshots | Recommended |
|
|
183
|
+
|---|---|---|
|
|
184
|
+
| 30 minutes | 30 snapshots | 2–3 hours of data |
|
|
185
|
+
| 1 hour | 60 snapshots | 4–6 hours of data |
|
|
186
|
+
| 2 hours | 120 snapshots | 8–12 hours of data |
|
|
187
|
+
|
|
188
|
+
**Rule of thumb:** Collect at least 3–5× more history than your forecast horizon
|
|
189
|
+
for reliable predictions.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 🧠 How Forecasting Works
|
|
194
|
+
|
|
195
|
+
Foresight uses three time-series forecasting models:
|
|
196
|
+
|
|
197
|
+
**ARIMA (AutoRegressive Integrated Moving Average)**
|
|
198
|
+
Predicts future values based on patterns in past values and past prediction errors.
|
|
199
|
+
Parameters: AR (past values), I (differencing to remove trend), MA (error correction).
|
|
200
|
+
Best for data with a clear, consistent long-term trend.
|
|
201
|
+
|
|
202
|
+
**Holt-Winters Exponential Smoothing**
|
|
203
|
+
Weights recent data more heavily than older data — exponentially decreasing influence.
|
|
204
|
+
The model continuously updates its estimate of level and trend as new data arrives.
|
|
205
|
+
Best for data where recent behaviour matters more than long-term history.
|
|
206
|
+
|
|
207
|
+
**Ensemble (Default)**
|
|
208
|
+
Averages ARIMA and Holt-Winters predictions step by step. Two models with different
|
|
209
|
+
assumptions tend to make different errors — averaging cancels individual mistakes out.
|
|
210
|
+
Consistently more robust than either model alone.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## 🛠️ Tech Stack
|
|
215
|
+
|
|
216
|
+
| Layer | Technology |
|
|
217
|
+
|---|---|
|
|
218
|
+
| Language | Python 3.10+ |
|
|
219
|
+
| Metrics collection | psutil |
|
|
220
|
+
| Local storage | SQLite (built-in) |
|
|
221
|
+
| Forecasting | statsmodels (ARIMA + Holt-Winters) |
|
|
222
|
+
| Data handling | pandas |
|
|
223
|
+
| CLI framework | Typer |
|
|
224
|
+
| Terminal UI | Rich |
|
|
225
|
+
| ASCII charts | plotext |
|
|
226
|
+
| Packaging | setuptools + pyproject.toml |
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## 📁 Project Structure
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
foresight/
|
|
234
|
+
├── foresight/
|
|
235
|
+
│ ├── __init__.py
|
|
236
|
+
│ ├── collector.py # psutil metrics collection
|
|
237
|
+
│ ├── storage.py # SQLite database layer
|
|
238
|
+
│ ├── forecaster.py # ARIMA, Holt-Winters, Ensemble, alerting
|
|
239
|
+
│ └── cli.py # Typer CLI — all 8 commands
|
|
240
|
+
├── tests/
|
|
241
|
+
├── data/ # SQLite database (gitignored, created locally)
|
|
242
|
+
├── pyproject.toml
|
|
243
|
+
├── requirements.txt
|
|
244
|
+
├── CONTRIBUTING.md
|
|
245
|
+
├── LICENSE
|
|
246
|
+
└── README.md
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## 🤝 Contributing
|
|
252
|
+
|
|
253
|
+
Contributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) first.
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## 🗺️ Roadmap
|
|
258
|
+
|
|
259
|
+
- [ ] Export forecasts to CSV
|
|
260
|
+
- [ ] Cron job integration for automated collection
|
|
261
|
+
- [ ] Network metrics (bandwidth usage)
|
|
262
|
+
- [ ] Multi-machine support
|
|
263
|
+
- [ ] Weighted ensemble based on historical model accuracy
|
|
264
|
+
- [ ] GitHub Actions CI pipeline
|
|
265
|
+
- [ ] Seasonal detection when sufficient data is available
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## 👨💻 Author
|
|
270
|
+
|
|
271
|
+
Built by **Rishi Garg**
|
|
272
|
+
2nd Year AIML Student, Delhi Technological University
|
|
273
|
+
Member, [AIMS-DTU](https://aimsdtu.in) — AI/ML Society of DTU
|
|
274
|
+
|
|
275
|
+
*Built as a portfolio and learning project with a focus on
|
|
276
|
+
time-series forecasting, system programming, and open-source contribution.*
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## 📄 License
|
|
281
|
+
|
|
282
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
<div align="center">
|
|
287
|
+
|
|
288
|
+
**If this helped you, give it a ⭐ on GitHub**
|
|
289
|
+
|
|
290
|
+
</div>
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: foresight-cli
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Predict system resource exhaustion before it happens.
|
|
5
|
+
Author: Rishi Garg
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Rishi Garg
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/TECHSCHOLAR777/foresight
|
|
29
|
+
Project-URL: Repository, https://github.com/TECHSCHOLAR777/foresight
|
|
30
|
+
Project-URL: Issues, https://github.com/TECHSCHOLAR777/foresight/issues
|
|
31
|
+
Keywords: cli,monitoring,forecasting,devops,time-series,arima,machine-learning,psutil,system-monitoring,resource-forecasting,holt-winters,ensemble
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Operating System :: OS Independent
|
|
37
|
+
Classifier: Environment :: Console
|
|
38
|
+
Classifier: Topic :: System :: Monitoring
|
|
39
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
40
|
+
Classifier: Intended Audience :: Developers
|
|
41
|
+
Classifier: Intended Audience :: System Administrators
|
|
42
|
+
Requires-Python: >=3.10
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
License-File: LICENSE
|
|
45
|
+
Requires-Dist: psutil>=5.9.0
|
|
46
|
+
Requires-Dist: rich>=13.0.0
|
|
47
|
+
Requires-Dist: typer>=0.9.0
|
|
48
|
+
Requires-Dist: plotext>=5.2.0
|
|
49
|
+
Requires-Dist: pandas>=2.0.0
|
|
50
|
+
Requires-Dist: statsmodels>=0.14.0
|
|
51
|
+
Dynamic: license-file
|
|
52
|
+
|
|
53
|
+
<div align="center">
|
|
54
|
+
|
|
55
|
+
# 🔭 Foresight
|
|
56
|
+
|
|
57
|
+
**Predict system resource exhaustion before it happens.**
|
|
58
|
+
|
|
59
|
+
[](https://pypi.org/project/foresight-cli/)
|
|
60
|
+
[](https://www.python.org/)
|
|
61
|
+
[](LICENSE)
|
|
62
|
+
[](https://github.com/TECHSCHOLAR777/foresight)
|
|
63
|
+
[](https://dtu.ac.in)
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
*Traditional monitoring tools tell you what **is** happening.*
|
|
68
|
+
*Foresight tells you what **will** happen — before it does.*
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
## 📖 What is Foresight?
|
|
75
|
+
|
|
76
|
+
Foresight is a lightweight, CLI-native system resource forecaster built in Python.
|
|
77
|
+
It collects CPU, RAM, and disk metrics locally, stores them in SQLite, and applies
|
|
78
|
+
time-series ML models (ARIMA, Holt-Winters, Ensemble) to predict resource exhaustion
|
|
79
|
+
**before** it happens.
|
|
80
|
+
|
|
81
|
+
No cloud. No dashboard. No subscription. Just your terminal.
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
foresight healthcheck --horizon 1h
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
System Health Check — next 1h via ENSEMBLE
|
|
89
|
+
|
|
90
|
+
✅ cpu_percent OK now: 18.4% threshold: 75.0% trend: stable
|
|
91
|
+
🚨 ram_percent CRITICAL now: 87.4% threshold: 80.0% trend: rising
|
|
92
|
+
✅ disk_percent OK now: 17.4% threshold: 85.0% trend: stable
|
|
93
|
+
|
|
94
|
+
🚨 Overall: CRITICAL
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## ✨ Features
|
|
100
|
+
|
|
101
|
+
| Feature | Description |
|
|
102
|
+
|---|---|
|
|
103
|
+
| **Live Monitor** | Real-time resource usage with color-coded health indicators |
|
|
104
|
+
| **ARIMA Forecasting** | AutoRegressive model for trend-based prediction |
|
|
105
|
+
| **Holt-Winters Forecasting** | Exponential smoothing — weights recent data more heavily |
|
|
106
|
+
| **Ensemble Forecasting** | Blends ARIMA + Holt-Winters for more robust predictions |
|
|
107
|
+
| **Threshold Alerting** | Warns when a metric is predicted to breach safe limits |
|
|
108
|
+
| **Health Check** | Full system overview across all metrics in one command |
|
|
109
|
+
| **ASCII Charts** | Visualize metric history directly in the terminal |
|
|
110
|
+
| **Smart Defaults** | Per-metric health thresholds based on industry standards |
|
|
111
|
+
| **Horizon-based** | Think in time: `--horizon 30m`, `--horizon 1h`, `--horizon 2h` |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 🚀 Quick Start
|
|
116
|
+
|
|
117
|
+
### Install via pip
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
pip install foresight-cli
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
That's it. The `foresight` command is now available globally.
|
|
124
|
+
|
|
125
|
+
### Collect Data
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Collect 60 snapshots every 60 seconds (1 hour of data)
|
|
129
|
+
foresight collect
|
|
130
|
+
|
|
131
|
+
# Quick test — 10 snapshots every 5 seconds
|
|
132
|
+
foresight collect --rounds 10 --interval 5
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
> ⚠️ **Important:** Forecasting requires historical data. For reliable 30-minute
|
|
136
|
+
> forecasts, collect at least 2-3 hours of data first. The more data, the better
|
|
137
|
+
> the predictions.
|
|
138
|
+
|
|
139
|
+
### Check Your System
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
foresight healthcheck --horizon 30m
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 📋 All Commands
|
|
148
|
+
|
|
149
|
+
### `foresight collect`
|
|
150
|
+
Collect system metrics and save to local SQLite database.
|
|
151
|
+
```bash
|
|
152
|
+
foresight collect # 60 rounds × 60s = 1 hour
|
|
153
|
+
foresight collect --rounds 30 --interval 5 # 30 snapshots every 5 seconds
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### `foresight status`
|
|
157
|
+
Single live snapshot with color-coded health indicators.
|
|
158
|
+
```bash
|
|
159
|
+
foresight status
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### `foresight watch`
|
|
163
|
+
Live refreshing monitor. Clears screen and updates every N seconds.
|
|
164
|
+
```bash
|
|
165
|
+
foresight watch # every 5s, 50 rounds
|
|
166
|
+
foresight watch --interval 2 --rounds 30
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### `foresight show`
|
|
170
|
+
Display recent snapshots as a color-coded formatted table.
|
|
171
|
+
```bash
|
|
172
|
+
foresight show # last 10 snapshots
|
|
173
|
+
foresight show --limit 50 # last 50 snapshots
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### `foresight chart`
|
|
177
|
+
ASCII line chart of any metric rendered directly in the terminal.
|
|
178
|
+
```bash
|
|
179
|
+
foresight chart # default: cpu_percent
|
|
180
|
+
foresight chart --metric ram_percent
|
|
181
|
+
foresight chart --metric disk_percent --limit 100
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Available metrics:** `cpu_percent`, `ram_percent`, `ram_used_mb`, `disk_percent`, `disk_used_gb`
|
|
185
|
+
|
|
186
|
+
### `foresight forecast`
|
|
187
|
+
Forecast future resource usage over a time horizon.
|
|
188
|
+
```bash
|
|
189
|
+
foresight forecast # CPU, 30m, ensemble
|
|
190
|
+
foresight forecast --metric ram_percent --horizon 1h
|
|
191
|
+
foresight forecast --metric cpu_percent --horizon 2h --model arima
|
|
192
|
+
foresight forecast --metric disk_percent --model holtwinters
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Models:**
|
|
196
|
+
- `ensemble` *(default)* — Blends ARIMA + Holt-Winters. Most robust.
|
|
197
|
+
- `arima` — Better for data with clear, consistent trends
|
|
198
|
+
- `holtwinters` — Better when recent data matters more than history
|
|
199
|
+
|
|
200
|
+
### `foresight alert`
|
|
201
|
+
Check if a metric is predicted to breach its health threshold.
|
|
202
|
+
```bash
|
|
203
|
+
foresight alert # CPU, 30m, smart threshold
|
|
204
|
+
foresight alert --metric ram_percent --horizon 1h
|
|
205
|
+
foresight alert --metric cpu_percent --threshold 70 # custom threshold
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### `foresight healthcheck`
|
|
209
|
+
Full system health check across CPU, RAM, and Disk at once.
|
|
210
|
+
```bash
|
|
211
|
+
foresight healthcheck # 30m horizon, ensemble
|
|
212
|
+
foresight healthcheck --horizon 1h
|
|
213
|
+
foresight healthcheck --model arima
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 🎯 Smart Health Thresholds
|
|
219
|
+
|
|
220
|
+
Foresight uses industry-standard thresholds by default:
|
|
221
|
+
|
|
222
|
+
| Metric | Warning | Critical | Reasoning |
|
|
223
|
+
|---|---|---|---|
|
|
224
|
+
| CPU | 75% | 90% | Above 75% sustained → thermal throttling risk |
|
|
225
|
+
| RAM | 80% | 90% | Above 80% → heavy memory swapping begins |
|
|
226
|
+
| Disk | 85% | 95% | Above 85% → write performance degrades |
|
|
227
|
+
|
|
228
|
+
Override any threshold with `--threshold` flag.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## 📊 How Much Data Do You Need?
|
|
233
|
+
|
|
234
|
+
| Forecast Horizon | Minimum Snapshots | Recommended |
|
|
235
|
+
|---|---|---|
|
|
236
|
+
| 30 minutes | 30 snapshots | 2–3 hours of data |
|
|
237
|
+
| 1 hour | 60 snapshots | 4–6 hours of data |
|
|
238
|
+
| 2 hours | 120 snapshots | 8–12 hours of data |
|
|
239
|
+
|
|
240
|
+
**Rule of thumb:** Collect at least 3–5× more history than your forecast horizon
|
|
241
|
+
for reliable predictions.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## 🧠 How Forecasting Works
|
|
246
|
+
|
|
247
|
+
Foresight uses three time-series forecasting models:
|
|
248
|
+
|
|
249
|
+
**ARIMA (AutoRegressive Integrated Moving Average)**
|
|
250
|
+
Predicts future values based on patterns in past values and past prediction errors.
|
|
251
|
+
Parameters: AR (past values), I (differencing to remove trend), MA (error correction).
|
|
252
|
+
Best for data with a clear, consistent long-term trend.
|
|
253
|
+
|
|
254
|
+
**Holt-Winters Exponential Smoothing**
|
|
255
|
+
Weights recent data more heavily than older data — exponentially decreasing influence.
|
|
256
|
+
The model continuously updates its estimate of level and trend as new data arrives.
|
|
257
|
+
Best for data where recent behaviour matters more than long-term history.
|
|
258
|
+
|
|
259
|
+
**Ensemble (Default)**
|
|
260
|
+
Averages ARIMA and Holt-Winters predictions step by step. Two models with different
|
|
261
|
+
assumptions tend to make different errors — averaging cancels individual mistakes out.
|
|
262
|
+
Consistently more robust than either model alone.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## 🛠️ Tech Stack
|
|
267
|
+
|
|
268
|
+
| Layer | Technology |
|
|
269
|
+
|---|---|
|
|
270
|
+
| Language | Python 3.10+ |
|
|
271
|
+
| Metrics collection | psutil |
|
|
272
|
+
| Local storage | SQLite (built-in) |
|
|
273
|
+
| Forecasting | statsmodels (ARIMA + Holt-Winters) |
|
|
274
|
+
| Data handling | pandas |
|
|
275
|
+
| CLI framework | Typer |
|
|
276
|
+
| Terminal UI | Rich |
|
|
277
|
+
| ASCII charts | plotext |
|
|
278
|
+
| Packaging | setuptools + pyproject.toml |
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 📁 Project Structure
|
|
283
|
+
|
|
284
|
+
```
|
|
285
|
+
foresight/
|
|
286
|
+
├── foresight/
|
|
287
|
+
│ ├── __init__.py
|
|
288
|
+
│ ├── collector.py # psutil metrics collection
|
|
289
|
+
│ ├── storage.py # SQLite database layer
|
|
290
|
+
│ ├── forecaster.py # ARIMA, Holt-Winters, Ensemble, alerting
|
|
291
|
+
│ └── cli.py # Typer CLI — all 8 commands
|
|
292
|
+
├── tests/
|
|
293
|
+
├── data/ # SQLite database (gitignored, created locally)
|
|
294
|
+
├── pyproject.toml
|
|
295
|
+
├── requirements.txt
|
|
296
|
+
├── CONTRIBUTING.md
|
|
297
|
+
├── LICENSE
|
|
298
|
+
└── README.md
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## 🤝 Contributing
|
|
304
|
+
|
|
305
|
+
Contributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) first.
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## 🗺️ Roadmap
|
|
310
|
+
|
|
311
|
+
- [ ] Export forecasts to CSV
|
|
312
|
+
- [ ] Cron job integration for automated collection
|
|
313
|
+
- [ ] Network metrics (bandwidth usage)
|
|
314
|
+
- [ ] Multi-machine support
|
|
315
|
+
- [ ] Weighted ensemble based on historical model accuracy
|
|
316
|
+
- [ ] GitHub Actions CI pipeline
|
|
317
|
+
- [ ] Seasonal detection when sufficient data is available
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## 👨💻 Author
|
|
322
|
+
|
|
323
|
+
Built by **Rishi Garg**
|
|
324
|
+
2nd Year AIML Student, Delhi Technological University
|
|
325
|
+
Member, [AIMS-DTU](https://aimsdtu.in) — AI/ML Society of DTU
|
|
326
|
+
|
|
327
|
+
*Built as a portfolio and learning project with a focus on
|
|
328
|
+
time-series forecasting, system programming, and open-source contribution.*
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## 📄 License
|
|
333
|
+
|
|
334
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
<div align="center">
|
|
339
|
+
|
|
340
|
+
**If this helped you, give it a ⭐ on GitHub**
|
|
341
|
+
|
|
342
|
+
</div>
|
|
@@ -1,51 +1,60 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=65", "wheel"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=65", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "foresight-cli"
|
|
7
|
+
version = "0.1.2"
|
|
8
|
+
description = "Predict system resource exhaustion before it happens."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Rishi Garg" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"cli",
|
|
17
|
+
"monitoring",
|
|
18
|
+
"forecasting",
|
|
19
|
+
"devops",
|
|
20
|
+
"time-series",
|
|
21
|
+
"arima",
|
|
22
|
+
"machine-learning",
|
|
23
|
+
"psutil",
|
|
24
|
+
"system-monitoring",
|
|
25
|
+
"resource-forecasting",
|
|
26
|
+
"holt-winters",
|
|
27
|
+
"ensemble",
|
|
28
|
+
]
|
|
29
|
+
classifiers = [
|
|
30
|
+
"Programming Language :: Python :: 3.10",
|
|
31
|
+
"Programming Language :: Python :: 3.11",
|
|
32
|
+
"Programming Language :: Python :: 3.12",
|
|
33
|
+
"License :: OSI Approved :: MIT License",
|
|
34
|
+
"Operating System :: OS Independent",
|
|
35
|
+
"Environment :: Console",
|
|
36
|
+
"Topic :: System :: Monitoring",
|
|
37
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
38
|
+
"Intended Audience :: Developers",
|
|
39
|
+
"Intended Audience :: System Administrators",
|
|
40
|
+
]
|
|
41
|
+
dependencies = [
|
|
42
|
+
"psutil>=5.9.0",
|
|
43
|
+
"rich>=13.0.0",
|
|
44
|
+
"typer>=0.9.0",
|
|
45
|
+
"plotext>=5.2.0",
|
|
46
|
+
"pandas>=2.0.0",
|
|
47
|
+
"statsmodels>=0.14.0",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
Homepage = "https://github.com/TECHSCHOLAR777/foresight"
|
|
52
|
+
Repository = "https://github.com/TECHSCHOLAR777/foresight"
|
|
53
|
+
Issues = "https://github.com/TECHSCHOLAR777/foresight/issues"
|
|
54
|
+
|
|
55
|
+
[project.scripts]
|
|
56
|
+
foresight = "foresight.cli:app"
|
|
57
|
+
|
|
58
|
+
[tool.setuptools.packages.find]
|
|
59
|
+
where = ["."]
|
|
60
|
+
include = ["foresight*"]
|
foresight_cli-0.1.0/PKG-INFO
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: foresight-cli
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: Predict system resource exhaustion before it happens.
|
|
5
|
-
Author: Rishi Garg
|
|
6
|
-
Project-URL: Homepage, https://github.com/YOUR_USERNAME/foresight
|
|
7
|
-
Project-URL: Repository, https://github.com/YOUR_USERNAME/foresight
|
|
8
|
-
Project-URL: Issues, https://github.com/YOUR_USERNAME/foresight/issues
|
|
9
|
-
Keywords: cli,monitoring,forecasting,devops,time-series,arima,machine-learning,psutil,system-monitoring
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
-
Classifier: Operating System :: OS Independent
|
|
15
|
-
Classifier: Environment :: Console
|
|
16
|
-
Classifier: Topic :: System :: Monitoring
|
|
17
|
-
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
-
Classifier: Intended Audience :: Developers
|
|
19
|
-
Classifier: Intended Audience :: System Administrators
|
|
20
|
-
Requires-Python: >=3.10
|
|
21
|
-
Description-Content-Type: text/markdown
|
|
22
|
-
Requires-Dist: psutil>=5.9.0
|
|
23
|
-
Requires-Dist: rich>=13.0.0
|
|
24
|
-
Requires-Dist: typer>=0.9.0
|
|
25
|
-
Requires-Dist: plotext>=5.2.0
|
|
26
|
-
Requires-Dist: pandas>=2.0.0
|
|
27
|
-
Requires-Dist: statsmodels>=0.14.0
|
foresight_cli-0.1.0/README.md
DELETED
|
File without changes
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: foresight-cli
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: Predict system resource exhaustion before it happens.
|
|
5
|
-
Author: Rishi Garg
|
|
6
|
-
Project-URL: Homepage, https://github.com/YOUR_USERNAME/foresight
|
|
7
|
-
Project-URL: Repository, https://github.com/YOUR_USERNAME/foresight
|
|
8
|
-
Project-URL: Issues, https://github.com/YOUR_USERNAME/foresight/issues
|
|
9
|
-
Keywords: cli,monitoring,forecasting,devops,time-series,arima,machine-learning,psutil,system-monitoring
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
-
Classifier: Operating System :: OS Independent
|
|
15
|
-
Classifier: Environment :: Console
|
|
16
|
-
Classifier: Topic :: System :: Monitoring
|
|
17
|
-
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
-
Classifier: Intended Audience :: Developers
|
|
19
|
-
Classifier: Intended Audience :: System Administrators
|
|
20
|
-
Requires-Python: >=3.10
|
|
21
|
-
Description-Content-Type: text/markdown
|
|
22
|
-
Requires-Dist: psutil>=5.9.0
|
|
23
|
-
Requires-Dist: rich>=13.0.0
|
|
24
|
-
Requires-Dist: typer>=0.9.0
|
|
25
|
-
Requires-Dist: plotext>=5.2.0
|
|
26
|
-
Requires-Dist: pandas>=2.0.0
|
|
27
|
-
Requires-Dist: statsmodels>=0.14.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|