void ConfigTreeView::read_config() { if ( !m_config ) { return; } m_config_tree->clear(); m_config->lock(); Configuration::ValueIterator* cit = m_config->iterator(); while ( cit->next() ) { if ( cit->is_bool() ) { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_bool()); } else if ( cit->is_int() ) { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_int()); } else if ( cit->is_uint() ) { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_uint()); } else if ( cit->is_float() ) { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_float()); } else if ( cit->is_string() ) { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_string()); } } delete cit; m_config->unlock(); }
/** Constructor. * @param config Fawkes configuration */ FvRetrieverPlugin::FvRetrieverPlugin(Configuration *config) : Plugin(config) { std::string prefix = "/firevision/retriever/camera/"; Configuration::ValueIterator *vi = config->search(prefix.c_str()); while (vi->next()) { if ( ! vi->is_string() ) { throw TypeMismatchException("Only values of type string are valid for camera" " argument strings, but got %s for %s", vi->type(), vi->path()); } std::string id = std::string(vi->path()).substr(prefix.length()); thread_list.push_back(new FvRetrieverThread(vi->get_string().c_str(), id.c_str())); } if ( thread_list.empty() ) { throw Exception("No cameras have been set for fvretriever"); } delete vi; }
void ProcRRDThread::init() { __samplerate = 10; try { __samplerate = config->get_uint("/plugins/procrrd/samplerate"); } catch (Exception &e) {} __timewait = new TimeWait(clock, __samplerate * 1000000); __netinterface = "wlan0"; try { __netinterface = config->get_string("/plugins/procrrd/netinterface"); } catch (Exception &e) {} __lastcpu = new unsigned long int[11]; get_cpu(__lastcpu); __net_recv_graph = NULL; __net_trans_graph = NULL; std::vector<RRDDataSource> rrds; // /proc/net/dev // use data for net_interface // Receive bytes rrds.push_back(RRDDataSource("net_recv_bytes", RRDDataSource::COUNTER)); // Receive packets rrds.push_back(RRDDataSource("net_recv_packets", RRDDataSource::COUNTER)); // Receive errs rrds.push_back(RRDDataSource("net_recv_errors", RRDDataSource::COUNTER)); // Transmit bytes rrds.push_back(RRDDataSource("net_trans_bytes", RRDDataSource::COUNTER)); // Transmit packets rrds.push_back(RRDDataSource("net_trans_packets", RRDDataSource::COUNTER)); // Transmit errs rrds.push_back(RRDDataSource("net_trans_errors", RRDDataSource::COUNTER)); __net_rrd = new RRDDefinition("network", rrds); try { rrd_manager->add_rrd(__net_rrd); } catch (Exception &e) { finalize(); throw; } std::vector<RRDGraphDataDefinition> defs; std::vector<RRDGraphElement *> els; defs.push_back(RRDGraphDataDefinition("net_recv_bytes", RRDArchive::AVERAGE, __net_rrd)); defs.push_back(RRDGraphDataDefinition("net_recv_packets", RRDArchive::AVERAGE, __net_rrd)); defs.push_back(RRDGraphDataDefinition("net_recv_errors", RRDArchive::AVERAGE, __net_rrd)); els.push_back(new RRDGraphLine("net_recv_bytes", 1, "006400", "Bytes")); els.push_back(new RRDGraphGPrint("net_recv_bytes", RRDArchive::LAST, " Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("net_recv_bytes", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("net_recv_bytes", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphLine("net_recv_packets", 1, "808000", "Packets")); els.push_back(new RRDGraphGPrint("net_recv_packets", RRDArchive::LAST, "Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("net_recv_packets", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("net_recv_packets", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphLine("net_recv_errors", 1, "FF0000", "Errors")); els.push_back(new RRDGraphGPrint("net_recv_errors", RRDArchive::LAST, " Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("net_recv_errors", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("net_recv_errors", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); __net_recv_graph = new RRDGraphDefinition("network_recv", __net_rrd, "Network Receive", "", defs, els); defs.clear(); els.clear(); defs.push_back(RRDGraphDataDefinition("net_trans_bytes", RRDArchive::AVERAGE, __net_rrd)); defs.push_back(RRDGraphDataDefinition("net_trans_packets", RRDArchive::AVERAGE, __net_rrd)); defs.push_back(RRDGraphDataDefinition("net_trans_errors", RRDArchive::AVERAGE, __net_rrd)); els.push_back(new RRDGraphLine("net_trans_bytes", 1, "006400", "Bytes")); els.push_back(new RRDGraphGPrint("net_trans_bytes", RRDArchive::LAST, " Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("net_trans_bytes", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("net_trans_bytes", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphLine("net_trans_packets", 1, "808000", "Packets")); els.push_back(new RRDGraphGPrint("net_trans_packets", RRDArchive::LAST, "Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("net_trans_packets", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("net_trans_packets", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphLine("net_trans_errors", 1, "FF0000", "Errors")); els.push_back(new RRDGraphGPrint("net_trans_errors", RRDArchive::LAST, " Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("net_trans_errors", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("net_trans_errors", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); __net_trans_graph = new RRDGraphDefinition("network_trans", __net_rrd, "Network Transmit", "", defs, els); try { rrd_manager->add_graph(__net_recv_graph); rrd_manager->add_graph(__net_trans_graph); } catch (Exception &e) { finalize(); throw; } std::string procprefix = PROC_CONF_PREFIX; try { std::string selfid = get_process_id("fawkes"); add_process((procprefix+"fawkes").c_str(), selfid, "fawkes"); } catch (Exception &e) { logger->log_warn(name(), "Failed to add process: Fawkes, exception follows"); logger->log_warn(name(), e); finalize(); throw; } Configuration::ValueIterator *i = config->search(procprefix.c_str()); while (i->next()) { if (! i->is_string()) { logger->log_warn(name(), "Entry %s is not a string, but of type %s, " "ignoring", i->path(), i->type()); continue; } std::string name = i->get_string(); try { std::string pid = get_process_id(name.c_str()); add_process(i->path(), pid, name); } catch (Exception &e) { logger->log_warn(this->name(), "Failed to add process: %s, exception follows", name.c_str()); logger->log_warn(this->name(), e); finalize(); throw; } } std::string p; ProcessMap::iterator pi = __processes.begin(); p = pi->second.name; ++pi; for (; pi != __processes.end(); ++pi) { p += ", "+pi->second.name; } logger->log_info(name(), "ProcRRD logging network interface %s and processes %s with a samplerate of %lu second(s)", __netinterface.c_str(), p.c_str(), __samplerate); config->add_change_handler(this); }
void MongoRRDThread::init() { __timewait = new TimeWait(clock, 10 * 1000000); __opcounters_graph = NULL; __memory_graph = NULL; __indexes_graph = NULL; std::vector<RRDDataSource> rrds; rrds.push_back(RRDDataSource("insert", RRDDataSource::COUNTER)); rrds.push_back(RRDDataSource("query", RRDDataSource::COUNTER)); rrds.push_back(RRDDataSource("update", RRDDataSource::COUNTER)); rrds.push_back(RRDDataSource("delete", RRDDataSource::COUNTER)); rrds.push_back(RRDDataSource("getmore", RRDDataSource::COUNTER)); rrds.push_back(RRDDataSource("command", RRDDataSource::COUNTER)); __opcounters_rrd = new RRDDefinition("opcounters", rrds); rrds.clear(); rrds.push_back(RRDDataSource("resident", RRDDataSource::GAUGE)); rrds.push_back(RRDDataSource("virtual", RRDDataSource::GAUGE)); rrds.push_back(RRDDataSource("mapped", RRDDataSource::GAUGE)); __memory_rrd = new RRDDefinition("memory", rrds); rrds.clear(); rrds.push_back(RRDDataSource("accesses", RRDDataSource::COUNTER)); rrds.push_back(RRDDataSource("hits", RRDDataSource::COUNTER)); rrds.push_back(RRDDataSource("misses", RRDDataSource::COUNTER)); rrds.push_back(RRDDataSource("resets", RRDDataSource::COUNTER)); __indexes_rrd = new RRDDefinition("indexes", rrds); rrds.clear(); rrds.push_back(RRDDataSource("locktime", RRDDataSource::COUNTER)); __locks_rrd = new RRDDefinition("locks", rrds); try { rrd_manager->add_rrd(__opcounters_rrd); rrd_manager->add_rrd(__memory_rrd); rrd_manager->add_rrd(__indexes_rrd); rrd_manager->add_rrd(__locks_rrd); } catch (Exception &e) { finalize(); throw; } std::vector<RRDGraphDataDefinition> defs; std::vector<RRDGraphElement *> els; defs.push_back(RRDGraphDataDefinition("insert", RRDArchive::AVERAGE, __opcounters_rrd)); defs.push_back(RRDGraphDataDefinition("query", RRDArchive::AVERAGE, __opcounters_rrd)); defs.push_back(RRDGraphDataDefinition("update", RRDArchive::AVERAGE, __opcounters_rrd)); defs.push_back(RRDGraphDataDefinition("delete", RRDArchive::AVERAGE, __opcounters_rrd)); defs.push_back(RRDGraphDataDefinition("getmore", RRDArchive::AVERAGE, __opcounters_rrd)); defs.push_back(RRDGraphDataDefinition("command", RRDArchive::AVERAGE, __opcounters_rrd)); els.push_back(new RRDGraphLine("insert", 1, "FF7200", "Inserts")); els.push_back(new RRDGraphGPrint("insert", RRDArchive::LAST, " Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("insert", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("insert", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphLine("query", 1, "503001", "Queries")); els.push_back(new RRDGraphGPrint("query", RRDArchive::LAST, " Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("query", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("query", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphLine("update", 1, "EDAC00", "Updates")); els.push_back(new RRDGraphGPrint("update", RRDArchive::LAST, " Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("update", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("update", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphLine("delete", 1, "506101", "Deletes")); els.push_back(new RRDGraphGPrint("delete", RRDArchive::LAST, " Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("delete", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("delete", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphLine("getmore", 1, "0CCCCC", "Getmores")); els.push_back(new RRDGraphGPrint("getmore", RRDArchive::LAST, "Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("getmore", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("getmore", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphLine("command", 1, "53CA05", "Commands")); els.push_back(new RRDGraphGPrint("command", RRDArchive::LAST, "Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("command", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("command", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); __opcounters_graph = new RRDGraphDefinition("opcounters", __opcounters_rrd, "MongoDB Op Counters", "Ops/sec", defs, els); defs.clear(); els.clear(); defs.push_back(RRDGraphDataDefinition("rawresident", RRDArchive::AVERAGE, __memory_rrd, "resident")); defs.push_back(RRDGraphDataDefinition("rawvirtual", RRDArchive::AVERAGE, __memory_rrd, "virtual")); defs.push_back(RRDGraphDataDefinition("rawmapped", RRDArchive::AVERAGE, __memory_rrd, "mapped")); defs.push_back(RRDGraphDataDefinition("resident", "rawresident,1048576,*")); defs.push_back(RRDGraphDataDefinition("virtual", "rawvirtual,1048576,*")); defs.push_back(RRDGraphDataDefinition("mapped", "rawmapped,1048576,*")); els.push_back(new RRDGraphArea("virtual", "3B7AD9", "Virtual")); els.push_back(new RRDGraphGPrint("virtual", RRDArchive::LAST, " Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("virtual", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("virtual", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphArea("mapped", "6FD1BF", "Mapped")); els.push_back(new RRDGraphGPrint("mapped", RRDArchive::LAST, " Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("mapped", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("mapped", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphArea("resident", "0E6E5C", "Resident")); els.push_back(new RRDGraphGPrint("resident", RRDArchive::LAST, "Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("resident", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("resident", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); __memory_graph = new RRDGraphDefinition("memory", __memory_rrd, "MongoDB Memory Usage", "MB", defs, els); defs.clear(); els.clear(); defs.push_back(RRDGraphDataDefinition("accesses", RRDArchive::AVERAGE, __indexes_rrd)); defs.push_back(RRDGraphDataDefinition("hits", RRDArchive::AVERAGE, __indexes_rrd)); defs.push_back(RRDGraphDataDefinition("misses", RRDArchive::AVERAGE, __indexes_rrd)); defs.push_back(RRDGraphDataDefinition("resets", RRDArchive::AVERAGE, __indexes_rrd)); els.push_back(new RRDGraphLine("accesses", 1, "FF7200", "Accesses")); els.push_back(new RRDGraphGPrint("accesses", RRDArchive::LAST, "Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("accesses", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("accesses", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphLine("hits", 1, "503001", "Hits")); els.push_back(new RRDGraphGPrint("hits", RRDArchive::LAST, " Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("hits", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("hits", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphLine("misses", 1, "EDAC00", "Misses")); els.push_back(new RRDGraphGPrint("misses", RRDArchive::LAST, " Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("misses", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("misses", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); els.push_back(new RRDGraphLine("resets", 1, "506101", "Resets")); els.push_back(new RRDGraphGPrint("resets", RRDArchive::LAST, " Current\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("resets", RRDArchive::AVERAGE, "Average\\:%8.2lf %s")); els.push_back(new RRDGraphGPrint("resets", RRDArchive::MAX, "Maximum\\:%8.2lf %s\\n")); __indexes_graph = new RRDGraphDefinition("indexes", __indexes_rrd, "MongoDB Indexes", "", defs, els); try { rrd_manager->add_graph(__opcounters_graph); rrd_manager->add_graph(__memory_graph); rrd_manager->add_graph(__indexes_graph); } catch (Exception &e) { finalize(); throw; } // Add DB Stats std::string dbprefix = DB_CONF_PREFIX; Configuration::ValueIterator *i = config->search(dbprefix.c_str()); while (i->next()) { if (! i->is_string()) { logger->log_warn(name(), "Entry %s is not a string, but of type %s, " "ignoring", i->path(), i->type()); continue; } std::string dbname = i->get_string(); if (dbname.find(".") != std::string::npos) { logger->log_warn(name(), "Database name %s contains dot, ignoring", dbname.c_str()); continue; } try { add_dbstats(i->path(), dbname); } catch (Exception &e) { finalize(); throw; } } config->add_change_handler(this); }
bool ConfigTreeView::remove_entry(const Gtk::TreeIter& iter) { bool ret_val = false; int result; Gtk::TreeModel::Row row = *iter; Glib::ustring type = row[m_config_record.type]; bool is_default = row[m_config_record.is_default]; if (type == "") //if type is empty the row is a directory -> return { ret_val = false; } else { Glib::ustring path = row[m_config_record.path]; m_dlg_remove->init(path, is_default); Gtk::Window* parent = dynamic_cast<Gtk::Window*>( get_toplevel() ); m_dlg_remove->set_transient_for(*parent); result = m_dlg_remove->run(); switch (result) { case Gtk::RESPONSE_OK: { const char* p = path.c_str(); bool rem_default = m_dlg_remove->get_remove_default(); m_config->erase(p); if (rem_default) m_config->erase_default(p); Gtk::TreePath tree_path = m_config_tree->get_path(iter); m_config_tree->erase(iter); m_config_tree->row_deleted(tree_path); Configuration::ValueIterator* cit = m_config->search(p); if (!rem_default && cit->next()) //reenter the default value { if ( cit->is_bool() ) { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_bool()); } else if ( cit->is_int() ) { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_int()); } else if ( cit->is_uint() ) { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_uint()); } else if ( cit->is_float() ) { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_float()); } else if ( cit->is_string() ) { set_value(cit->path(), cit->type(), cit->is_default(), cit->get_string()); } } break; } default: ret_val = false; break; } m_dlg_remove->hide(); } return ret_val; }