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 <aspect/clock.h>
27 #include <aspect/configurable.h>
28 #include <aspect/logging.h>
29 #include <config/change_handler.h>
30 #include <core/threading/thread.h>
31 #include <plugins/mongodb/aspect/mongodb.h>
32 #include <plugins/rrd/aspect/rrd.h>
33 
34 namespace fawkes {
35 class TimeWait;
36 }
37 
39  public fawkes::LoggingAspect,
41  public fawkes::ClockAspect,
42  public fawkes::MongoDBAspect,
43  public fawkes::RRDAspect,
45 {
46 public:
48  virtual ~MongoRRDThread();
49 
50  virtual void init();
51  virtual void loop();
52  virtual void finalize();
53 
54  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
55 protected:
56  virtual void
57  run()
58  {
59  Thread::run();
60  }
61 
62 private:
63  void add_dbstats(const char *path, std::string dbname);
64  void remove_dbstats(const char *path);
65 
66  virtual void config_tag_changed(const char *new_tag);
67  virtual void config_value_changed(const fawkes::Configuration::ValueIterator *v);
68  virtual void config_comment_changed(const fawkes::Configuration::ValueIterator *v);
69  virtual void config_value_erased(const char *path);
70 
71 private:
72  fawkes::TimeWait *timewait_;
73 
74  fawkes::RRDDefinition *opcounters_rrd_;
75  fawkes::RRDDefinition *memory_rrd_;
76  fawkes::RRDDefinition *indexes_rrd_;
77  fawkes::RRDDefinition *locks_rrd_;
78 
79  fawkes::RRDGraphDefinition *opcounters_graph_;
80  fawkes::RRDGraphDefinition *memory_graph_;
81  fawkes::RRDGraphDefinition *indexes_graph_;
82 
83  /// @cond INTERNALS
84  typedef struct
85  {
86  std::string db_name;
87  std::string rrd_name;
88  std::string conf_path;
93  } DbStatsInfo;
94  /// @endcond
95 
96  typedef std::map<std::string, DbStatsInfo> DbStatsMap;
97  DbStatsMap dbstats_;
98 };
99 
100 #endif
MongoDB RRD Thread.
virtual ~MongoRRDThread()
Destructor.
MongoRRDThread()
Constructor.
virtual void run()
Stub to see name in backtrace for easier debugging.
virtual void finalize()
Finalize the thread.
virtual void loop()
Code to execute in the thread.
virtual void init()
Initialize the thread.
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:34
Thread aspect to access configuration data.
Definition: configurable.h:33
Interface for configuration change handling.
Iterator interface to iterate over config values.
Definition: config.h:72
Thread aspect to log output.
Definition: logging.h:33
Thread aspect to access MongoDB.
Definition: mongodb.h:39
Thread aspect create, update, and graph round-robin databases (RRD).
Definition: rrd.h:36
Class representing a graph definition.
Thread class encapsulation of pthreads.
Definition: thread.h:46
Time wait utility.
Definition: wait.h:33
Fawkes library namespace.