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 ==='",
|
|
"awk '/2026-03-12 11:29:38/{found=1} found' /var/log/bigwo/server-out.log | grep -E '(Session started:|Stored user speech|RawBody|Callback received|500ms timeout|Using ASR user speech|Starting KB query|search_knowledge completed|Ark KB search succeeded|Sending Command:function|Command:function sent OK|Session stopped:|Loaded [0-9]+ messages from DB|\[Subtitle\]\[assistant\]|\[Subtitle\]\[user\])'",
|
|
"echo '=== DB LATEST SESSION MESSAGES ==='",
|
|
"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 1'); if(!s.length){console.log('no session'); process.exit(0)} const sid=s[0].id; console.log('session_id=',sid); const [m]=await pool.query('SELECT role, source, tool_name, LEFT(content,200) content, created_at FROM messages WHERE session_id=? ORDER BY created_at ASC',[sid]); 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,
|
|
});
|