diff --git a/BACKEND/app/services/line_connection.ts b/BACKEND/app/services/line_connection.ts
index 0a07cf6..e2a5521 100644
--- a/BACKEND/app/services/line_connection.ts
+++ b/BACKEND/app/services/line_connection.ts
@@ -169,15 +169,15 @@ export default class LineConnection {
lineNumber,
status: 'connected',
})
- // this.checkLog()
+ this.checkLog()
resolve()
}, 1000)
})
this.client.on('data', (data) => {
let message = this.connecting ? cleanData(data.toString()) : data.toString()
- // const lines = this.bufferLog.push(data)
- // lines.forEach(this.handleLogLine)
+ const lines = this.bufferLog.push(data)
+ lines.forEach(this.handleLogLine)
let rawData = ''
if (this.isRunningScript) {
this.waitingScenario = true
@@ -806,31 +806,31 @@ export default class LineConnection {
try {
if (this.config.status !== 'connected') {
clearInterval(interval)
+ this.session.clear()
+ this.bufferLog.clear()
return
}
const result = this.session.finalize()
- if (result.errors.length === 0) return
+ if (result.errors.length === 0) {
+ this.session.clear()
+ this.bufferLog.clear()
+ return
+ }
- // console.log('===== TEST RESULT =====')
- // console.log('STATUS:', result.status)
- // console.log('SUMMARY:', result.summary)
-
- // result.errors.forEach((err, idx) => {
- // console.log(`\n[${idx + 1}] ${err.level} - ${err.ruleId}`)
- // console.log('Message:', err.message)
- // console.log('Log:', err.evidence.raw)
- // })
-
- const detectLog = await this.detectLogWithAI(this.bufferLog.buffer)
+ const detectLog = await this.detectLogWithAI(this.bufferLog.allBuffer)
// console.log(detectLog)
const tableHTML = this.buildEmailContent(result, detectLog)
await sendMessageToMail(
'andrew.ng@apactech.io',
- `[${result.status}] - [${this.config.stationName} - Line: ${this.config.lineNumber}] - Cisco Device Log Result`,
- tableHTML
- // ,
- // ['ips@ipsupply.com.au', 'kay@ipsupply.com.au', 'joseph@apactech.io']
+ `[ATC] - [${this.config.stationName} - Line: ${this.config.lineNumber}] - Raw log issue`,
+ tableHTML +
+ `${`
+
+ Logs:
+
+ ${this.bufferLog.allBuffer}
`}`,
+ ['ips@ipsupply.com.au', 'kay@ipsupply.com.au', 'joseph@apactech.io']
)
this.session.clear()
this.bufferLog.clear()
@@ -847,8 +847,8 @@ export default class LineConnection {
const header = `
- | Level |
- Rule |
+ Level |
+ Rule |
Message |
Log Evidence |
@@ -881,7 +881,7 @@ export default class LineConnection {
renderAIDetectTable(row: any): string {
return `
-
+
| Summary |
Issues |
@@ -902,7 +902,6 @@ export default class LineConnection {
return `
Cisco Device Log Result
Line: ${this.config.lineNumber} - Station: ${this.config.stationName}
- Status: ${result.status}
Summary: ${result.summary}
${table}
diff --git a/BACKEND/app/ultils/helper.ts b/BACKEND/app/ultils/helper.ts
index d57c8cb..8fa910d 100644
--- a/BACKEND/app/ultils/helper.ts
+++ b/BACKEND/app/ultils/helper.ts
@@ -410,20 +410,20 @@ export const RULES: LogRule[] = [
message: 'Critical features disabled by license',
},
// INTERFACE
- {
- id: 'INTERFACE_UP',
- category: 'INTERFACE',
- match: /LINK-3-UPDOWN: Interface .* up/i,
- level: 'PASS',
- message: 'Interface up',
- },
- {
- id: 'INTERFACE_FLAP',
- category: 'INTERFACE',
- match: /LINK-3-UPDOWN: Interface .* down/i,
- level: 'WARN',
- message: 'Interface flapping detected',
- },
+ // {
+ // id: 'INTERFACE_UP',
+ // category: 'INTERFACE',
+ // match: /LINK-3-UPDOWN: Interface .* up/i,
+ // level: 'PASS',
+ // message: 'Interface up',
+ // },
+ // {
+ // id: 'INTERFACE_FLAP',
+ // category: 'INTERFACE',
+ // match: /LINK-3-UPDOWN: Interface .* down/i,
+ // level: 'WARN',
+ // message: 'Interface flapping detected',
+ // },
{
id: 'INTERFACE_ERROR',
category: 'INTERFACE',
@@ -576,15 +576,17 @@ export class TestSession {
}
export class LogStreamBuffer {
- public buffer = ''
+ public allBuffer = ''
+ private buffer = ''
public push(chunk: Buffer): string[] {
this.buffer += chunk.toString('utf8').replace('--More--', '').trim()
+ this.allBuffer += cleanData(chunk.toString())
const lines = this.buffer.split(/\r?\n/)
this.buffer = lines.pop() || ''
- return lines.map((l) => l.trim()).filter(Boolean)
+ return lines.map((l) => l.replaceAll('--More--', '').trim()).filter(Boolean)
}
public flush(): string | null {
@@ -595,7 +597,7 @@ export class LogStreamBuffer {
}
public clear() {
- this.buffer = ''
+ this.allBuffer = ''
}
}