Scan System
Connectivity scan ka step-by-step technical flow
Scan Trigger Karne Ke Tarike
1. Manual
Dashboard > Routers > Connectivity > Run Connectivity Scan button
2. Scheduler
Dashboard > Routers > Scheduler — automatic intervals set karo (e.g., har 5 minute)
3. Worker Jobs
Backend worker automatically scheduled scans run karta hai background mein
Scan Execution Flow
diagram
SCAN START
|
▼
[1] Select Routers
├── All active? (onlyActive = true)
└── Specific router? (routerId filter)
|
▼
[2] For Each Router:
|
├── [2a] Bridge Status Check
│ ├── ONLINE? → Continue
│ └── OFFLINE? → Mark UNREACHABLE, skip
|
├── [2b] Fetch Active Sessions
│ Bridge Agent → Router API (/ppp/active/getall)
│ Returns: [{username, address, uptime}]
|
├── [2c] Compare with DB Subscribers
│ MATCH? → ONLINE
│ NO MATCH? → miss_count + 1
|
└── [2d] Evaluate Miss Count
miss_count < threshold(2) → wait
miss_count >= threshold → OFFLINE_ROUTER
|
▼
[3] Generate Events
├── New OFFLINE → event: offline_detected
└── Was OFFLINE, now ONLINE → event: recovered_online
|
▼
[4] Queue WhatsApp Notifications
├── Template find karo
├── Cooldown check (4 hours)
├── Variables replace karo
└── Queue to dispatch worker
|
▼
[5] Update Database + WebSocket emit
|
▼
SCAN COMPLETE → Summary returnRouter Unreachable Guard
Agar ek scan mein bahut sare users "offline" dikhein (50%+), toh shayad router ki problem ho — users actually offline nahi. Guard is se bachata hai:
logic
IF offline_count / total_tracked > 0.50 (50%)
THEN:
Mark router as ROUTER_UNREACHABLE
No individual offline_detected events
No WhatsApp notifications
Wait for next scanQueue Mode vs Direct Mode
| Mode | Description | Best For |
|---|---|---|
| Queued (recommended) | Scan background worker queue mein jaata hai | Production use |
| Direct | Scan immediately is request mein run hota hai | Testing/debug |
Scan Summary — Kaise Samjhein?
| Badge | Matlab |
|---|---|
| Scan HealthyHealthy | 0 offline, 0 failed, routers processed |
| Scan UpdateUpdate | Kuch offline ya issues hain |
| offlineRows=5 | Currently offline subscribers count |
| eventRows=8 | Events generated |
| dispatchRows=3 | Notifications queued |
| restartGraceRouters=1 | Routers in restart grace period |