Commit 1d64f14c authored by Pavel Vainerman's avatar Pavel Vainerman

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

RRDStorage --> RRDServer
parent d7e1d336
......@@ -262,8 +262,8 @@ AC_CONFIG_FILES([Makefile
extensions/SharedMemory/Makefile
extensions/SharedMemory/libUniSetSharedMemory.pc
extensions/SharedMemoryPlus/Makefile
extensions/RRDStorage/Makefile
extensions/RRDStorage/libUniSetRRDStorage.pc
extensions/RRDServer/Makefile
extensions/RRDServer/libUniSetRRDServer.pc
extensions/tests/Makefile
python/lib/Makefile
python/lib/pyUniSet/Makefile
......
......@@ -5,7 +5,7 @@
if HAVE_EXTENTIONS
SUBDIRS = lib include SharedMemory IOControl LogicProcessor \
ModbusMaster ModbusSlave SMViewer UniNetwork UNetUDP DBServer-MySQL DBServer-SQLite \
RRDStorage SharedMemoryPlus tests
RRDServer SharedMemoryPlus tests
#SMDBServer
#SharedMemoryPlus
#UDPExchange
......
bin_PROGRAMS = @PACKAGE@-rrdstorage
bin_PROGRAMS = @PACKAGE@-rrdserver
RRD_VER=@LIBVER@
lib_LTLIBRARIES = libUniSetRRDStorage.la
libUniSetRRDStorage_la_LDFLAGS = -version-info $(RRD_VER)
libUniSetRRDStorage_la_LIBADD = $(top_builddir)/lib/libUniSet.la \
lib_LTLIBRARIES = libUniSetRRDServer.la
libUniSetRRDServer_la_LDFLAGS = -version-info $(RRD_VER)
libUniSetRRDServer_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 \
libUniSetRRDServer_la_CXXFLAGS = -I$(top_builddir)/extensions/include \
-I$(top_builddir)/extensions/SharedMemory \
$(SIGC_CFLAGS) $(RRD_CFLAGS)
libUniSetRRDStorage_la_SOURCES = RRDStorage.cc
libUniSetRRDServer_la_SOURCES = RRDServer.cc
@PACKAGE@_rrdstorage_SOURCES = main.cc
@PACKAGE@_rrdstorage_LDADD = libUniSetRRDStorage.la $(top_builddir)/lib/libUniSet.la \
@PACKAGE@_rrdserver_SOURCES = main.cc
@PACKAGE@_rrdserver_LDADD = libUniSetRRDServer.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 \
@PACKAGE@_rrdserver_CXXFLAGS = -I$(top_builddir)/extensions/include \
-I$(top_builddir)/extensions/SharedMemory \
$(SIGC_CFLAGS) $(RRD_CFLAGS)
......@@ -27,7 +27,7 @@ devel_include_HEADERS = *.h
devel_includedir = $(pkgincludedir)/extensions
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libUniSetRRDStorage.pc
pkgconfig_DATA = libUniSetRRDServer.pc
all-local:
ln -sf ../RRDStorage/$(devel_include_HEADERS) ../include
ln -sf ../RRDServer/$(devel_include_HEADERS) ../include
......@@ -5,13 +5,13 @@ extern "C" {
#include <cmath>
#include <sstream>
#include "Exceptions.h"
#include "RRDStorage.h"
#include "RRDServer.h"
// -----------------------------------------------------------------------------
using namespace std;
using namespace UniSetTypes;
using namespace UniSetExtensions;
// -----------------------------------------------------------------------------
RRDStorage::RRDStorage( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes::ObjectId shmId, SharedMemory* ic,
RRDServer::RRDServer( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes::ObjectId shmId, SharedMemory* ic,
const string prefix, DebugStream& log ):
UObject_SK(objId,cnode),
shm( new SMInterface(shmId,&ui,objId,ic) ),
......@@ -25,7 +25,7 @@ prefix(prefix)
{
ostringstream err;
err << myname << "(init): empty rrd list...";
RRDStorage::dlog[Debug::CRIT] << err.str() << endl;
RRDServer::dlog[Debug::CRIT] << err.str() << endl;
throw NameNotFound(err.str());
}
......@@ -34,15 +34,15 @@ prefix(prefix)
initRRD(it1,tmID);
}
// -----------------------------------------------------------------------------
RRDStorage::~RRDStorage()
RRDServer::~RRDServer()
{
}
// -----------------------------------------------------------------------------
void RRDStorage::step()
void RRDServer::step()
{
}
//--------------------------------------------------------------------------------
void RRDStorage::initRRD( xmlNode* cnode, int tmID )
void RRDServer::initRRD( xmlNode* cnode, int tmID )
{
UniXML::iterator it(cnode);
......@@ -57,8 +57,8 @@ void RRDStorage::initRRD( xmlNode* cnode, int tmID )
int lastup = it.getPIntProp("lastup",0);
bool overwrite = it.getPIntProp("overwrite",0);
if( RRDStorage::dlog.debugging(Debug::INFO) )
RRDStorage::dlog[Debug::INFO] << myname << "(init): add rrd: file='" << fname
if( RRDServer::dlog.debugging(Debug::INFO) )
RRDServer::dlog[Debug::INFO] << myname << "(init): add rrd: file='" << fname
<< " " << ff << "='" << fv
<< "' create='" << cf << "'"
<< " step=" << rrdstep
......@@ -71,7 +71,7 @@ void RRDStorage::initRRD( xmlNode* cnode, int tmID )
{
ostringstream err;
err << myname << "(init): rrd='" << fname << "' Unknown RRA list";
RRDStorage::dlog[Debug::CRIT] << err.str();
RRDServer::dlog[Debug::CRIT] << err.str();
throw SystemError(err.str());
}
......@@ -82,7 +82,7 @@ void RRDStorage::initRRD( xmlNode* cnode, int tmID )
{
ostringstream err;
err << myname << "(init): rrd='" << fname << "' Unkown RRA item.. <item rra='...'";
RRDStorage::dlog[Debug::CRIT] << err.str();
RRDServer::dlog[Debug::CRIT] << err.str();
throw SystemError(err.str());
}
......@@ -93,7 +93,7 @@ void RRDStorage::initRRD( xmlNode* cnode, int tmID )
{
ostringstream err;
err << myname << "(init): Not found RRA items...";
RRDStorage::dlog[Debug::CRIT] << err.str() << endl;
RRDServer::dlog[Debug::CRIT] << err.str() << endl;
throw SystemError(err.str());
}
......@@ -105,7 +105,7 @@ void RRDStorage::initRRD( xmlNode* cnode, int tmID )
{
ostringstream err;
err << myname << "(init): Not found section <sensors>";
RRDStorage::dlog[Debug::CRIT] << err.str();
RRDServer::dlog[Debug::CRIT] << err.str();
throw SystemError(err.str());
}
......@@ -114,7 +114,7 @@ void RRDStorage::initRRD( xmlNode* cnode, int tmID )
{
ostringstream err;
err << myname << "(init): section <sensors> empty?!";
RRDStorage::dlog[Debug::CRIT] << err.str();
RRDServer::dlog[Debug::CRIT] << err.str();
throw SystemError(err.str());
}
......@@ -133,7 +133,7 @@ void RRDStorage::initRRD( xmlNode* cnode, int tmID )
{
ostringstream err;
err << myname << "(init): Unknown create parameters ('" << cf << "')";
RRDStorage::dlog[Debug::CRIT] << err.str();
RRDServer::dlog[Debug::CRIT] << err.str();
throw SystemError(err.str());
}
......@@ -147,7 +147,7 @@ void RRDStorage::initRRD( xmlNode* cnode, int tmID )
{
ostringstream err;
err << myname << "(init): Unknown SensorID for '" << dsname << "'";
RRDStorage::dlog[Debug::CRIT] << err.str();
RRDServer::dlog[Debug::CRIT] << err.str();
throw SystemError(err.str());
}
......@@ -159,7 +159,7 @@ void RRDStorage::initRRD( xmlNode* cnode, int tmID )
{
ostringstream err;
err << myname << "(init): Not found RRD items...";
RRDStorage::dlog[Debug::CRIT] << err.str() << endl;
RRDServer::dlog[Debug::CRIT] << err.str() << endl;
throw SystemError(err.str());
}
......@@ -179,8 +179,8 @@ void RRDStorage::initRRD( xmlNode* cnode, int tmID )
// Собственно создаём RRD
if( !overwrite && file_exist(fname) )
{
if( RRDStorage::dlog.debugging(Debug::INFO) )
RRDStorage::dlog[Debug::INFO] << myname << "(init): ignore create file='" << fname
if( RRDServer::dlog.debugging(Debug::INFO) )
RRDServer::dlog[Debug::INFO] << myname << "(init): ignore create file='" << fname
<< "'. File exist... overwrite=0." << endl;
}
else
......@@ -190,7 +190,7 @@ void RRDStorage::initRRD( xmlNode* cnode, int tmID )
{
ostringstream err;
err << myname << "(init): Can`t create RRD ('" << fname << "'): err: " << string(rrd_get_error());
RRDStorage::dlog[Debug::CRIT] << err.str() << endl;
RRDServer::dlog[Debug::CRIT] << err.str() << endl;
throw SystemError(err.str());
}
}
......@@ -206,39 +206,39 @@ void RRDStorage::initRRD( xmlNode* cnode, int tmID )
}
/* catch( Exception& ex )
{
RRDStorage::dlog[Debug::CRIT] << myname << "(init) " << ex << std::endl;
RRDServer::dlog[Debug::CRIT] << myname << "(init) " << ex << std::endl;
}
catch( ... )
{
RRDStorage::dlog[Debug::CRIT] << myname << "(init): catch ..." << std::endl;
RRDServer::dlog[Debug::CRIT] << myname << "(init): catch ..." << std::endl;
}
*/
}
//--------------------------------------------------------------------------------
void RRDStorage::help_print( int argc, const char* const* argv )
void RRDServer::help_print( int argc, const char* const* argv )
{
cout << " Default prefix='rrd'" << endl;
cout << "--prefix-name - ID for rrdstorage. Default: RRDStorage1. " << endl;
cout << "--prefix-name - ID for rrdstorage. Default: RRDServer1. " << endl;
cout << "--prefix-confnode - configuration section name. Default: <NAME name='NAME'...> " << endl;
cout << "--prefix-heartbeat-id name - ID for heartbeat sensor." << endl;
cout << "--prefix-heartbeat-max val - max value for heartbeat sensor." << endl;
}
// -----------------------------------------------------------------------------
RRDStorage* RRDStorage::init_rrdstorage( int argc, const char* const* argv,
RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string prefix )
{
string name = conf->getArgParam("--" + prefix + "-name","RRDStorage");
string name = conf->getArgParam("--" + prefix + "-name","RRDServer");
if( name.empty() )
{
UniSetExtensions::dlog[Debug::CRIT] << "(RRDStorage): Unknown name. Usage: --" << prefix << "-name" << endl;
UniSetExtensions::dlog[Debug::CRIT] << "(RRDServer): Unknown name. Usage: --" << prefix << "-name" << endl;
return 0;
}
ObjectId ID = conf->getObjectID(name);
if( ID == UniSetTypes::DefaultObjectId )
{
UniSetExtensions::dlog[Debug::CRIT] << "(RRDStorage): Not found ID for '" << name
UniSetExtensions::dlog[Debug::CRIT] << "(RRDServer): Not found ID for '" << name
<< " in '" << conf->getObjectsSection() << "' section" << endl;
return 0;
}
......@@ -247,15 +247,15 @@ RRDStorage* RRDStorage::init_rrdstorage( int argc, const char* const* argv,
xmlNode* cnode = conf->getNode(confname);
if( !cnode )
{
UniSetExtensions::dlog[Debug::CRIT] << "(RRDStorage): " << name << "(init): Not found <" + confname + ">" << endl;
UniSetExtensions::dlog[Debug::CRIT] << "(RRDServer): " << name << "(init): Not found <" + confname + ">" << endl;
return 0;
}
UniSetExtensions::dlog[Debug::INFO] << "(RRDStorage): name = " << name << "(" << ID << ")" << endl;
return new RRDStorage(ID,cnode,icID,ic,prefix);
UniSetExtensions::dlog[Debug::INFO] << "(RRDServer): name = " << name << "(" << ID << ")" << endl;
return new RRDServer(ID,cnode,icID,ic,prefix);
}
// -----------------------------------------------------------------------------
void RRDStorage::askSensors( UniversalIO::UIOCommand cmd )
void RRDServer::askSensors( UniversalIO::UIOCommand cmd )
{
UObject_SK::askSensors(cmd);
......@@ -269,13 +269,13 @@ void RRDStorage::askSensors( UniversalIO::UIOCommand cmd )
}
catch( std::exception& ex )
{
RRDStorage::dlog[Debug::CRIT] << myname << "(askSensors): " << ex.what() << endl;
RRDServer::dlog[Debug::CRIT] << myname << "(askSensors): " << ex.what() << endl;
}
}
}
}
// -----------------------------------------------------------------------------
void RRDStorage::sysCommand( UniSetTypes::SystemMessage* sm )
void RRDServer::sysCommand( UniSetTypes::SystemMessage* sm )
{
UObject_SK::sysCommand(sm);
if( sm->command == SystemMessage::StartUp || sm->command == SystemMessage::WatchDog )
......@@ -288,13 +288,13 @@ void RRDStorage::sysCommand( UniSetTypes::SystemMessage* sm )
}
catch( std::exception& ex )
{
RRDStorage::dlog[Debug::CRIT] << myname << "(askTimer): " << ex.what() << endl;
RRDServer::dlog[Debug::CRIT] << myname << "(askTimer): " << ex.what() << endl;
}
}
}
}
// -----------------------------------------------------------------------------
void RRDStorage::sensorInfo( UniSetTypes::SensorMessage* sm )
void RRDServer::sensorInfo( UniSetTypes::SensorMessage* sm )
{
for( RRDList::iterator it=rrdlist.begin(); it!=rrdlist.end(); ++it )
{
......@@ -306,7 +306,7 @@ void RRDStorage::sensorInfo( UniSetTypes::SensorMessage* sm )
}
}
// -----------------------------------------------------------------------------
void RRDStorage::timerInfo( UniSetTypes::TimerMessage* tm )
void RRDServer::timerInfo( UniSetTypes::TimerMessage* tm )
{
for( RRDList::iterator it=rrdlist.begin(); it!=rrdlist.end(); ++it )
{
......@@ -318,8 +318,8 @@ void RRDStorage::timerInfo( UniSetTypes::TimerMessage* tm )
for( DSMap::iterator s=it->dsmap.begin(); s!=it->dsmap.end(); ++s )
v << ":" << s->second.value;
if( RRDStorage::dlog.debugging(Debug::INFO) )
RRDStorage::dlog[Debug::INFO] << myname << "(update): '" << it->filename << "' " << v.str() << endl;
if( RRDServer::dlog.debugging(Debug::INFO) )
RRDServer::dlog[Debug::INFO] << myname << "(update): '" << it->filename << "' " << v.str() << endl;
rrd_clear_error();
const char* argv = v.str().c_str();
......@@ -327,7 +327,7 @@ void RRDStorage::timerInfo( UniSetTypes::TimerMessage* tm )
{
ostringstream err;
err << myname << "(update): Can`t update RRD ('" << it->filename << "'): err: " << string(rrd_get_error());
RRDStorage::dlog[Debug::CRIT] << err.str() << endl;
RRDServer::dlog[Debug::CRIT] << err.str() << endl;
}
break;
......
#ifndef _RRDStorage_H_
#define _RRDStorage_H_
#ifndef _RRDServer_H_
#define _RRDServer_H_
// -----------------------------------------------------------------------------
#include "UObject_SK.h"
#include "SMInterface.h"
......@@ -7,13 +7,22 @@
#include "extensions/Extensions.h"
// -----------------------------------------------------------------------------
/*!
\page page_RRDServer Реализация RRD хранилища
- \ref sec_RRD_Comm
- \ref sec_RRD_Conf
\section sec_RRD_Comm Общее описание RRDServer
"RoundRobinDatabase" - реализация циклического хранилища.
Процесс реализует циклическое хранение данных (от датчиков) и позволяет
конфигурировать любое количество rrd-баз и входящих в них "источников".
\section sec_RRD_Conf Настройка RRDServer
Пример секции конфигурации:
\code
<RRDStorage1 name="RRDStorage1">
<RRDServer1 name="RRDServer1">
<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"/>
......@@ -22,16 +31,16 @@
<item rra="RRA:AVERAGE:0.5:1:4320"/>
<item rra="RRA:MAX:0.5:1:4320"/>
</rrd>
</RRDStorage1>
</RRDServer1>
\endcode
Где:
\b filename - имя создаваемого rrd-файла
\b filter_field - поле у датчика, определяющее, что его нужно сохранять в БД
\b filter_value - значение filter_field, определяющее, что датчик нужно сохранять в БД
\b ds_field - поле определяющее, параметр задающий формат хранения. Если \a ds_field не задано,
- \b filename - имя создаваемого rrd-файла
- \b filter_field - поле у датчика, определяющее, что его нужно сохранять в БД
- \b filter_value - значение \b filter_field, определяющее, что датчик нужно сохранять в БД
- \b ds_field - поле определяющее, параметр задающий формат хранения. Если \a ds_field не задано,
то будет браться filter_field+filter_value+'_ds'.
\b step - период обновления данных (в секундах)
\b overwrite - [0,1]. Пересоздавать ли БД, если файл уже существует.
- \b step - период обновления данных (в секундах)
- \b overwrite - [0,1]. Пересоздавать ли БД, если файл уже существует.
При этом в секции <sensors> у датчиков прописываются параметры относящиеся к источнику:
\code
......@@ -45,16 +54,16 @@
</sensors>
\endcode
*/
class RRDStorage:
class RRDServer:
public UObject_SK
{
public:
RRDStorage( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
RRDServer( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
const std::string prefix="rrd", DebugStream& log=UniSetExtensions::dlog );
virtual ~RRDStorage();
virtual ~RRDServer();
/*! глобальная функция для инициализации объекта */
static RRDStorage* init_rrdstorage( int argc, const char* const* argv,
static RRDServer* init_rrdstorage( int argc, const char* const* argv,
UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
const std::string prefix="rrd" );
......@@ -62,7 +71,7 @@ class RRDStorage:
static void help_print( int argc, const char* const* argv );
protected:
RRDStorage();
RRDServer();
virtual void askSensors( UniversalIO::UIOCommand cmd );
virtual void sensorInfo( UniSetTypes::SensorMessage* sm );
......@@ -105,5 +114,5 @@ class RRDStorage:
std::string prefix;
};
// -----------------------------------------------------------------------------
#endif // _RRDStorage_H_
#endif // _RRDServer_H_
// -----------------------------------------------------------------------------
......@@ -3,9 +3,9 @@ exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libUniSetRRDStorage
Description: Support library for UniSetRRDStorage
Name: libUniSetRRDServer
Description: Support library for UniSetRRDServer
Requires: libUniSetExtensions librrd
Version: @VERSION@
Libs: -L${libdir} -lUniSetRRDStorage
Libs: -L${libdir} -lUniSetRRDServer
Cflags: -I${includedir}/uniset
#include <sstream>
#include "RRDStorage.h"
#include "RRDServer.h"
#include "Configuration.h"
#include "Debug.h"
#include "ObjectsActivator.h"
......@@ -17,7 +17,7 @@ int main( int argc, const char** argv )
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);
RRDServer::help_print(argc, argv);
return 0;
}
......@@ -51,7 +51,7 @@ int main( int argc, const char** argv )
return 1;
}
RRDStorage* db = RRDStorage::init_rrdstorage(argc,argv,shmID);
RRDServer* db = RRDServer::init_rrdstorage(argc,argv,shmID);
if( !db )
{
dlog[Debug::CRIT] << "(rrdstorage): init не прошёл..." << endl;
......@@ -65,9 +65,9 @@ int main( int argc, const char** argv )
act.broadcast( sm.transport_msg() );
unideb(Debug::ANY) << "\n\n\n";
unideb[Debug::ANY] << "(main): -------------- RRDStorage START -------------------------\n\n";
unideb[Debug::ANY] << "(main): -------------- RRDServer START -------------------------\n\n";
dlog(Debug::ANY) << "\n\n\n";
dlog[Debug::ANY] << "(main): -------------- RRDStorage START -------------------------\n\n";
dlog[Debug::ANY] << "(main): -------------- RRDServer START -------------------------\n\n";
act.run(false);
return 0;
}
......
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