26 lines
977 B
JavaScript
26 lines
977 B
JavaScript
const { Client } = require('ssh2');
|
||
const conn = new Client();
|
||
const config = {
|
||
host: 'demo.tensorgrove.com.cn',
|
||
port: 22,
|
||
username: 'root',
|
||
privateKey: require('fs').readFileSync(require('path').join(require('os').homedir(), '.ssh', 'id_rsa')),
|
||
};
|
||
|
||
conn.on('ready', () => {
|
||
// 搜索最近的 FC 回调日志(过去5分钟的所有 FC 相关日志)
|
||
const cmd = `grep -E '\\[FC\\]|\\[ToolExecutor\\]|room_980c6671|ExternalTextToSpeech|Command:function|TTS segment|Split into|Knowledge base|Promise|parallel' /var/log/bigwo/server-out.log | tail -80`;
|
||
conn.exec(cmd, (err, stream) => {
|
||
if (err) { console.error('exec error:', err); conn.end(); return; }
|
||
let out = '';
|
||
stream.on('data', d => out += d.toString());
|
||
stream.stderr.on('data', d => process.stderr.write(d));
|
||
stream.on('close', () => {
|
||
console.log(out);
|
||
conn.end();
|
||
});
|
||
});
|
||
}).on('error', err => {
|
||
console.error('SSH error:', err.message);
|
||
}).connect(config);
|