Metadata-Version: 2.4
Name: isptools-pro
Version: 3.0.0
Summary: Python library for ISP network management - MikroTik, Ubiquiti NanoStation, Cisco, SNMP
Home-page: https://github.com/alexiq01/IspTool
Author: devyassin01
Author-email: devyassin01 <developeryassin01@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/alexiq01/IspTool
Project-URL: Repository, https://github.com/alexiq01/IspTool
Project-URL: Bug Tracker, https://github.com/alexiq01/IspTool/issues
Project-URL: Instagram, https://instagram.com/y_as.01
Keywords: networking,isp,mikrotik,ubiquiti,nanostation,snmp,cisco,network-management
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: System Administrators
Classifier: Topic :: System :: Networking :: Monitoring
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: routeros-api>=0.17.0
Requires-Dist: requests>=2.28.0
Requires-Dist: urllib3>=1.26.0
Requires-Dist: netmiko>=4.0.0
Requires-Dist: pysnmp>=4.4.12
Requires-Dist: click>=8.1.0
Requires-Dist: tabulate>=0.9.0
Provides-Extra: telegram
Requires-Dist: requests>=2.28.0; extra == "telegram"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# isptools 🌐 (v3.0.0)

[![PyPI version](https://img.shields.io/pypi/v/isptools)](https://pypi.org/project/isptools/)
[![Python versions](https://img.shields.io/pypi/pyversions/isptools)](https://pypi.org/project/isptools/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

---

### 🌍 (Arabic / العربية)

**isptools** هي مكتبة Python احترافية وأداة سطر أوامر (CLI) متكاملة مصممة خصيصاً لمهندسي الشبكات وفنيي مزودي خدمات الإنترنت (ISPs).

#### ❓ ما هي أداة isptools؟
هي أداة شاملة لإدارة أجهزة الشبكة من شركات مختلفة مثل **MikroTik**, **Ubiquiti**, **Cisco**, و أجهزة **SNMP** عبر واجهة موحدة.

#### ⚙️ كيف تعمل الأداة؟
1. **الاتصال الموحد:** تستخدم بروتوكولات (SSH, HTTP, API) للوصول للأجهزة.
2. **التحليل:** تحول البيانات المعقدة إلى تقارير بسيطة.
3. **الإصلاح التلقائي (AutoFix):** تكتشف المشاكل (مثل ضعف الإشارة) وتعالجها تلقائياً.
4. **رسم الخرائط:** ترسم خريطة الشبكة (Topology) آلياً.

#### 👨‍💻 المطور
تم التطوير بواسطة **ياسين طه (devyassin01)**.
- **GitHub:** [devyassin01](https://github.com/alexiq01)
- **Instagram:** [@y_as.01](https://instagram.com/y_as.01)

#### 💻 الأنظمة المدعومة
تعمل على: **Linux**, **Windows**, **macOS**, و **Android (Termux)**.

---

### 🌎 (English / الإنجليزية)

**isptools** is a professional Python library and CLI tool designed specifically for network engineers and ISP technicians.

#### ❓ What is isptools?
It is a comprehensive tool for managing network equipment from multiple vendors like **MikroTik**, **Ubiquiti**, **Cisco**, and **SNMP** devices through a unified interface.

#### ⚙️ How does it work?
1. **Unified Connection:** Uses standard protocols (SSH, HTTP, API) to access devices.
2. **Analysis:** Converts complex data into simple, readable reports.
3. **Self-Healing (AutoFix):** Detects issues (like low signal) and fixes them automatically.
4. **Topology Mapping:** Automatically maps the network structure.

#### 👨‍💻 Developer
Developed by **Yassin Taha (devyassin01)**.
- **GitHub:** [devyassin01](https://github.com/alexiq01)
- **Instagram:** [@y_as.01](https://instagram.com/y_as.01)

#### 💻 Supported Systems
Runs on: **Linux**, **Windows**, **macOS**, and **Android (Termux)**.

---


## Features
- **Unified API:** One library to talk to multiple vendor platforms.
- **MikroTik:** Full support via RouterOS API.
- **Ubiquiti NanoStation:** Deep integration with airOS 6.x/8.x (Auto-detection, Link Quality, Spectrum Scan).
- **Cisco:** Command execution via SSH (Netmiko).
- **SNMP:** Generic monitoring support (v1, v2c, v3).
- **CLI Tool:** Powerful `isptools` command for terminal-based management.
- **Monitoring:** Built-in asynchronous poller for concurrent device monitoring.
- **Alerting:** Flexible alert manager with threshold-based rules.

## Installation
```bash
pip install isptools
```

## CLI Usage
The library comes with a powerful CLI tool:
```bash
# Scan a device for full info
isptools scan --host 192.168.1.20 --user admin --password pass --type ubiquiti

# List connected clients
isptools clients --host 192.168.1.1 --user admin --password pass --type mikrotik

# Live monitor stats
isptools monitor --host 10.0.0.1 --user ubnt --password ubnt --type ubiquiti --interval 2
```

## Quick Start (Python API)

### Basic Usage
```python
from isptools import ISPTools, Device

# Initialize
isp = ISPTools()

# Add a MikroTik device
isp.add_device(Device(
    host="192.168.88.1", 
    username="admin", 
    password="password", 
    device_type="mikrotik"
))

# Connect and get stats
isp.connect_all()
stats = isp.get_stats("192.168.88.1")
print(f"CPU Load: {stats.cpu_load}%")
```

### Advanced NanoStation Support
```python
from isptools import ISPTools, Device

isp = ISPTools()
isp.add_device(Device(host="192.168.1.20", username="ubnt", password="ubnt", device_type="ubiquiti"))
isp.connect_all()

driver = isp.devices["192.168.1.20"]
quality = driver.get_link_quality()
print(f"Link Quality Score: {quality['score']}/100 ({quality['level']})")

# Run spectrum scan
# results = driver.scan_spectrum()
```

## Advanced Features

### AutoFix (Self-Healing)
Automatically detect and repair common network issues with a permission-based system.
```python
from isptools import ISPTools, Device, PermissionManager, PermissionLevel, AutoFixEngine

pm = PermissionManager(level=PermissionLevel.SAFE_FIX, require_confirm=True)
engine = AutoFixEngine(pm)

isp = ISPTools()
# ... add devices ...
stats = isp.get_stats("192.168.1.20")
results = engine.apply_fixes(isp.devices["192.168.1.20"], stats.__dict__)
```

### Network Topology Mapping
Discover how your devices are connected and export the graph.
```python
from isptools import TopologyMapper, TopologyExporter

mapper = TopologyMapper(list(isp.devices.values()))
graph = mapper.discover()
print(TopologyExporter.to_mermaid(graph))
```

### Reports & History
Track bandwidth and performance over time using SQLite.
```python
from isptools import StatsCollector, Reporter

collector = StatsCollector()
reporter = Reporter(collector)

# After some polling...
reporter.export_html("192.168.1.1", hours=24, output_path="daily_report.html")
```

### Telegram Alerts
Get notified of issues directly on your phone.
```python
from isptools import TelegramNotifier

tg = TelegramNotifier(bot_token="YOUR_TOKEN", chat_id="YOUR_ID")
tg.send_alert("192.168.1.20", "Signal dropped to -85 dBm", "Increased TX power ✅")
```

## API Reference

### `Device` Dataclass
| Field | Type | Description |
|-------|------|-------------|
| `host` | `str` | IP address or hostname |
| `username`| `str` | Login username |
| `password`| `str` | Login password |
| `device_type`| `str` | `mikrotik`, `ubiquiti`, `cisco`, `snmp` |
| `port` | `int` | Optional override port |

### `ISPTools` Class Methods
- `add_device(device: Device)`: Register a device.
- `connect_all()`: Establish connections to all devices.
- `get_stats(host: str) -> DeviceStats`: Fetch performance metrics.
- `get_clients(host: str) -> List[Station]`: List connected clients.
- `start_monitor(interval: int)`: Start async background polling.
- `stop_monitor()`: Stop polling.

## Publishing
To publish a new version to PyPI:
1. Update version in `isptools/version.py`.
2. Commit changes and push.
3. Create a git tag:
```bash
git tag -a v3.0.0 -m "Release version 3.0.0"
git push origin v3.0.0
```
GitHub Actions will automatically build and publish to PyPI.

---

## 👨‍💻 Developer

**isptools** was developed by **Yassin Taha**

[

![Instagram](https://img.shields.io/badge/Instagram-%40y__as.01-E4405F?style=flat&logo=instagram&logoColor=white)

](https://instagram.com/y_as.01)
[

![GitHub](https://img.shields.io/badge/GitHub-devyassin01-181717?style=flat&logo=github&logoColor=white)

](https://github.com/alexiq01)

> Built with ❤️ for ISP engineers and network technicians.

## License
MIT
