-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
44 lines (38 loc) · 1.44 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//Edit this url to point to your mongo db!
var mongoUrl = 'mongodb://localhost:27017/test';
var MongoClient = require("mongodb").MongoClient;
var async = require('asyncawait/async');
var await = require('asyncawait/await');
async(function () {
try {
console.log("using connection URL: " + mongoUrl);
console.log("If this is wrong, change it in index.js. If your not seeing anything probaly need to change it")
var dbCon = await(MongoClient.connect(mongoUrl));
process.on('SIGINT', function () { //Should I do this ?
dbCon.close();
console.log('Closed Database Connection');
process.exit();
})
var Profile = dbCon.collection('system.profile');
var items;
var lastTime = new Date();
while (true) {
items = await(Profile.find({ ts: { $gte: lastTime }, junkField: { $ne: "SDLKJFJ" } }).toArray());
lastTime = new Date();
items.forEach((item) => {
if (item.query && !item.query.junkField && item.ns != "meteor.cronHistory")
console.log(item.ns + "::\n" + "" + item.op + " ", JSON.stringify(item.query, null, " ") + "\n");
});
await(pause());
}
} catch (e) {
console.trace(e);
}
dbCon.close();
})();
function pause(time) {
time = time || 1000;
return new Promise((resolve) => {
setTimeout(_ => resolve(), time);
})
}