monitoring.js
function serverMonitoringCleanup(db, conn){
    var exclude = {
        eventDate: 0,
        pid: 0,
        version: 0,
        uptime: 0,
        network: 0,
        connectionName: 0,
        connections: 0,
        memory: 0,
        dataRetrieved: 0,
        docCounts: 0
    };

    var retainedRecords = (24 * 60) * 60 / 30; // 24 hours worth of 30 sec blocks (data refresh interval)

    db.find({connectionName: conn}).skip(retainedRecords).sort({eventDate: -1}).projection(exclude).exec(function (err, serverEvents){
        var idArray = [];
        _.each(serverEvents, function(value, key){
            idArray.push(value._id);
        });

        db.remove({'_id': {'$in': idArray}}, {multi: true}, function (err, newDoc){});
    });
}
function serverMonitoringCleanup(db, conn){
    var exclude = {
        eventDate: 0,
        pid: 0,
        version: 0,
        uptime: 0,
        network: 0,
        connectionName: 0,
        connections: 0,
        memory: 0,
        dataRetrieved: 0,
        docCounts: 0
    };

    var retainedRecords = (24 * 60) * 60 / 30; // 24 hours worth of 30 sec blocks (data refresh interval)

    db.find({connectionName: conn}).skip(retainedRecords).sort({eventDate: -1}).projection(exclude).exec(function (err, serverEvents){
        var idArray = [];
        _.each(serverEvents, function(value, key){
            idArray.push(value._id);
        });

        db.remove({'_id': {'$in': idArray}}, {multi: true}, function (err, newDoc){});
    });
}
function serverMonitoringCleanup ( db , conn ) { var exclude = { eventDate : 0 , pid : 0 , version : 0 , uptime : 0 , network : 0 , connectionName : 0 , connections : 0 , memory : 0 , dataRetrieved : 0 , docCounts : 0 } ; var retainedRecords = ( 24 * 60 ) * 60 / 30 ; // 24 hours worth of 30 sec blocks (data refresh interval) db . find ( { connectionName : conn } ) . skip ( retainedRecords ) . sort ( { eventDate : - 1 } ) . projection ( exclude ) . exec ( function ( err , serverEvents ) { var idArray = [ ] ; _ . each ( serverEvents , function ( value , key ) { idArray . push ( value . _id ) ; } ) ; db . remove ( { '_id' : { '$in' : idArray } } , { multi : true } , function ( err , newDoc ) { } ) ; } ) ; }
Removes old monitoring data. We only want basic monitoring with the last 100 events. We keep last 80 and remove the rest to be sure.
Removes old monitoring data . We only want basic monitoring with the last 100 events . We keep last 80 and remove the rest to be sure .