const { Client } = require('ssh2');
const conn = new Client();
function exec(conn, cmd) {
  return new Promise((resolve, reject) => {
    conn.exec(cmd, (err, stream) => {
      if (err) return reject(err);
      let out = '';
      stream.on('data', d => out += d);
      stream.stderr.on('data', d => out += d);
      stream.on('close', () => resolve(out.trim()));
    });
  });
}
conn.on('ready', async () => {
  const r = await exec(conn, 'ls /home/slin/enduro-trails/data/terrain/hypso/ 2>/dev/null');
  console.log('Зумы в hypso:', r);
  const r2 = await exec(conn, 'find /home/slin/enduro-trails/data/terrain/hypso -name "*.png" | wc -l');
  console.log('PNG тайлов:', r2);
  const r3 = await exec(conn, 'pgrep -a gdal2tiles 2>/dev/null | wc -l');
  console.log('gdal2tiles процессов:', r3);
  const r4 = await exec(conn, 'du -sh /home/slin/enduro-trails/data/terrain/');
  console.log('Размер terrain:', r4);
  conn.end();
});
conn.connect({ host: '82.22.50.71', username: 'slin', password: 'motoZ@yaz2010', readyTimeout: 15000 });
