CogniOS is a lightweight, self-contained system telemetry monitor and workload optimization platform written in Python. It provides high-concurrency performance metrics logging, Isolation Forest anomaly detection, neural network-based workload classification, and process priority adjustments with safety fallbacks for sandboxed environments.
The project is built using Test-Driven Development (TDD) and features a dynamic dark-themed dashboard.
/cognios
├── /src
│ ├── __init__.py
│ ├── database.py # Thread-safe SQLite connection manager (WAL mode)
│ ├── telemetry.py # Real-time telemetry loop & stateful OS simulation
│ ├── os_doctor.py # Isolation Forest anomaly detection classifier
│ ├── focus_os.py # PyTorch CNN workload classifier & process prioritizer
│ ├── blackbox.py # Historical logs database cleanup & CSV exporter
│ ├── research.py # FCFS vs SJF waiting time and RL scheduler simulator
│ └── ui.py # Streamlit graphical dashboard
├── /tests
│ └── test_all.py # Pytest suite verifying all core modules
├── requirements.txt # Project dependencies
└── main.py # Platform orchestrator (starts daemons and UI)
- Non-Blocking Telemetry DB: Uses SQLite configured with Write-Ahead Logging (
WALmode) and aNORMALsynchronous profile. This setup supports concurrent, thread-safe writes from the telemetry collector while Streamlit and the ML diagnostic modules continuously read the data. - Stateful System Simulator: When real OS metrics are restricted, the telemetry engine runs a state machine mimicking transitions between
'idle'operations and heavy'spike'workloads (e.g. active code compilation) with realistic random-walk momentum and slow-drifting disk allocation. - ML Diagnostics (OS Doctor): An unsupervised
IsolationForestcontinuously trains on active telemetry to distinguish between healthy baselines and high-intensity resource spikes. - Workload Classification & Nice Control (FocusOS):
- Features a PyTorch Convolutional Neural Network (
WorkloadCNN) that maps multi-channel temporal metric windows(channels=3, time_steps=10, features=5)to active execution states. - Contains a
nicevalue scheduler with automatedpsutil.AccessDeniedexception handling to safely mock optimizations in sandboxed or non-sudo setups.
- Features a PyTorch Convolutional Neural Network (
- Scheduling Simulator: Evaluates queue waiting times across First Come First Serve (FCFS), mathematically optimal Shortest Job First (SJF), and simulated Reinforcement Learning (RL) scheduling policies.
- Python 3.10+ (Tested on Python 3.14)
- Virtual environment tools (
venv)
-
Clone the repository and navigate to the project directory:
cd CogniOS -
Initialize and activate a virtual environment:
python3 -m venv .venv source .venv/bin/activate -
Install dependencies:
pip install -r cognios/requirements.txt
To start the unified platform (starts the telemetry daemon, anomaly monitor, and the graphical Streamlit dashboard):
python cognios/main.pyOnce running, access the interactive dashboard at: 👉 http://localhost:8501
The platform includes a comprehensive pytest suite covering telemetry capture, ML diagnostics, neural net tensor passes, SQLite concurrent writes, database pruning, and UI integration.
To run the complete test suite:
pytest cognios/tests/test_all.py -vgraph TD
A[main.py: Platform Orchestrator] --> B[telemetry.py: Telemetry Daemon]
A --> C[os_doctor.py: ML Anomaly Detector]
A --> D[ui.py: Streamlit Dashboard Subprocess]
B -->|Batch Insert (psutil/mock)| E[(cognios.db: SQLite WAL)]
C -->|Train / Read| E
D -->|Plot / Read| E
subgraph "Workload Optimization"
F[focus_os.py: WorkloadCNN]
G[focus_os.py: Process Prioritizer]
end
subgraph "Logs & Cleanup"
H[blackbox.py: DB Purge & CSV Exporter]
end
subgraph "Scheduler Research"
I[research.py: FCFS vs SJF vs RL Simulator]
end