require('dotenv').config(); const mikrotik = require('./services/mikrotikService'); async function testBroadcastSearch(interfaceName) { console.log(`[Test] Starting Broadcast Search for '${interfaceName}'...`); // 1. Get All Router IDs const routerIds = mikrotik.getConfiguredRouterIds(); console.log(`[Test] Configured Routers: ${routerIds.join(', ')}`); let foundAny = false; // 2. Scan Loop for (const rId of routerIds) { console.log(`\n--- Checking Router ${rId} ---`); try { // Find Interface const found = await mikrotik.findInterface(interfaceName, rId); if (found) { console.log(` [MATCH] Found interface: ${found.name}`); console.log(` Monitoring traffic...`); const traffic = await mikrotik.monitorInterfaceTraffic(found.name, rId); console.log(` [RESULT] Traffic: RX ${traffic['rx-bits-per-second']}bps / TX ${traffic['tx-bits-per-second']}bps`); foundAny = true; } else { console.log(` [info] Not found on Router ${rId}`); } } catch (e) { console.error(` [ERROR] Router ${rId} error: ${e.message}`); } } if (!foundAny) { console.log("\n[Test] Interface not found on ANY router."); } else { console.log("\n[Test] Search Complete. Found matches."); } } // Run test for "vlan_124" testBroadcastSearch("vlan_124");