Send an email when not able to get last block header

This commit is contained in:
adaxi
2018-02-18 22:08:01 +01:00
parent 43ed5842d0
commit 9ee4b71651
+24
View File
@@ -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();