diff --git a/lib/worker.js b/lib/worker.js index cb0b499..0aec1ce 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -521,6 +521,30 @@ function monitorNodes() { }); } +function monitorNodes() { + global.coinFuncs.getLastBlockHeader((err, block) => { + if (err !== null) { + return global.support.sendEmail( + global.config.general.adminEmail, + 'Failed to query daemon for last block header', + `The worker failed to return last block header. Please verify if the daemon is running properly.` + ); + } + const sql = 'SELECT blockID, hostname, ip FROM pools WHERE last_checkin > DATE_SUB(NOW(), INTERVAL 30 MINUTE)'; + global.mysql.query(sql).then(pools => { + pools.forEach(({ blockID, hostname, ip }) => { + if (blockID < block.height - 3) { + global.support.sendEmail( + global.config.general.adminEmail, + 'Pool server is behind in blocks', + `The pool server: ${hostname} with IP: ${ip} is ${(block.height - blockID)} blocks behind.` + ); + } + }) + }); + }); +} + updateShareStats(); updateBlockHeader(); updatePoolStats();