7 #ifndef __GANGLIA_METRIC__
8 #define __GANGLIA_METRIC__ 1
10 #include "artdaq-utilities/Plugins/MetricMacros.hh"
11 #include "fhiclcpp/fwd.h"
14 #include <boost/filesystem.hpp>
15 namespace bfs = boost::filesystem;
26 std::string configFile_;
37 explicit GangliaMetric(fhicl::ParameterSet
const& pset, std::string
const& app_name)
38 : MetricPlugin(pset, app_name),
39 configFile_(pset.get<std::string>(
"configFile",
"")),
40 group_(pset.get<std::string>(
"group",
"ARTDAQ")),
41 cluster_(pset.get<std::string>(
"cluster",
"")) {
42 if (configFile_ ==
"" || bfs::exists(configFile_)) {
45 throw cet::exception(
"GangliaMetric") <<
"Unable to configure Ganglia";
48 throw cet::exception(
"GangliaMetric") <<
"Configuration file " << configFile_ <<
" does not exist!";
53 MetricPlugin::stopMetrics();
61 std::string
getLibName()
const override {
return "ganglia"; }
77 void sendMetric_(
const std::string& name,
const std::string& value,
const std::string& unit)
override {
78 send_gmetric(name.c_str(), value.c_str(),
"string", unit.c_str(),
"both", 15, 0, group_.c_str(), cluster_.c_str(),
88 void sendMetric_(
const std::string& name,
const int& value,
const std::string& unit)
override {
89 send_gmetric(name.c_str(), std::to_string(value).c_str(),
"int32", unit.c_str(),
"both", 15, 0, group_.c_str(),
90 cluster_.c_str(),
"",
"");
99 void sendMetric_(
const std::string& name,
const double& value,
const std::string& unit)
override {
100 send_gmetric(name.c_str(), std::to_string(value).c_str(),
"double", unit.c_str(),
"both", 15, 0, group_.c_str(),
101 cluster_.c_str(),
"",
"");
110 void sendMetric_(
const std::string& name,
const float& value,
const std::string& unit)
override {
111 send_gmetric(name.c_str(), std::to_string(value).c_str(),
"float", unit.c_str(),
"both", 15, 0, group_.c_str(),
112 cluster_.c_str(),
"",
"");
121 void sendMetric_(
const std::string& name,
const unsigned long int& value,
const std::string& unit)
override {
122 send_gmetric(name.c_str(), std::to_string(value).c_str(),
"uint32", unit.c_str(),
"both", 15, 0, group_.c_str(),
123 cluster_.c_str(),
"",
"");
130 #endif // End ifndef __GANGLIA_METRIC__
std::string getLibName() const override
Gets the unique library name of this plugin.
void sendMetric_(const std::string &name, const double &value, const std::string &unit) override
Send a double metric to Ganglia.
int init_gmetric(const char *conf)
Initialize Ganglia.
void stopMetrics_() override
Ganglia does not need any specific action on stop.
void destroy_gmetric()
Close connection to gmond.
void sendMetric_(const std::string &name, const float &value, const std::string &unit) override
Send a float metric to Ganglia.
GangliaMetric(fhicl::ParameterSet const &pset, std::string const &app_name)
Construct an instance of the Ganglia metric.
int send_gmetric(const char *name, const char *value, const char *type, const char *units, const char *slope, int tmax, int dmax, const char *group, const char *cluster, const char *desc, const char *title)
Send a metric to gmond.
void sendMetric_(const std::string &name, const std::string &value, const std::string &unit) override
Send a string metric to Ganglia.
void sendMetric_(const std::string &name, const int &value, const std::string &unit) override
Send a integer metric to Ganglia (truncated to int32)
An instance of the MetricPlugin class that sends metric data to Ganglia.
void startMetrics_() override
Ganglia does not need any specific action on start.
void sendMetric_(const std::string &name, const unsigned long int &value, const std::string &unit) override
Send an unsigned long metric to Ganglia (truncated to uint32)