diagnostico: adicionada função (TESTING)
Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
7f38d16821
commit
0dbab52aa1
3 files changed
+430
-1
No files matched your search
@@ -468,6 +468,58 @@ class SSHManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica o status da porta Ethernet de uma ONU Datacom pelo slot e ID
|
||||
* @param {string} equipmentId - ID do equipamento OLT
|
||||
* @param {string} slot - Slot da ONU (ex: 1/1/1)
|
||||
* @param {string} onuId - ID da ONU
|
||||
* @returns {Promise} - { success, portStatus, speed, rawOutput }
|
||||
*/
|
||||
async checkOnuEthernetDatacom(equipmentId, slot, onuId) {
|
||||
try {
|
||||
const connection = await this.connect(equipmentId);
|
||||
|
||||
if (!connection.success) {
|
||||
throw new Error(`Falha na conexão: ${connection.message}`);
|
||||
}
|
||||
|
||||
const command = `show interface gpon ${slot} onu ${onuId} ethernet`;
|
||||
const result = await this.executeCommand(connection.connectionId, command);
|
||||
|
||||
this.disconnect(connection.connectionId);
|
||||
|
||||
if (!result.success) {
|
||||
return { success: false, error: result.error, rawOutput: result.output };
|
||||
}
|
||||
|
||||
// Extrai status e velocidade da porta ethernet
|
||||
// Linha típica: " 1 Forwarding 1Gbit Full-Duplex"
|
||||
// ou: " 1 Down N/A"
|
||||
const portStatus = null;
|
||||
const speed = null;
|
||||
const output = result.output || '';
|
||||
|
||||
// Procurar por linha de porta ethernet
|
||||
const lineMatch = output.match(/\b(Forwarding|Down|Up|Blocking)\b.*?([\d]+(?:Gbit|Mbit)[^\n]*|N\/A)/i);
|
||||
const statusVal = lineMatch ? lineMatch[1] : null;
|
||||
const speedVal = lineMatch ? lineMatch[2]?.trim() : null;
|
||||
|
||||
return {
|
||||
success: true,
|
||||
portStatus: statusVal,
|
||||
speed: speedVal,
|
||||
rawOutput: output
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error: error.message,
|
||||
rawOutput: null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Busca informações de uma ONU pelo serial number na OLT
|
||||
* @param {string} equipmentId - ID do equipamento OLT
|
||||
|
||||
Reference in new issue
Block a user