Python SENDER scriptleri — REST uç noktaları
Collector API, ağ toplayıcı scriptlerinin veritabanına yazması içindir. Tüm yanıtlar JSON; POST gövdeleri application/json olmalıdır.
Base URL:
Örnek tam yol: https://switchero.net/api/v1/collector/ip-log
Her istekte Bearer token zorunludur.
Authorization: Bearer YOUR_64_CHAR_TOKEN
Content-Type: application/json
Alternatif: X-Api-Token: YOUR_TOKEN
Her istekte tenant şirket kodu gönderilmelidir (ör. RHBLK). Sunucu otomatik atama yapmaz.
| Method | Nerede? | Örnek |
|---|---|---|
| POST | JSON gövdesi | "company": "RHBLK" |
| GET | Query parametresi | ?company=RHBLK |
Python: COLLECTOR_COMPANY in config.py — api_payload() / api_params().
| Script | Method | Endpoint |
|---|---|---|
| switch_active_checker_services.py | GET | /cleanup |
| switch_active_checker_services.py | GET | /ip-log/clear |
| switch_active_checker_services.py | POST | /ip-log |
| switch_fan_checker_services.py | GET | /fan-log/clear |
| switch_fan_checker_services.py | POST | /fan-status |
| switch_auto_save_config_services.py | POST | /switch-config |
| switch_info_collector_services.py | POST | /switch-info, /switch-interface |
| switch_mac_checker_services.py | POST | /switch-lldp |
| makos.py | POST | /switch-mac |
GET https://switchero.net/api/v1/collector/cleanup?company=RHBLK
İlgili şirketin closed_ips kayıtlarında alert_rate < 6 olanları siler.
GET https://switchero.net/api/v1/collector/ip-log/clear?company=RHBLK
Sadece o şirketin ip_status_log kayıtlarını siler.
POST https://switchero.net/api/v1/collector/ip-log
{
"company": "RHBLK",
"ips": [
{ "ip": "10.0.0.1", "status": "AKTIF" },
{ "ip": "10.0.0.2", "status": "KAPALI" }
]
}
status: AKTIF veya KAPALI
GET https://switchero.net/api/v1/collector/fan-log/clear?company=RHBLK
POST https://switchero.net/api/v1/collector/fan-status
{
"company": "RHBLK",
"fans": [
{ "ip": "10.0.0.1", "fan_status": "Normal", "temperature": "42C" }
]
}
POST https://switchero.net/api/v1/collector/switch-config
{
"company": "RHBLK",
"ip_address": "10.0.0.1",
"config_data": "...",
"config_type": "running"
}
POST https://switchero.net/api/v1/collector/switch-info
{ "company": "RHBLK", "ip", "description", "uptime", "name", "mac_address" }
POST https://switchero.net/api/v1/collector/switch-interface
{ "company": "RHBLK", "ip", "interface_name", "admin_status", "oper_status", "speed" }
POST https://switchero.net/api/v1/collector/switch-lldp
Zorunlu: company, switch_ip, local_port, remote_chassis_id, remote_port_id, remote_sys_name
POST https://switchero.net/api/v1/collector/switch-mac
Zorunlu: company, switch_ip, port, mac_address
Tüm SENDER scriptleri api/SENDER/config.py üzerinden v1 yollarını kullanır.
from config import api_headers, api_url, api_params, api_payload
import requests
# GET — sadece RHBLK loglarını temizle
response = requests.get(
api_url("clear_ip_log"),
headers=api_headers(),
params=api_params(), # {"company": "RHBLK"}
timeout=60,
)
# POST — company zorunlu
response = requests.post(
api_url("save_all_ips"),
json=api_payload({
"ips": [
{"ip": "10.0.0.1", "status": "AKTIF"},
],
}),
headers=api_headers(),
timeout=120,
)
| HTTP | Anlam |
|---|---|
| 401 | Token eksik veya geçersiz |
| 404 | Geçersiz yol (eski .php uçları desteklenmez) |
| 400 | company eksik veya hatalı gövde |
| 500 | Sunucu hatası |
/api/switch-history vb. collector token ile karıştırılmamalıdır.