2019-05-08 16:12:02 +03:00
|
|
|
const fs = require('fs')
|
|
|
|
const path = require('path')
|
|
|
|
const logger = require('./logger')('checkWorker2')
|
|
|
|
const eventsStats = require('./eventsStats')
|
|
|
|
const alerts = require('./alerts')
|
|
|
|
|
|
|
|
async function checkWorker2() {
|
|
|
|
try {
|
|
|
|
logger.debug('calling eventsStats()')
|
|
|
|
const evStats = await eventsStats()
|
|
|
|
if (!evStats) throw new Error('evStats is empty: ' + JSON.stringify(evStats))
|
2019-08-01 16:10:22 +03:00
|
|
|
fs.writeFileSync(path.join(__dirname, '/responses/eventsStats.json'), JSON.stringify(evStats, null, 4))
|
2019-05-08 16:12:02 +03:00
|
|
|
logger.debug('calling alerts()')
|
|
|
|
const _alerts = await alerts()
|
|
|
|
if (!_alerts) throw new Error('alerts is empty: ' + JSON.stringify(_alerts))
|
2019-08-01 16:10:22 +03:00
|
|
|
fs.writeFileSync(path.join(__dirname, '/responses/alerts.json'), JSON.stringify(_alerts, null, 4))
|
2019-05-08 16:12:02 +03:00
|
|
|
logger.debug('Done x2')
|
|
|
|
} catch (e) {
|
2019-05-30 21:05:36 +03:00
|
|
|
logger.error(e)
|
2019-05-08 16:12:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
checkWorker2()
|