163 lines
3.5 KiB
Plaintext
163 lines
3.5 KiB
Plaintext
# 🚀 Integrasi MikroTik MCP dengan Gemini AI
|
|
|
|
## 📋 **Daftar Isi**
|
|
1. [Overview](#overview)
|
|
2. [Prerequisites](#prerequisites)
|
|
3. [Struktur File](#struktur-file)
|
|
4. [Instalasi Cepat](#instalasi-cepat)
|
|
5. [Penggunaan](#penggunaan)
|
|
6. [Deployment](#deployment)
|
|
7. [Contoh Penggunaan](#contoh-penggunaan)
|
|
8. [Troubleshooting](#troubleshooting)
|
|
|
|
## 🔍 **Overview**
|
|
|
|
Integrasi ini memungkinkan Anda bertanya tentang perangkat MikroTik menggunakan **Google Gemini AI** dengan konteks data real-time dari perangkat.
|
|
|
|
**Fitur Utama:**
|
|
- ✅ Query natural language tentang MikroTik
|
|
- ✅ Context-aware responses
|
|
- ✅ Real-time monitoring
|
|
- ✅ Web API interface
|
|
- ✅ Docker deployment
|
|
- ✅ Optimized token usage
|
|
|
|
## 📦 **Prerequisites**
|
|
|
|
### **1. Google Cloud Account**
|
|
- API Key Gemini dari [Google AI Studio](https://makersuite.google.com/app/apikey)
|
|
|
|
### **2. Python 3.11+**
|
|
```bash
|
|
python --version
|
|
```
|
|
|
|
### **3. MikroTik Data**
|
|
File: `mikrotik_mcp_data.json` (sudah ada di project)
|
|
|
|
## 📁 **Struktur File**
|
|
|
|
```
|
|
gemini_integration/
|
|
├── README.md # File ini
|
|
├── gemini_mikrotik_integration.py # Script utama
|
|
├── api_server.py # FastAPI server
|
|
├── realtime_monitor.py # Monitoring real-time
|
|
├── context_optimizer.py # Optimasi context
|
|
├── requirements.txt # Dependencies
|
|
├── docker-compose.yml # Docker deployment
|
|
├── nginx.conf # Nginx config
|
|
├── example_prompts.md # Contoh prompt
|
|
├── .env.example # Template environment
|
|
└── config.yaml # Konfigurasi
|
|
```
|
|
|
|
## ⚡ **Instalasi Cepat**
|
|
|
|
### **Step 1: Setup Environment**
|
|
```bash
|
|
cd /a0/usr/projects/project_1/gemini_integration
|
|
|
|
# Copy environment template
|
|
cp .env.example .env
|
|
|
|
# Edit .env dengan API key Anda
|
|
nano .env
|
|
```
|
|
|
|
### **Step 2: Install Dependencies**
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
### **Step 3: Test Integration**
|
|
```bash
|
|
python gemini_mikrotik_integration.py
|
|
```
|
|
|
|
## 🎯 **Penggunaan**
|
|
|
|
### **1. Interactive Chat**
|
|
```bash
|
|
python gemini_mikrotik_integration.py
|
|
```
|
|
|
|
### **2. Web API**
|
|
```bash
|
|
python api_server.py
|
|
# Akses: http://localhost:8000/docs
|
|
```
|
|
|
|
### **3. Real-time Monitoring**
|
|
```bash
|
|
python realtime_monitor.py
|
|
```
|
|
|
|
## 🐳 **Deployment dengan Docker**
|
|
|
|
### **Build dan Run**
|
|
```bash
|
|
docker-compose up -d
|
|
```
|
|
|
|
### **Check Status**
|
|
```bash
|
|
docker-compose ps
|
|
curl http://localhost:8000/health
|
|
```
|
|
|
|
## 💡 **Contoh Penggunaan**
|
|
|
|
### **Via Python Script**
|
|
```python
|
|
from gemini_mikrotik_integration import MikroTikGeminiAssistant
|
|
|
|
assistant = MikroTikGeminiAssistant()
|
|
answer = assistant.ask_question("Berapa CPU usage router?")
|
|
print(answer)
|
|
```
|
|
|
|
### **Via API**
|
|
```bash
|
|
curl -X POST http://localhost:8000/ask \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"question": "Ada berapa interface yang running?"}'
|
|
```
|
|
|
|
## 🔧 **Troubleshooting**
|
|
|
|
### **Error: API Key Invalid**
|
|
```bash
|
|
# Periksa .env file
|
|
cat .env | grep GEMINI_API_KEY
|
|
```
|
|
|
|
### **Error: MikroTik Data Not Found**
|
|
```bash
|
|
# Pastikan file data ada
|
|
ls -la ../mikrotik_mcp_data.json
|
|
```
|
|
|
|
### **Error: Port Already in Use**
|
|
```bash
|
|
# Ganti port di api_server.py atau kill process
|
|
lsof -i :8000
|
|
kill -9 <PID>
|
|
```
|
|
|
|
## 📞 **Support**
|
|
|
|
- **Issues**: Check error logs
|
|
- **Questions**: Lihat example_prompts.md
|
|
- **Updates**: Pantau perubahan API Gemini
|
|
|
|
## 📄 **License**
|
|
|
|
MIT License - Bebas digunakan untuk keperluan apapun.
|
|
|
|
---
|
|
|
|
**Dibuat oleh:** Agent Zero AI Assistant
|
|
**Tanggal:** 2026-01-20
|
|
**Versi:** 1.0.0
|