datacom: exibe service-port nas configurações
Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
dd2d026fa0
commit
5fd008c003
1 file changed
+26
-5
+26
-5
@@ -1858,18 +1858,39 @@ Digite /help para ver todos os comandos disponíveis!
|
||||
}
|
||||
|
||||
const configCommand = `show running-config interface gpon ${slot} onu ${onuId}`;
|
||||
const result = await this.ssh.executeCommand(connection.connectionId, configCommand);
|
||||
const spCommand = `show running-config service-port | context-match "gpon ${slot} onu ${onuId}"`;
|
||||
|
||||
const [configResult, spResult] = await Promise.all([
|
||||
this.ssh.executeCommand(connection.connectionId, configCommand),
|
||||
this.ssh.executeCommand(connection.connectionId, spCommand)
|
||||
]);
|
||||
|
||||
this.ssh.disconnect(connection.connectionId);
|
||||
|
||||
if (result.success) {
|
||||
if (configResult.success) {
|
||||
// Extrair service-ports
|
||||
const servicePorts = spResult.success
|
||||
? this.ssh.parseServicePorts(spResult.output)
|
||||
: [];
|
||||
|
||||
let message = `📋 *Configuração da ONU*\n`;
|
||||
message += `📍 Slot: ${slot}, ONU: ${onuId}\n\n`;
|
||||
message += `\`\`\`\n${result.output}\n\`\`\``;
|
||||
message += `📍 Slot: ${slot}, ONU: ${onuId}\n`;
|
||||
|
||||
if (servicePorts.length > 0) {
|
||||
message += `🔌 *Service-port${servicePorts.length > 1 ? 's' : ''}:* ${servicePorts.join(', ')}\n`;
|
||||
} else {
|
||||
message += `🔌 *Service-port:* não encontrado\n`;
|
||||
}
|
||||
|
||||
message += `\n\`\`\`\n${configResult.output}\n\`\`\``;
|
||||
|
||||
if (spResult.success && spResult.output && spResult.output.trim()) {
|
||||
message += `\n\n*Service-port(s):*\n\`\`\`\n${spResult.output.trim()}\n\`\`\``;
|
||||
}
|
||||
|
||||
await this.bot.sendMessage(chatId, message, { parse_mode: 'Markdown' });
|
||||
} else {
|
||||
await this.bot.sendMessage(chatId, `❌ Erro ao obter configuração: ${result.error}`);
|
||||
await this.bot.sendMessage(chatId, `❌ Erro ao obter configuração: ${configResult.error}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erro ao mostrar configuração:', error);
|
||||
|
||||
Reference in new issue
Block a user