Fawkes API  Fawkes Development Version
rrd_thread.h
00001 
00002 /***************************************************************************
00003  *  rrd_thread.h - RRD thread
00004  *
00005  *  Created: Fri Dec 17 00:32:48 2010
00006  *  Copyright  2006-2010  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #ifndef __PLUGINS_RRD_RRD_THREAD_H_
00024 #define __PLUGINS_RRD_RRD_THREAD_H_
00025 
00026 #include <plugins/rrd/aspect/rrd_manager.h>
00027 #include <plugins/rrd/aspect/rrd_inifin.h>
00028 #include <core/threading/thread.h>
00029 #include <core/utils/rwlock_vector.h>
00030 #include <aspect/logging.h>
00031 #include <aspect/configurable.h>
00032 #include <aspect/clock.h>
00033 #include <aspect/aspect_provider.h>
00034 #include <utils/time/wait.h>
00035 
00036 class RRDThread
00037 : public fawkes::Thread,
00038   public fawkes::LoggingAspect,
00039   public fawkes::ConfigurableAspect,
00040   public fawkes::ClockAspect,
00041   public fawkes::AspectProviderAspect,
00042   public fawkes::RRDManager
00043 {
00044  public:
00045   RRDThread();
00046   virtual ~RRDThread();
00047 
00048   virtual void init();
00049   virtual void loop();
00050   virtual void finalize();
00051 
00052   // for RRDManager
00053   virtual void add_rrd(fawkes::RRDDefinition *rrd_def);
00054   virtual void remove_rrd(fawkes::RRDDefinition *rrd_def);
00055   virtual void add_graph(fawkes::RRDGraphDefinition *rrd_graph_def);
00056 
00057   virtual void add_data(const char *rrd_name, const char *format, ...);
00058 
00059   virtual const fawkes::RWLockVector<fawkes::RRDDefinition *> & get_rrds() const;
00060   virtual const fawkes::RWLockVector<fawkes::RRDGraphDefinition *> &
00061     get_graphs() const;
00062 
00063   void generate_graphs();
00064 
00065  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
00066  protected: virtual void run() { Thread::run(); }
00067 
00068  private:
00069   fawkes::RRDAspectIniFin     __rrd_aspect_inifin;
00070 
00071   fawkes::RWLockVector<fawkes::RRDDefinition *>      __rrds;
00072   fawkes::RWLockVector<fawkes::RRDGraphDefinition *> __graphs;
00073 
00074   fawkes::TimeWait           *__time_wait;
00075   float                       __cfg_graph_interval;
00076   unsigned int                __loop_count;
00077 };
00078 
00079 #endif