-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-98.mjs
More file actions
34 lines (26 loc) · 1.37 KB
/
check-98.mjs
File metadata and controls
34 lines (26 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import Database from 'better-sqlite3';
const db = new Database('./netmap.db');
// Trova il device
const device = db.prepare("SELECT * FROM devices WHERE sysname LIKE '%casse-18-19_bis%'").get();
console.log('Device trovato:', device?.sysname, 'ID:', device?.id);
// Link DA questo device
const linksFrom = db.prepare('SELECT * FROM links WHERE device_id = ?').all(device.id);
console.log('\nLink DA questo device:', linksFrom.length);
linksFrom.forEach(l => {
const remote = db.prepare('SELECT sysname FROM devices WHERE id = ?').get(l.remote_device_id);
console.log(' ->', remote?.sysname || l.remote_sysname || 'NULL', '| Protocol:', l.protocol);
});
// Link VERSO questo device
const linksTo = db.prepare('SELECT * FROM links WHERE remote_device_id = ?').all(device.id);
console.log('\nLink VERSO questo device:', linksTo.length);
linksTo.forEach(l => {
const local = db.prepare('SELECT sysname FROM devices WHERE id = ?').get(l.device_id);
console.log(' <-', local?.sysname || 'NULL', '| Protocol:', l.protocol);
});
// Verifica API map
console.log('\n=== VERIFICA API ===');
const allLinks = db.prepare('SELECT * FROM links').all();
const deviceInLinks = allLinks.filter(l => l.device_id === device.id || l.remote_device_id === device.id);
console.log('Link totali nel DB:', allLinks.length);
console.log('Link che coinvolgono questo device:', deviceInLinks.length);
db.close();