Fawkes API  Fawkes Development Version
rrd_thread.h
1 
2 /***************************************************************************
3  * rrd_thread.h - RRD thread
4  *
5  * Created: Fri Dec 17 00:32:48 2010
6  * Copyright 2006-2010 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_RRD_RRD_THREAD_H_
24 #define __PLUGINS_RRD_RRD_THREAD_H_
25 
26 #include <plugins/rrd/aspect/rrd_manager.h>
27 #include <plugins/rrd/aspect/rrd_inifin.h>
28 #include <core/threading/thread.h>
29 #include <core/utils/rwlock_vector.h>
30 #include <aspect/logging.h>
31 #include <aspect/configurable.h>
32 #include <aspect/clock.h>
33 #include <aspect/aspect_provider.h>
34 #include <utils/time/wait.h>
35 
36 class RRDThread
37 : public fawkes::Thread,
38  public fawkes::LoggingAspect,
40  public fawkes::ClockAspect,
42  public fawkes::RRDManager
43 {
44  public:
45  RRDThread();
46  virtual ~RRDThread();
47 
48  virtual void init();
49  virtual void loop();
50  virtual void finalize();
51 
52  // for RRDManager
53  virtual void add_rrd(fawkes::RRDDefinition *rrd_def);
54  virtual void remove_rrd(fawkes::RRDDefinition *rrd_def);
55  virtual void add_graph(fawkes::RRDGraphDefinition *rrd_graph_def);
56 
57  virtual void add_data(const char *rrd_name, const char *format, ...);
58 
61  get_graphs() const;
62 
63  void generate_graphs();
64 
65  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
66  protected: virtual void run() { Thread::run(); }
67 
68  private:
69  fawkes::RRDAspectIniFin __rrd_aspect_inifin;
70 
73 
74  fawkes::TimeWait *__time_wait;
75  float __cfg_graph_interval;
76 };
77 
78 #endif
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
Interface for a RRD connection creator.
Definition: rrd_manager.h:40
virtual const fawkes::RWLockVector< fawkes::RRDDefinition * > & get_rrds() const
Get RRDs.
Definition: rrd_thread.cpp:283
virtual void add_rrd(fawkes::RRDDefinition *rrd_def)
Add RRD.
Definition: rrd_thread.cpp:116
Thread class encapsulation of pthreads.
Definition: thread.h:42
virtual void finalize()
Finalize the thread.
Definition: rrd_thread.cpp:74
virtual void loop()
Code to execute in the thread.
Definition: rrd_thread.cpp:80
virtual void add_graph(fawkes::RRDGraphDefinition *rrd_graph_def)
Add graph.
Definition: rrd_thread.cpp:212
virtual ~RRDThread()
Destructor.
Definition: rrd_thread.cpp:56
virtual void remove_rrd(fawkes::RRDDefinition *rrd_def)
Remove RRD.
Definition: rrd_thread.cpp:185
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: rrd_thread.h:66
Class representing a graph definition.
virtual const fawkes::RWLockVector< fawkes::RRDGraphDefinition * > & get_graphs() const
Get graphs.
Definition: rrd_thread.cpp:290
RRD Thread.
Definition: rrd_thread.h:36
Thread aspect to log output.
Definition: logging.h:35
Thread aspect provide a new aspect.
Thread aspect to access configuration data.
Definition: configurable.h:35
virtual void init()
Initialize the thread.
Definition: rrd_thread.cpp:62
RRDThread()
Constructor.
Definition: rrd_thread.cpp:47
Time wait utility.
Definition: wait.h:32
RRDAspect initializer/finalizer.
Definition: rrd_inifin.h:38
Vector with a lock.
Definition: rwlock_vector.h:37
void generate_graphs()
Generate all graphs.
Definition: rrd_thread.cpp:90
virtual void add_data(const char *rrd_name, const char *format,...)
Add data.
Definition: rrd_thread.cpp:236