-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinal-analysis.mjs
More file actions
53 lines (39 loc) · 2.19 KB
/
final-analysis.mjs
File metadata and controls
53 lines (39 loc) · 2.19 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import SSHAgent from './sshAgent.js';
const agent = new SSHAgent();
async function finalAnalysis() {
try {
console.log('[INFO] Analisi finale - Esame file .def e sezione Dispro...\n');
const commands = [
// 1. Ricerca "Dispro" in tutti i .def
'echo "=== DISPRO PROTOCOL USAGE ===" && grep "^Dispro" /var/nedi/sysobj/*.def | sort | uniq -c | sort -rn',
// 2. File con LLDP configurato
'echo "\n=== DISPOSITIVI CON LLDP ===" && grep -l "^Dispro.*LLDP" /var/nedi/sysobj/*.def | wc -l && echo "file .def con LLDP"',
// 3. File con CDP
'echo "\n=== DISPOSITIVI CON CDP ===" && grep -l "^Dispro.*CDP" /var/nedi/sysobj/*.def | wc -l && echo "file .def con CDP"',
// 4. File senza Dispro definito
'echo "\n=== DISPOSITIVI SENZA DISPRO ===" && grep -L "^Dispro" /var/nedi/sysobj/*.def | wc -l && echo "file .def senza Dispro"',
// 5. Esamina alcuni file importanti (non trovati Huawei 2011, check if any D-Link)
'echo "\n=== RICERCA VENDOR SPECIFICI ===" && ls /var/nedi/sysobj/1.3.6.1.4.1.* | sed "s/.*1.3.6.1.4.1.//" | sed "s/.def$//" | sort | uniq -c | sort -rn | head -15',
// 6. Stato della directory sysobj
'echo "\n=== STATO SYSOBJ ===" && ls -lhS /var/nedi/sysobj | head -20',
// 7. Database content - devices table
'echo "\n=== DEVICES DISCOVERY STATS ===" && mysql -u nedi -p$NEDI_MYSQL_PASS nedi -N -e "SELECT COUNT(*) as total, COUNT(DISTINCT devstatus) as statuses FROM devices;"',
// 8. Links discovery stats
'echo "\n=== LINKS DISCOVERY STATS ===" && mysql -u nedi -p$NEDI_MYSQL_PASS nedi -N -e "SELECT protocol, COUNT(*) as count FROM links GROUP BY protocol ORDER BY count DESC LIMIT 10;"'
];
const results = await agent.executeCommandsOnServer('ndei', commands, {
timeout: 25000,
stopOnError: false
});
for (const result of results) {
console.log(result.stdout);
if (result.stderr && !result.stderr.includes('cannot access') && !result.stderr.includes('No such')) {
console.error('[STDERR]', result.stderr);
}
}
} catch (err) {
console.error('[ERRORE]', err.message);
process.exit(1);
}
}
finalAnalysis();