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
    
  
  
    
  | 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
    
  
  
    
  | 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
    
  
  
    
  | 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
    
  
  
    
  | 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
    
  
  
    
  | 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
    
  
  
    
  | 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
    
  
  
    
  | bytesToSize = function(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
    
  
  
    
  | /*** | |
| Extract max a min data from rawtable of extracting data from La crosse WS1640 | |
| project: http://meteo.marcoberri.it | |
| **/ | |
| var dbOne = db.getSisterDB('mbmeteolacrosse'); | 
  
    
      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
    
  
  
    
  | /*** | |
| data example | |
| { "_id" : ObjectId("5554dc1a4e047bc09c427420"), "ts" : ISODate("2015-05-13T23:24:03Z"), "RC" : 6 } | |
| { "_id" : ObjectId("5554dc1a4e047bc09c427421"), "ts" : ISODate("2015-05-13T23:25:03Z"), "RC" : 6 } | |
| get different from RC prev and act record and write a new collection in upsert | |
| Data from La Crosse ws1640 increment Rain Counter. |