Fawkes API  Fawkes Development Version
mongorrd_thread.h
1 
2 /***************************************************************************
3  * mongorrd_thread.h - MongoDB RRD thread
4  *
5  * Created: Sat Jan 15 18:42:12 2011
6  * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_MONGORRD_MONGORRD_THREAD_H_
24 #define __PLUGINS_MONGORRD_MONGORRD_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 #include <aspect/logging.h>
28 #include <aspect/configurable.h>
29 #include <aspect/clock.h>
30 #include <plugins/mongodb/aspect/mongodb.h>
31 #include <plugins/rrd/aspect/rrd.h>
32 #include <config/change_handler.h>
33 
34 namespace fawkes {
35  class TimeWait;
36 }
37 
39 : public fawkes::Thread,
40  public fawkes::LoggingAspect,
42  public fawkes::ClockAspect,
43  public fawkes::MongoDBAspect,
44  public fawkes::RRDAspect,
46 {
47  public:
49  virtual ~MongoRRDThread();
50 
51  virtual void init();
52  virtual void loop();
53  virtual void finalize();
54 
55  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
56  protected: virtual void run() { Thread::run(); }
57 
58  private:
59  void add_dbstats(const char *path, std::string dbname);
60  void remove_dbstats(const char *path);
61 
62  virtual void config_tag_changed(const char *new_tag);
63  virtual void config_value_changed(const fawkes::Configuration::ValueIterator *v);
64  virtual void config_comment_changed(const fawkes::Configuration::ValueIterator *v);
65  virtual void config_value_erased(const char *path);
66 
67  private:
68  fawkes::TimeWait *__timewait;
69 
70  fawkes::RRDDefinition *__opcounters_rrd;
71  fawkes::RRDDefinition *__memory_rrd;
72  fawkes::RRDDefinition *__indexes_rrd;
73  fawkes::RRDDefinition *__locks_rrd;
74 
75  fawkes::RRDGraphDefinition *__opcounters_graph;
76  fawkes::RRDGraphDefinition *__memory_graph;
77  fawkes::RRDGraphDefinition *__indexes_graph;
78 
79  /// @cond INTERNALS
80  typedef struct {
81  std::string db_name;
82  std::string rrd_name;
83  std::string conf_path;
88  } DbStatsInfo;
89  /// @endcond
90 
91  typedef std::map<std::string, DbStatsInfo> DbStatsMap;
92  DbStatsMap __dbstats;
93 };
94 
95 #endif
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
Fawkes library namespace.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
Interface for configuration change handling.
Thread class encapsulation of pthreads.
Definition: thread.h:42
Thread aspect to access MongoDB.
Definition: mongodb.h:40
Thread aspect create, update, and graph round-robin databases (RRD).
Definition: rrd.h:36
Class representing a graph definition.
virtual void run()
Stub to see name in backtrace for easier debugging.
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to access configuration data.
Definition: configurable.h:35
Iterator interface to iterate over config values.
Definition: config.h:72
MongoDB RRD Thread.
Time wait utility.
Definition: wait.h:32