29 lines
1.8 KiB
JavaScript
29 lines
1.8 KiB
JavaScript
|
|
const { Client } = require('ssh2');
|
||
|
|
const conn = new Client();
|
||
|
|
conn.on('ready', () => {
|
||
|
|
const cmd = [
|
||
|
|
"echo '=== LOG TIMELINE AFTER 11:55 ==='",
|
||
|
|
"awk '/2026-03-12 11:55:52/{found=1} found' /var/log/bigwo/server-out.log | grep -E '(Session started:|Stored user speech|Callback received|500ms timeout|Using ASR user speech|Starting KB query|Ark KB search succeeded|search_knowledge completed|Sending Command:function|Command:function sent OK|Final result|Session stopped:|Loaded [0-9]+ messages from DB|\\[Subtitle\\]\\[assistant\\]|\\[Subtitle\\]\\[user\\])'",
|
||
|
|
"echo '=== DB LAST 2 SESSIONS ==='",
|
||
|
|
"cd /www/wwwroot/demo.tensorgrove.com.cn/server && node -e \"require('dotenv').config(); const db=require('./db'); (async()=>{await db.initialize(); const pool=db.getPool(); const [s]=await pool.query('SELECT id, updated_at FROM sessions ORDER BY updated_at DESC LIMIT 2'); console.log(JSON.stringify(s,null,2)); for (const row of s){ const [m]=await pool.query('SELECT role, source, tool_name, LEFT(content,160) content, created_at FROM messages WHERE session_id=? ORDER BY created_at ASC',[row.id]); console.log('SESSION', row.id); console.log(JSON.stringify(m,null,2)); } process.exit(0)})().catch(e=>{console.error(e); process.exit(1)})\""
|
||
|
|
].join(' && ');
|
||
|
|
conn.exec(cmd, (err, stream) => {
|
||
|
|
if (err) { console.error('exec error:', err); conn.end(); return; }
|
||
|
|
let out = '';
|
||
|
|
let errOut = '';
|
||
|
|
stream.on('data', d => out += d.toString());
|
||
|
|
stream.stderr.on('data', d => errOut += d.toString());
|
||
|
|
stream.on('close', () => {
|
||
|
|
console.log(out || '(no output)');
|
||
|
|
if (errOut) console.error(errOut);
|
||
|
|
conn.end();
|
||
|
|
});
|
||
|
|
});
|
||
|
|
}).on('error', err => console.error('SSH error:', err.message)).connect({
|
||
|
|
host: '119.45.10.34',
|
||
|
|
port: 22,
|
||
|
|
username: 'root',
|
||
|
|
password: '#xyzh%CS#2512@28',
|
||
|
|
readyTimeout: 10000,
|
||
|
|
});
|