Job to clean up outdated monitoring data.

This commit is contained in:
baldo 2016-05-24 20:39:51 +02:00
parent b84bfb5c99
commit e03be8bf51
3 changed files with 36 additions and 1 deletions
server/services

View file

@ -307,6 +307,28 @@ angular.module('ffffng')
);
});
});
},
cleanupNodeInformation: function (callback) {
var daysBeforeCleanup = 30;
Logger
.tag('monitoring', 'information-cleanup')
.info('Cleaning up node data not updated for %s days...', daysBeforeCleanup);
Database.run(
'DELETE FROM node_state WHERE modified_at < ?',
[moment().subtract(daysBeforeCleanup, 'days').unix()],
function (err) {
if (err) {
return callback(err);
}
Logger
.tag('monitoring', 'information-retrieval')
.info('Node data cleanup done.');
callback();
}
);
}
};
});