0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MetricsCollectorGanglia.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3
9  * of the License.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
27 
28 #ifndef Common_MetricsCollectorGanglia_h
29 #define Common_MetricsCollectorGanglia_h
30 
31 #include "MetricsCollector.h"
32 
33 #include <Common/Properties.h>
34 
35 #include <memory>
36 #include <mutex>
37 #include <unordered_map>
38 
39 namespace Hypertable {
40 
43 
46  public:
47 
55  MetricsCollectorGanglia(const std::string &component, PropertiesPtr &props);
56 
60 
66  void update(const std::string &name, const std::string &value) override;
67 
73  void update(const std::string &name, int16_t value) override;
74 
80  void update(const std::string &name, int32_t value) override;
81 
87  void update(const std::string &name, float value) override;
88 
94  void update(const std::string &name, double value) override;
95 
102  void publish() override;
103 
104  private:
105 
110  void connect();
111 
114 
116  std::string m_prefix;
117 
119  uint16_t m_port {};
120 
122  int m_sd {};
123 
125  std::string m_message;
126 
128  std::unordered_map<std::string, std::string> m_values_string;
129 
131  std::unordered_map<std::string, int32_t> m_values_int;
132 
134  std::unordered_map<std::string, double> m_values_double;
135 
137  bool m_connected {};
138 
140  bool m_disabled {};
141  };
142 
144  typedef std::shared_ptr<MetricsCollectorGanglia> MetricsCollectorGangliaPtr;
145 
147 }
148 
149 #endif // Common_MetricsCollectorGanglia_h
Declarations for MetricsCollector.
static std::mutex mutex
Definition: Logger.cc:43
Program options handling.
std::string m_prefix
Metric name prefix ("ht." + component + ".")
std::mutex m_mutex
Mutex for serializing access to members
uint16_t m_port
Ganglia hypertable extension listen port.
Abstract metrics collector.
std::unordered_map< std::string, std::string > m_values_string
Map holding string metric values.
std::shared_ptr< Properties > PropertiesPtr
Definition: Properties.h:447
std::unordered_map< std::string, int32_t > m_values_int
Map holding integer metric values.
std::shared_ptr< MetricsCollectorGanglia > MetricsCollectorGangliaPtr
Smart pointer to MetricsCollectorGanglia.
Hypertable definitions
void update(const std::string &name, const std::string &value) override
Updates string metric value.
void connect()
Connects to Ganglia hypertable extension receive port.
MetricsCollectorGanglia(const std::string &component, PropertiesPtr &props)
Constructor.
bool m_connected
Flag indicating if socket is connected.
std::unordered_map< std::string, double > m_values_double
Map holding floating point metric values.
bool m_disabled
Flag indicating if publishing is disabled.
std::string m_message
Persistent string for holding JSON string.
void publish() override
Publishes metric values to Ganglia hypertable extension.