This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for(dbName in db.getMongo().getDBNames()){ | |
| var name = db.getMongo().getDBNames()[dbName]; | |
| if(name.lastIndexOf("<db start name>") === 0 && name !== "<db>_to_exclude"){ | |
| print(); | |
| print('------------ START ---------------------'); | |
| print('--> to fix --> ' + name); | |
| var dbSister = db.getSisterDB(name); | |
| var coll = dbSister.getCollection("nodes"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| db.nodes.group( | |
| {key : {'className':'it.marcoberri.Document'}, | |
| cond:{"stats" : {"$exists":1}}, | |
| reduce : function(curr, result){ | |
| if(curr.stats.downloads) | |
| result.totDownload += curr.stats.downloads; | |
| if(curr.stats.views) | |
| result.totView += curr.stats.views; | |
| result.totEle++; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| example using mtools | |
| ------------------------- | |
| mlogfilter | |
| mlogfilter /var/log/mongodb/mongod_node1.log --slow --json | mongoimport -d mtools -c node1 | |
| db.node1.findOne(); | |
| { | |
| "_id" : ObjectId("5652d5a0db7669686cfc1952"), | |
| "split_tokens" : [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var dbOne = db.getSisterDB('mbmeteolacrosse'); | |
| var cur = dbOne.rawdata.find({"tsMillis":{"$exists":false}},{"_id":1,"ts":1}).addOption(DBQuery.Option.noTimeout); | |
| var updated=0; | |
| cur.forEach(function(doc) { | |
| dbOne.rawdata.update({"_id":doc._id},{"$set" : {"tsMillis":doc.ts.getTime()}}); | |
| updated = updated + 1; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while(1) { | |
| var c = db.currentOp(); | |
| if(c && c.inprog && c.inprog.length > 0 && c.inprog[0].op == 'query') { | |
| var el = c.inprog[0]; | |
| if( el.ns == 'admin.$cmd' || el.ns == 'local.$cmd' || el.ns == '') | |
| continue; | |
| print("on:" + el.ns); | |
| if(el.microsecs_running && el.microsecs_running.floatApprox) | |
| print("time:" + el.microsecs_running.floatApprox); | |
| print("query: " + JSON.stringify(el.query)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String root_dir = base + "/file_freedb/freedb-complete-20090101/"; | |
| FileFilter directoryFilter = new FileFilter() { | |
| public boolean accept(File file) { | |
| return file.isDirectory(); | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mongoserver:PRIMARY> rs.status(); | |
| { | |
| "set" : "mongoserver", | |
| "date" : ISODate("2016-02-02T10:47:07.510Z"), | |
| "myState" : 1, | |
| "members" : [ | |
| { | |
| "_id" : 3, | |
| "name" : "192.168.1.10:37017", | |
| "health" : 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function bytesToSize(bytes, precision) { | |
| var kilobyte = 1024; | |
| var megabyte = kilobyte * 1024; | |
| var gigabyte = megabyte * 1024; | |
| var terabyte = gigabyte * 1024; | |
| if ((bytes >= 0) && (bytes < kilobyte)) { | |
| return bytes + ' B'; | |
| } else if ((bytes >= kilobyte) && (bytes < megabyte)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| la funzioanlità ricerca nel server tutti i db like <db_like_name> e per ogni collecion presente nel singolo db | |
| esegue una eliminazione per spurgare i log. | |
| per eseguire lo script | |
| ./mongo --host <indirizzo_host> --port <porta> PurgeLogCollection.js --quiet --eval "var deleteData=false;var beforePurgeDay=200;" | |
| parametri in eval | |
| deleteDate = true|false (se false visualizza solo questo che dovrà fare senza eliminare default false) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function deleteAllCollection(dbName,excludeCollection){ | |
| var dbOne = db.getSisterDB(dbName); | |
| for(var colName in dbOne.getCollectionNames()){ | |
| var collectionName = dbOne.getCollectionNames()[colName]; | |
| if(!collectionName || collectionName == "") | |
| continue; | |
| if(excludeCollection.indexOf(collectionName) > -1) | |
| continue; | |
| dbOne[collectionName].drop(); |