Merge pull request #27 from rubo77/master

Documents the main structure, that sends out emails for offline nodes
This commit is contained in:
Andreas Baldeau 2016-08-19 20:33:19 +02:00 committed by GitHub
commit 769ca33495

View file

@ -22,6 +22,9 @@ angular.module('ffffng')
) { ) {
var MONITORING_STATE_MACS_CHUNK_SIZE = 100; var MONITORING_STATE_MACS_CHUNK_SIZE = 100;
var MONITORING_MAILS_DB_BATCH_SIZE = 50; var MONITORING_MAILS_DB_BATCH_SIZE = 50;
/**
* Defines the intervals emails are sent if a node is offline
*/
var MONITORING_OFFLINE_MAILS_SCHEDULE = { var MONITORING_OFFLINE_MAILS_SCHEDULE = {
1: { amount: 3, unit: 'hours' }, 1: { amount: 3, unit: 'hours' },
2: { amount: 1, unit: 'days' }, 2: { amount: 1, unit: 'days' },
@ -343,11 +346,20 @@ angular.module('ffffng')
); );
} }
/**
* sends one of three mails if a node is offline
* @param {moment} startTime the moment the job started
* @param {Number} mailNumber which of three mails
* @param {Function} callback gets all nodes that are offline
*/
function sendOfflineMails(startTime, mailNumber, callback) { function sendOfflineMails(startTime, mailNumber, callback) {
sendMonitoringMailsBatched( sendMonitoringMailsBatched(
'offline ' + mailNumber, 'offline ' + mailNumber,
'monitoring-offline-' + mailNumber, 'monitoring-offline-' + mailNumber,
function (findBatchCallback) { function (findBatchCallback) {
/**
* descriptive string that stores, which was the last mail type, stored in the database as last_status_mail_type
*/
var previousType = var previousType =
mailNumber === 1 mailNumber === 1
? 'monitoring-online-again' ? 'monitoring-online-again'