Ganglia metrics collector. More...
#include <MetricsCollectorGanglia.h>
Public Member Functions | |
MetricsCollectorGanglia (const std::string &component, PropertiesPtr &props) | |
Constructor. More... | |
~MetricsCollectorGanglia () | |
Destructor. More... | |
void | update (const std::string &name, const std::string &value) override |
Updates string metric value. More... | |
void | update (const std::string &name, int16_t value) override |
Updates short integer metric value. More... | |
void | update (const std::string &name, int32_t value) override |
Updates integer metric value. More... | |
void | update (const std::string &name, float value) override |
Updates float metric value. More... | |
void | update (const std::string &name, double value) override |
Updates double metric value. More... | |
void | publish () override |
Publishes metric values to Ganglia hypertable extension. More... | |
Private Member Functions | |
void | connect () |
Connects to Ganglia hypertable extension receive port. More... | |
Private Attributes | |
std::mutex | m_mutex |
Mutex for serializing access to members More... | |
std::string | m_prefix |
Metric name prefix ("ht." + component + ".") More... | |
uint16_t | m_port |
Ganglia hypertable extension listen port. More... | |
int | m_sd {} |
Datagram send socket. More... | |
std::string | m_message |
Persistent string for holding JSON string. More... | |
std::unordered_map < std::string, std::string > | m_values_string |
Map holding string metric values. More... | |
std::unordered_map < std::string, int32_t > | m_values_int |
Map holding integer metric values. More... | |
std::unordered_map < std::string, double > | m_values_double |
Map holding floating point metric values. More... | |
bool | m_connected {} |
Flag indicating if socket is connected. More... | |
bool | m_disabled {} |
Flag indicating if publishing is disabled. More... | |
Ganglia metrics collector.
Definition at line 45 of file MetricsCollectorGanglia.h.
MetricsCollectorGanglia::MetricsCollectorGanglia | ( | const std::string & | component, |
PropertiesPtr & | props | ||
) |
Constructor.
Creates a datagram send socket and binds it to an arbitrary interface and ephemeral port. Initializes m_prefix to "ht." + component
+ ".".
component | Hypertable component ("fsbroker", "hyperspace, "master", "rangeserver", or "thriftbroker") |
props | Properties object |
Definition at line 55 of file MetricsCollectorGanglia.cc.
MetricsCollectorGanglia::~MetricsCollectorGanglia | ( | ) |
Destructor.
Closes datagram socket (m_sd).
Definition at line 86 of file MetricsCollectorGanglia.cc.
|
private |
Connects to Ganglia hypertable extension receive port.
Connects m_sd to "localhost", port m_port. Throws an exception on error, otherwise sets m_connected to true.
Exception | with code set to Error::COMM_CONNECT_ERROR |
Definition at line 176 of file MetricsCollectorGanglia.cc.
|
overridevirtual |
Publishes metric values to Ganglia hypertable extension.
Constructs a JSON object containing the metrics key/value pairs constructed from the m_values_string, m_values_int, and m_values_double maps. The JSON string is sent to the the Ganglia hyperspace extension by sending it in the form of a datagram packet over m_sd.
Implements Hypertable::MetricsCollector.
Definition at line 115 of file MetricsCollectorGanglia.cc.
|
overridevirtual |
Updates string metric value.
Inserts value
into m_values_string map using a key that is formulated as m_prefix + name
.
name | Relative name of metric |
value | Metric value |
Implements Hypertable::MetricsCollector.
Definition at line 90 of file MetricsCollectorGanglia.cc.
|
overridevirtual |
Updates short integer metric value.
Inserts value
into m_values_int map using a key that is formulated as m_prefix + name
.
name | Relative name of metric |
value | Metric value |
Implements Hypertable::MetricsCollector.
Definition at line 95 of file MetricsCollectorGanglia.cc.
|
overridevirtual |
Updates integer metric value.
Inserts value
into m_values_int map using a key that is formulated as m_prefix + name
.
name | Relative name of metric |
value | Metric value |
Implements Hypertable::MetricsCollector.
Definition at line 100 of file MetricsCollectorGanglia.cc.
|
overridevirtual |
Updates float metric value.
Inserts value
into m_values_double map using a key that is formulated as m_prefix + name
.
name | Relative name of metric |
value | Metric value |
Implements Hypertable::MetricsCollector.
Definition at line 105 of file MetricsCollectorGanglia.cc.
|
overridevirtual |
Updates double metric value.
Inserts value
into m_values_double map using a key that is formulated as m_prefix + name
.
name | Relative name of metric |
value | Metric value |
Implements Hypertable::MetricsCollector.
Definition at line 110 of file MetricsCollectorGanglia.cc.
|
private |
Flag indicating if socket is connected.
Definition at line 137 of file MetricsCollectorGanglia.h.
|
private |
Flag indicating if publishing is disabled.
Definition at line 140 of file MetricsCollectorGanglia.h.
|
private |
Persistent string for holding JSON string.
Definition at line 125 of file MetricsCollectorGanglia.h.
|
private |
Mutex for serializing access to members
Definition at line 113 of file MetricsCollectorGanglia.h.
|
private |
Ganglia hypertable extension listen port.
Definition at line 119 of file MetricsCollectorGanglia.h.
|
private |
Metric name prefix ("ht." + component + ".")
Definition at line 116 of file MetricsCollectorGanglia.h.
|
private |
Datagram send socket.
Definition at line 122 of file MetricsCollectorGanglia.h.
|
private |
Map holding floating point metric values.
Definition at line 134 of file MetricsCollectorGanglia.h.
|
private |
Map holding integer metric values.
Definition at line 131 of file MetricsCollectorGanglia.h.
|
private |
Map holding string metric values.
Definition at line 128 of file MetricsCollectorGanglia.h.