0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Monitoring.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 of the
9  * 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 
22 #ifndef Hypertable_Master_Monitoring_h
23 #define Hypertable_Master_Monitoring_h
24 
25 #include "RangeServerStatistics.h"
26 
27 #include <Hypertable/Lib/KeySpec.h>
31 
32 #include <Common/StatsSystem.h>
33 #include <Common/String.h>
34 
35 #include <map>
36 #include <memory>
37 #include <mutex>
38 #include <deque>
39 #include <vector>
40 
41 namespace Hypertable {
42 
43  class Context;
44 
47  class Monitoring {
48 
49  public:
53  Monitoring(Context *context);
54 
55  void add_server(const String &location, const StatsSystem &system_info);
56 
57  void drop_server(const String &location);
58 
59  void add(std::vector<RangeServerStatistics> &stats);
60 
61  void change_id_mapping(const String &table_id, const String &table_name);
62 
63  void invalidate_id_mapping(const String &table_id);
64 
65  private:
66 
68  uint64_t timestamp;
69  int32_t range_count;
70  int32_t scanner_count;
71  int64_t file_count;
72  double scan_rate;
73  double update_rate;
74  double sync_rate;
80  int64_t qcache_max_mem;
81  int64_t qcache_fill;
83  int64_t bcache_max_mem;
84  int64_t bcache_fill;
85  double disk_used_pct;
86  int64_t disk_read_bytes;
88  int64_t disk_read_iops;
89  int64_t disk_write_iops;
90  int64_t vm_size;
91  int64_t vm_resident;
92  int64_t page_in;
93  int64_t page_out;
94  int64_t heap_size;
95  int64_t heap_slack;
96  int64_t tracked_memory;
97  double net_rx_rate;
98  double net_tx_rate;
99  double load_average;
100  double cpu_user;
101  double cpu_sys;
102  };
103 
104  struct table_rrd_data {
106  uint32_t range_count;
107  uint32_t scanner_count;
108  uint64_t cell_count;
109  uint64_t file_count;
110  uint64_t scans;
111  double scan_rate;
112  uint64_t cells_read;
113  uint64_t bytes_read;
114  uint64_t disk_bytes_read;
115  uint64_t updates;
116  double update_rate;
117  uint64_t cells_written;
118  uint64_t bytes_written;
119  uint64_t disk_used;
123  uint64_t memory_used;
135  };
136 
137  void create_dir(const String &dir);
138  void compute_clock_skew(int64_t server_timestamp, RangeServerStatistics *stats);
140  void update_rangeserver_rrd(const String &filename, struct rangeserver_rrd_data &rrd_data);
141  void run_rrdtool(std::vector<String> &command);
142 
143  void dump_rangeserver_summary_json(std::vector<RangeServerStatistics> &stats);
145 
146  void create_table_rrd(const String &filename);
147  void update_table_rrd(const String &filename, struct table_rrd_data &rrd_data);
148  void add_table_stats(std::vector<StatsTable> &table_stats,int64_t fetch_timestamp);
150  void dump_table_id_name_map();
151 
152 
153  typedef std::map<String, RangeServerStatistics *> RangeServerMap;
154  typedef std::map<String, table_rrd_data> TableStatMap;
155  typedef std::map<String, String> TableNameMap;
156 
159  RangeServerMap m_server_map;
160  TableStatMap m_table_stat_map;
161  TableStatMap m_prev_table_stat_map;
162  TableNameMap m_table_name_map;
169  unsigned char m_last_server_set_digest[16];
173  };
174 
175  typedef std::shared_ptr<Monitoring> MonitoringPtr;
176 }
177 
178 
179 #endif // Hypertable_Master_Monitoring_h
static std::mutex mutex
Definition: Logger.cc:43
void invalidate_id_mapping(const String &table_id)
Definition: Monitoring.cc:802
void create_rangeserver_rrd(const String &filename)
Definition: Monitoring.cc:415
static String filename
Definition: Config.cc:48
void add_server(const String &location, const StatsSystem &system_info)
Definition: Monitoring.cc:79
TableNameMap m_table_name_map
Definition: Monitoring.h:162
void dump_rangeserver_summary_json(std::vector< RangeServerStatistics > &stats)
Definition: Monitoring.cc:659
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
RangeServerMap m_server_map
Definition: Monitoring.h:159
void change_id_mapping(const String &table_id, const String &table_name)
Definition: Monitoring.cc:795
TableStatMap m_table_stat_map
Definition: Monitoring.h:160
Collecting and (de)serializing system-wide statistics.
std::map< String, table_rrd_data > TableStatMap
Definition: Monitoring.h:154
TableStatMap m_prev_table_stat_map
Definition: Monitoring.h:161
NameIdMapperPtr m_namemap_ptr
Definition: Monitoring.h:171
std::shared_ptr< Monitoring > MonitoringPtr
Definition: Monitoring.h:175
void add(std::vector< RangeServerStatistics > &stats)
Definition: Monitoring.cc:118
void update_table_rrd(const String &filename, struct table_rrd_data &rrd_data)
Definition: Monitoring.cc:528
Monitoring(Context *context)
Constructor.
Definition: Monitoring.cc:47
void compute_clock_skew(int64_t server_timestamp, RangeServerStatistics *stats)
Definition: Monitoring.cc:389
void update_rangeserver_rrd(const String &filename, struct rangeserver_rrd_data &rrd_data)
Definition: Monitoring.cc:563
Collects, serializes and deserializes system-wide statistics.
Definition: StatsSystem.h:43
Hypertable definitions
void create_table_rrd(const String &filename)
Definition: Monitoring.cc:479
std::map< String, RangeServerStatistics * > RangeServerMap
Definition: Monitoring.h:153
uint64_t table_stats_timestamp
Definition: Monitoring.h:170
void drop_server(const String &location)
Definition: Monitoring.cc:95
unsigned char m_last_server_set_digest[16]
Definition: Monitoring.h:169
Execution context for the Master.
Definition: Context.h:85
A String class based on std::string.
void run_rrdtool(std::vector< String > &command)
Definition: Monitoring.cc:806
int32_t m_monitoring_interval
Definition: Monitoring.h:166
void create_dir(const String &dir)
Definition: Monitoring.cc:68
void add_table_stats(std::vector< StatsTable > &table_stats, int64_t fetch_timestamp)
Definition: Monitoring.cc:350
std::shared_ptr< NameIdMapper > NameIdMapperPtr
Smart pointer to NameIdMapper.
Definition: NameIdMapper.h:121
std::map< String, String > TableNameMap
Definition: Monitoring.h:155