// Path: src/com/clavain/muninmxcd.java
// public static MongoClient m;
// 
// Path: src/com/clavain/muninmxcd.java
// public static LinkedBlockingQueue<BasicDBObject> mongo_queue = new LinkedBlockingQueue<BasicDBObject>();
// 
// Path: src/com/clavain/muninmxcd.java
// public static boolean logMore   = false;
// 
// Path: src/com/clavain/muninmxcd.java
// public static Logger logger     = Logger.getRootLogger();


import static com.clavain.muninmxcd.logMore;
import static com.clavain.muninmxcd.logger;
import java.util.Iterator;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.MongoClient;
import com.mongodb.MongoOptions;
import static com.clavain.muninmxcd.m;
import static com.clavain.muninmxcd.mongo_queue;
        String plugin = "";
        while(true)
        { 
            try
            {
                BasicDBObject doc = mongo_queue.take();
                if(doc != null)
                {
                    plugin = doc.getString("plugin");
                    // each hostname got its own collection
                    col = db.getCollection(doc.getString("user_id") + "_" + doc.getString("nodeid"));
                    doc.removeField("hostname");
                    doc.removeField("nodeid");
                    doc.removeField("user_id");
                    //doc.removeField("plugin");
                    //db.requestStart();
                    col.insert(doc);
                    if(logMore)
                    {
                        logger.info("Mongo: Wrote " + plugin + " / " + doc.getString("graph") + " / " + doc.getString("value"));
                    }
                    //db.requestDone();
                }
                else
                {
                    Thread.sleep(50);    
                }
                
            } catch (Exception ex)
            {
// Path: src/com/clavain/muninmxcd.java
// public static MongoClient m;
// 
// Path: src/com/clavain/muninmxcd.java
// public static LinkedBlockingQueue<BasicDBObject> mongo_queue = new LinkedBlockingQueue<BasicDBObject>();
// 
// Path: src/com/clavain/muninmxcd.java
// public static boolean logMore   = false;
// 
// Path: src/com/clavain/muninmxcd.java
// public static Logger logger     = Logger.getRootLogger();


// Path: src/com/clavain/workers/MongoWorker.java
import static com.clavain.muninmxcd.logMore;
import static com.clavain.muninmxcd.logger;
import java.util.Iterator;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.MongoClient;
import com.mongodb.MongoOptions;
import static com.clavain.muninmxcd.m;
import static com.clavain.muninmxcd.mongo_queue;

        String plugin = "";
        while(true)
        { 
            try
            {
                BasicDBObject doc = mongo_queue.take();
                if(doc != null)
                {
                    plugin = doc.getString("plugin");
                    // each hostname got its own collection
                    col = db.getCollection(doc.getString("user_id") + "_" + doc.getString("nodeid"));
                    doc.removeField("hostname");
                    doc.removeField("nodeid");
                    doc.removeField("user_id");
                    //doc.removeField("plugin");
                    //db.requestStart();
                    col.insert(doc);
                    if(logMore)
                    {
                        logger.info("Mongo: Wrote " + plugin + " / " + doc.getString("graph") + " / " + doc.getString("value"));
                    }
                    //db.requestDone();
                }
                else
                {
                    Thread.sleep(50);    
                }
                
            } catch (Exception ex)
            {
                logger.fatal("Error in MongoWorker: " + ex.getLocalizedMessage());