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 <aspect/aspect_provider.h>
27 #include <aspect/clock.h>
28 #include <aspect/configurable.h>
29 #include <aspect/logging.h>
30 #include <core/threading/thread.h>
31 #include <core/utils/rwlock_vector.h>
32 #include <plugins/rrd/aspect/rrd_inifin.h>
33 #include <plugins/rrd/aspect/rrd_manager.h>
34 #include <utils/time/wait.h>
35 
36 class RRDThread : public fawkes::Thread,
37  public fawkes::LoggingAspect,
39  public fawkes::ClockAspect,
41  public fawkes::RRDManager
42 {
43 public:
44  RRDThread();
45  virtual ~RRDThread();
46 
47  virtual void init();
48  virtual void loop();
49  virtual void finalize();
50 
51  // for RRDManager
52  virtual void add_rrd(fawkes::RRDDefinition *rrd_def);
53  virtual void remove_rrd(fawkes::RRDDefinition *rrd_def);
54  virtual void add_graph(fawkes::RRDGraphDefinition *rrd_graph_def);
55 
56  virtual void add_data(const char *rrd_name, const char *format, ...);
57 
60 
61  void generate_graphs();
62 
63  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
64 protected:
65  virtual void
66  run()
67  {
68  Thread::run();
69  }
70 
71 private:
72  fawkes::RRDAspectIniFin rrd_aspect_inifin_;
73 
76 
77  fawkes::TimeWait *time_wait_;
78  float cfg_graph_interval_;
79 };
80 
81 #endif
fawkes::RRDGraphDefinition
Definition: rrd_descriptions.h:468
fawkes::RWLockVector< fawkes::RRDDefinition * >
fawkes::AspectProviderAspect
Definition: aspect_provider.h:39
RRDThread::loop
virtual void loop()
Code to execute in the thread.
Definition: rrd_thread.cpp:79
RRDThread::RRDThread
RRDThread()
Constructor.
Definition: rrd_thread.cpp:47
RRDThread::generate_graphs
void generate_graphs()
Generate all graphs.
Definition: rrd_thread.cpp:88
RRDThread::add_data
virtual void add_data(const char *rrd_name, const char *format,...)
Add data.
Definition: rrd_thread.cpp:224
fawkes::LoggingAspect
Definition: logging.h:36
RRDThread::remove_rrd
virtual void remove_rrd(fawkes::RRDDefinition *rrd_def)
Remove RRD.
Definition: rrd_thread.cpp:175
fawkes::RRDManager
Definition: rrd_manager.h:40
RRDThread::init
virtual void init()
Initialize the thread.
Definition: rrd_thread.cpp:61
RRDThread
Definition: rrd_thread.h:35
fawkes::RRDAspectIniFin
Definition: rrd_inifin.h:39
RRDThread::finalize
virtual void finalize()
Finalize the thread.
Definition: rrd_thread.cpp:73
RRDThread::get_rrds
virtual const fawkes::RWLockVector< fawkes::RRDDefinition * > & get_rrds() const
Get RRDs.
Definition: rrd_thread.cpp:269
RRDThread::add_rrd
virtual void add_rrd(fawkes::RRDDefinition *rrd_def)
Add RRD.
Definition: rrd_thread.cpp:115
fawkes::Thread
Definition: thread.h:44
fawkes::TimeWait
Definition: wait.h:36
fawkes::RRDDefinition
Definition: rrd_descriptions.h:166
RRDThread::~RRDThread
virtual ~RRDThread()
Destructor.
Definition: rrd_thread.cpp:56
RRDThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: rrd_thread.h:70
fawkes::ConfigurableAspect
Definition: configurable.h:36
RRDThread::get_graphs
virtual const fawkes::RWLockVector< fawkes::RRDGraphDefinition * > & get_graphs() const
Get graphs.
Definition: rrd_thread.cpp:275
fawkes::ClockAspect
Definition: clock.h:38
RRDThread::add_graph
virtual void add_graph(fawkes::RRDGraphDefinition *rrd_graph_def)
Add graph.
Definition: rrd_thread.cpp:202