$treeview $search $mathjax $extrastylesheet
artdaq_ganglia_plugin
v1_02_13
$projectbrief
|
$projectbrief
|
$searchbox |
00001 //ganglia_metric.cc: Ganglia Metric Plugin 00002 // Author: Eric Flumerfelt 00003 // Last Modified: 11/14/2014 00004 // 00005 // An implementation of the MetricPlugin interface for Ganglia 00006 00007 #ifndef __GANGLIA_METRIC__ 00008 #define __GANGLIA_METRIC__ 1 00009 00010 #include "fhiclcpp/fwd.h" 00011 #include "artdaq-utilities/Plugins/MetricMacros.hh" 00012 #include "send_gmetric.h" 00013 00017 namespace artdaq 00018 { 00022 class GangliaMetric : public MetricPlugin 00023 { 00024 private: 00025 std::string configFile_; 00026 std::string group_; 00027 std::string cluster_; 00028 00029 public: 00035 explicit GangliaMetric(fhicl::ParameterSet const& pset, std::string const& app_name) : MetricPlugin(pset, app_name) 00036 , configFile_(pset.get<std::string>("configFile", "/etc/ganglia/gmond.conf")) 00037 , group_(pset.get<std::string>("group", "ARTDAQ")) 00038 , cluster_(pset.get<std::string>("cluster", "")) 00039 { 00040 init_gmetric(configFile_.c_str()); 00041 } 00042 00043 virtual ~GangliaMetric() 00044 { 00045 MetricPlugin::stopMetrics(); 00046 destroy_gmetric(); 00047 } 00048 00053 std::string getLibName() const override { return "ganglia"; } 00057 void stopMetrics_() override { } 00061 void startMetrics_() override { } 00062 00069 void sendMetric_(const std::string& name, const std::string& value, const std::string& unit) override 00070 { 00071 send_gmetric(name.c_str(), value.c_str(), "string", 00072 unit.c_str(), "both", 15, 0, group_.c_str(), cluster_.c_str(), "", ""); 00073 } 00074 00081 void sendMetric_(const std::string& name, const int& value, const std::string& unit) override 00082 { 00083 send_gmetric(name.c_str(), std::to_string(value).c_str(), 00084 "int32", unit.c_str(), "both", 15, 0, group_.c_str(), cluster_.c_str(), "", ""); 00085 } 00086 00093 void sendMetric_(const std::string& name, const double& value, const std::string& unit) override 00094 { 00095 send_gmetric(name.c_str(), std::to_string(value).c_str(), 00096 "double", unit.c_str(), "both", 15, 0, group_.c_str(), cluster_.c_str(), "", ""); 00097 } 00098 00105 void sendMetric_(const std::string& name, const float& value, const std::string& unit) override 00106 { 00107 send_gmetric(name.c_str(), std::to_string(value).c_str(), 00108 "float", unit.c_str(), "both", 15, 0, group_.c_str(), cluster_.c_str(), "", ""); 00109 } 00110 00117 void sendMetric_(const std::string& name, const unsigned long int& value, const std::string& unit) override 00118 { 00119 send_gmetric(name.c_str(), std::to_string(value).c_str(), 00120 "uint32", unit.c_str(), "both", 15, 0, group_.c_str(), cluster_.c_str(), "", ""); 00121 } 00122 }; 00123 } //End namespace artdaq 00124 00125 DEFINE_ARTDAQ_METRIC(artdaq::GangliaMetric) 00126 00127 #endif //End ifndef __GANGLIA_METRIC__