Files
bigwo/mcp-server-ssh/check_current.cjs

19 lines
698 B
JavaScript
Raw Permalink Normal View History

const { Client } = require('ssh2');
const c = new Client();
c.on('ready', () => {
const cmd = [
"echo '=== LAST 200 LINES server-out.log ==='",
"tail -200 /var/log/bigwo/server-out.log",
"echo ''",
"echo '=== LAST 50 LINES server-error.log ==='",
"tail -50 /var/log/bigwo/server-error.log 2>/dev/null || echo 'no error log'",
].join(' && ');
c.exec(cmd, (err, s) => {
if (err) { console.error(err); c.end(); return; }
let o = '';
s.on('data', (d) => (o += d));
s.stderr.on('data', (d) => (o += d));
s.on('close', () => { console.log(o); c.end(); });
});
}).connect({ host: '119.45.10.34', port: 22, username: 'root', password: '#xyzh%CS#2512@28' });