Commit 6a552c9a authored by Pavel Vainerman's avatar Pavel Vainerman

По аналогии с другими процессами (MySQL,SQLite) переименовал RRDStorage --> RRDServer

parent a8384a95
...@@ -262,8 +262,8 @@ AC_CONFIG_FILES([Makefile ...@@ -262,8 +262,8 @@ AC_CONFIG_FILES([Makefile
extensions/SharedMemory/Makefile extensions/SharedMemory/Makefile
extensions/SharedMemory/libUniSetSharedMemory.pc extensions/SharedMemory/libUniSetSharedMemory.pc
extensions/SharedMemoryPlus/Makefile extensions/SharedMemoryPlus/Makefile
extensions/RRDStorage/Makefile extensions/RRDServer/Makefile
extensions/RRDStorage/libUniSetRRDStorage.pc extensions/RRDServer/libUniSetRRDServer.pc
extensions/tests/Makefile extensions/tests/Makefile
python/lib/Makefile python/lib/Makefile
python/lib/pyUniSet/Makefile python/lib/pyUniSet/Makefile
......
if DISABLE_RRD
else
bin_PROGRAMS = @PACKAGE@-rrdserver bin_PROGRAMS = @PACKAGE@-rrdserver
RRD_VER=@LIBVER@ RRD_VER=@LIBVER@
...@@ -35,5 +31,3 @@ pkgconfig_DATA = libUniSetRRDServer.pc ...@@ -35,5 +31,3 @@ pkgconfig_DATA = libUniSetRRDServer.pc
all-local: all-local:
ln -sf ../RRDServer/$(devel_include_HEADERS) ../include ln -sf ../RRDServer/$(devel_include_HEADERS) ../include
endif
\ No newline at end of file
...@@ -335,4 +335,3 @@ void RRDServer::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -335,4 +335,3 @@ void RRDServer::timerInfo( UniSetTypes::TimerMessage* tm )
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -4,4 +4,3 @@ ln -s -f ../../Utilities/scripts/uniset-start.sh ...@@ -4,4 +4,3 @@ ln -s -f ../../Utilities/scripts/uniset-start.sh
ln -s -f ../../Utilities/scripts/uniset-stop.sh stop.sh ln -s -f ../../Utilities/scripts/uniset-stop.sh stop.sh
ln -s -f ../../Utilities/scripts/uniset-functions.sh ln -s -f ../../Utilities/scripts/uniset-functions.sh
ln -s -f ../../conf/test.xml test.xml ln -s -f ../../conf/test.xml test.xml
...@@ -3,4 +3,3 @@ ...@@ -3,4 +3,3 @@
uniset-start.sh -f ./uniset-rrdstorage --confile test.xml \ uniset-start.sh -f ./uniset-rrdstorage --confile test.xml \
--rrd-name RRDStorage1 \ --rrd-name RRDStorage1 \
--dlog-add-levels info,crit,warn --dlog-add-levels info,crit,warn
bin_PROGRAMS = @PACKAGE@-rrdstorage
RRD_VER=@LIBVER@
lib_LTLIBRARIES = libUniSetRRDStorage.la
libUniSetRRDStorage_la_LDFLAGS = -version-info $(RRD_VER)
libUniSetRRDStorage_la_LIBADD = $(top_builddir)/lib/libUniSet.la \
$(top_builddir)/extensions/SharedMemory/libUniSetSharedMemory.la \
$(top_builddir)/extensions/lib/libUniSetExtensions.la \
$(SIGC_LIBS) $(RRD_LIBS)
libUniSetRRDStorage_la_CXXFLAGS = -I$(top_builddir)/extensions/include \
-I$(top_builddir)/extensions/SharedMemory \
$(SIGC_CFLAGS) $(RRD_CFLAGS)
libUniSetRRDStorage_la_SOURCES = RRDStorage.cc
@PACKAGE@_rrdstorage_SOURCES = main.cc
@PACKAGE@_rrdstorage_LDADD = libUniSetRRDStorage.la $(top_builddir)/lib/libUniSet.la \
$(top_builddir)/extensions/SharedMemory/libUniSetSharedMemory.la \
$(top_builddir)/extensions/lib/libUniSetExtensions.la \
$(SIGC_LIBS) $(RRD_LIBS)
@PACKAGE@_rrdstorage_CXXFLAGS = -I$(top_builddir)/extensions/include \
-I$(top_builddir)/extensions/SharedMemory \
$(SIGC_CFLAGS) $(RRD_CFLAGS)
# install
devel_include_HEADERS = *.h
devel_includedir = $(pkgincludedir)/extensions
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libUniSetRRDStorage.pc
all-local:
ln -sf ../RRDStorage/$(devel_include_HEADERS) ../include
#ifndef _RRDStorage_H_
#define _RRDStorage_H_
// -----------------------------------------------------------------------------
#include "UObject_SK.h"
#include "SMInterface.h"
#include "SharedMemory.h"
#include "extensions/Extensions.h"
// -----------------------------------------------------------------------------
/*!
"RoundRobinDatabase" - реализация циклического хранилища.
Процесс реализует циклическое хранение данных (от датчиков) и позволяет
конфигурировать любое количество rrd-баз и входящих в них "источников".
Пример секции конфигурации:
\code
<RRDStorage1 name="RRDStorage1">
<rrd filename="rrdtest.rrd" filter_field="rrd" filter_value="1" step="5" ds_field="rrd1_ds" overwrite="0">
<item rra="RRA:AVERAGE:0.5:1:4320"/>
<item rra="RRA:MAX:0.5:1:4320"/>
</rrd>
<rrd filename="rrdtest2.rrd" filter_field="rrd" filter_value="2" step="10" ds_field="rrd2_ds" overwrite="0">
<item rra="RRA:AVERAGE:0.5:1:4320"/>
<item rra="RRA:MAX:0.5:1:4320"/>
</rrd>
</RRDStorage1>
\endcode
Где:
\b filename - имя создаваемого rrd-файла
\b filter_field - поле у датчика, определяющее, что его нужно сохранять в БД
\b filter_value - значение filter_field, определяющее, что датчик нужно сохранять в БД
\b ds_field - поле определяющее, параметр задающий формат хранения. Если \a ds_field не задано,
то будет браться filter_field+filter_value+'_ds'.
\b step - период обновления данных (в секундах)
\b overwrite - [0,1]. Пересоздавать ли БД, если файл уже существует.
При этом в секции <sensors> у датчиков прописываются параметры относящиеся к источнику:
\code
<sensors>
...
<item id="54" iotype="AI" name="AI54_S" textname="AI sensor 54" rrd="1" rrd1_ds="GAUGE:20:U:U"/>
<item id="55" iotype="AI" name="AI55_S" textname="AI sensor 55" rrd="1" rrd1_ds="GAUGE:20:U:U"/>
<item id="56" iotype="AI" name="AI56_S" textname="AI sensor 56" rrd="2" rrd2_ds="COUNTER:20:U:U"/>
<item id="57" iotype="AI" name="AI57_S" textname="AI sensor 57" rrd="2" rrd2_ds="DERIVE:20:U:U"/>
...
</sensors>
\endcode
*/
class RRDStorage:
public UObject_SK
{
public:
RRDStorage( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
const std::string prefix="rrd", DebugStream& log=UniSetExtensions::dlog );
virtual ~RRDStorage();
/*! глобальная функция для инициализации объекта */
static RRDStorage* init_rrdstorage( int argc, const char* const* argv,
UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
const std::string prefix="rrd" );
/*! глобальная функция для вывода help-а */
static void help_print( int argc, const char* const* argv );
protected:
RRDStorage();
virtual void askSensors( UniversalIO::UIOCommand cmd );
virtual void sensorInfo( UniSetTypes::SensorMessage* sm );
virtual void timerInfo( UniSetTypes::TimerMessage* tm );
virtual void sysCommand( UniSetTypes::SystemMessage* sm );
virtual void initRRD( xmlNode* cnode, int tmID );
void step();
SMInterface* shm;
struct DSInfo
{
std::string dsname;
long value;
DSInfo( const std::string& dsname, long defval ):
dsname(dsname),value(defval){}
};
typedef std::map<UniSetTypes::ObjectId,DSInfo> DSMap;
struct RRDInfo
{
std::string filename;
long tid;
long sec;
DSMap dsmap;
RRDInfo( const std::string& fname, long tmID, long sec, const DSMap& ds ):
filename(fname),tid(tmID),sec(sec),dsmap(ds){}
};
typedef std::list<RRDInfo> RRDList;
RRDList rrdlist;
private:
std::string prefix;
};
// -----------------------------------------------------------------------------
#endif // _RRDStorage_H_
// -----------------------------------------------------------------------------
#!/bin/sh
ln -s -f ../../Utilities/scripts/uniset-start.sh
ln -s -f ../../Utilities/scripts/uniset-stop.sh stop.sh
ln -s -f ../../Utilities/scripts/uniset-functions.sh
ln -s -f ../../conf/test.xml test.xml
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libUniSetRRDStorage
Description: Support library for UniSetRRDStorage
Requires: libUniSetExtensions librrd
Version: @VERSION@
Libs: -L${libdir} -lUniSetRRDStorage
Cflags: -I${includedir}/uniset
#include <sstream>
#include "RRDStorage.h"
#include "Configuration.h"
#include "Debug.h"
#include "ObjectsActivator.h"
#include "Extensions.h"
// -----------------------------------------------------------------------------
using namespace std;
using namespace UniSetTypes;
using namespace UniSetExtensions;
// -----------------------------------------------------------------------------
int main( int argc, const char** argv )
{
if( argc>1 && (!strcmp(argv[1],"--help") || !strcmp(argv[1],"-h")) )
{
cout << "--smemory-id objectName - SharedMemory objectID. Default: autodetect" << endl;
cout << "--confile filename - configuration file. Default: configure.xml" << endl;
cout << "--rrdstorage-logfile filename - logfilename. Default: rrdstorage.log" << endl;
cout << endl;
RRDStorage::help_print(argc, argv);
return 0;
}
try
{
string confile=UniSetTypes::getArgParam("--confile",argc, argv, "configure.xml");
conf = new Configuration( argc, argv, confile );
string logfilename(conf->getArgParam("--rrdstorage-logfile"));
if( logfilename.empty() )
logfilename = "rrdstorage.log";
conf->initDebug(dlog,"dlog");
std::ostringstream logname;
string dir(conf->getLogDir());
logname << dir << logfilename;
unideb.logFile( logname.str() );
dlog.logFile( logname.str() );
ObjectId shmID = DefaultObjectId;
string sID = conf->getArgParam("--smemory-id");
if( !sID.empty() )
shmID = conf->getControllerID(sID);
else
shmID = getSharedMemoryID();
if( shmID == DefaultObjectId )
{
cerr << sID << "? SharedMemoryID not found in " << conf->getControllersSection() << " section" << endl;
return 1;
}
RRDStorage* db = RRDStorage::init_rrdstorage(argc,argv,shmID);
if( !db )
{
dlog[Debug::CRIT] << "(rrdstorage): init не прошёл..." << endl;
return 1;
}
ObjectsActivator act;
act.addObject(static_cast<class UniSetObject*>(db));
SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() );
unideb(Debug::ANY) << "\n\n\n";
unideb[Debug::ANY] << "(main): -------------- RRDStorage START -------------------------\n\n";
dlog(Debug::ANY) << "\n\n\n";
dlog[Debug::ANY] << "(main): -------------- RRDStorage START -------------------------\n\n";
act.run(false);
return 0;
}
catch( UniSetTypes::Exception& ex )
{
dlog[Debug::CRIT] << "(rrdstorage): " << ex << std::endl;
}
catch(...)
{
dlog[Debug::CRIT] << "(rrdstorage): catch ..." << std::endl;
}
return 1;
}
#!/bin/sh
uniset-start.sh -f ./uniset-rrdstorage --confile test.xml \
--rrd-name RRDStorage1 \
--dlog-add-levels info,crit,warn
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment