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

(DBServer): добавил отладочную информацию

parent fab7ad77
...@@ -427,3 +427,22 @@ void DBServer_MySQL::help_print( int argc, const char* const* argv ) ...@@ -427,3 +427,22 @@ void DBServer_MySQL::help_print( int argc, const char* const* argv )
cout << DBServer::help_print() << endl; cout << DBServer::help_print() << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
std::string DBServer_MySQL::getMonitInfo( const std::string& params )
{
ostringstream inf;
inf << "Database: "
<< "[ ping=" << PingTime
<< " reconnect=" << ReconnectTime
<< " qbufSize=" << qbufSize
<< " ]" << endl
<< " connection: " << (connect_ok ? "OK" : "FAILED") << endl;
{
uniset_rwmutex_rlock lock(mqbuf);
inf << " buffer size: " << qbuf.size() << endl;
}
inf << " lastError: " << db->error() << endl;
return inf.str();
}
// -----------------------------------------------------------------------------
...@@ -168,6 +168,7 @@ namespace uniset ...@@ -168,6 +168,7 @@ namespace uniset
virtual void sysCommand( const uniset::SystemMessage* sm ) override; virtual void sysCommand( const uniset::SystemMessage* sm ) override;
virtual void sensorInfo( const uniset::SensorMessage* sm ) override; virtual void sensorInfo( const uniset::SensorMessage* sm ) override;
virtual void confirmInfo( const uniset::ConfirmMessage* cmsg ) override; virtual void confirmInfo( const uniset::ConfirmMessage* cmsg ) override;
virtual std::string getMonitInfo( const std::string& params ) override;
bool writeToBase( const std::string& query ); bool writeToBase( const std::string& query );
void createTables( MySQLInterface* db ); void createTables( MySQLInterface* db );
...@@ -184,7 +185,6 @@ namespace uniset ...@@ -184,7 +185,6 @@ namespace uniset
lastNumberOfTimer lastNumberOfTimer
}; };
std::unique_ptr<MySQLInterface> db; std::unique_ptr<MySQLInterface> db;
int PingTime = { 15000 }; int PingTime = { 15000 };
int ReconnectTime = { 30000 }; int ReconnectTime = { 30000 };
......
...@@ -464,6 +464,31 @@ bool DBServer_PostgreSQL::deactivateObject() ...@@ -464,6 +464,31 @@ bool DBServer_PostgreSQL::deactivateObject()
return DBServer::deactivateObject(); return DBServer::deactivateObject();
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
string DBServer_PostgreSQL::getMonitInfo( const string& params )
{
ostringstream inf;
inf << "Database: "
<< "[ ping=" << PingTime
<< " reconnect=" << ReconnectTime
<< " qbufSize=" << qbufSize
<< " ]" << endl
<< " connection: " << (connect_ok ? "OK" : "FAILED") << endl;
{
std::lock_guard<std::mutex> lock(mqbuf);
inf << " buffer size: " << qbuf.size() << endl;
}
inf << " lastError: " << db->error() << endl;
inf << "Insert buffer: "
<< "[ ibufMaxSize=" << ibufMaxSize
<< " ibufSize=" << ibufSize
<< " ibufSyncTimeout=" << ibufSyncTimeout
<< " ]" << endl;
return inf.str();
}
//--------------------------------------------------------------------------------------------
std::shared_ptr<DBServer_PostgreSQL> DBServer_PostgreSQL::init_dbserver( int argc, const char* const* argv, std::shared_ptr<DBServer_PostgreSQL> DBServer_PostgreSQL::init_dbserver( int argc, const char* const* argv,
const std::string& prefix ) const std::string& prefix )
{ {
......
...@@ -86,6 +86,7 @@ namespace uniset ...@@ -86,6 +86,7 @@ namespace uniset
virtual void sensorInfo( const uniset::SensorMessage* sm ) override; virtual void sensorInfo( const uniset::SensorMessage* sm ) override;
virtual void confirmInfo( const uniset::ConfirmMessage* cmsg ) override; virtual void confirmInfo( const uniset::ConfirmMessage* cmsg ) override;
virtual bool deactivateObject() override; virtual bool deactivateObject() override;
virtual std::string getMonitInfo( const std::string& params ) override;
bool writeToBase( const std::string& query ); bool writeToBase( const std::string& query );
void createTables( std::shared_ptr<PostgreSQLInterface>& db ); void createTables( std::shared_ptr<PostgreSQLInterface>& db );
......
...@@ -27,4 +27,6 @@ devel_includedir = $(includedir)/@PACKAGE@/extensions/pgsql ...@@ -27,4 +27,6 @@ devel_includedir = $(includedir)/@PACKAGE@/extensions/pgsql
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libUniSet2PostgreSQL.pc pkgconfig_DATA = libUniSet2PostgreSQL.pc
include $(top_builddir)/include.mk
endif endif
...@@ -401,3 +401,22 @@ void DBServer_SQLite::help_print( int argc, const char* const* argv ) ...@@ -401,3 +401,22 @@ void DBServer_SQLite::help_print( int argc, const char* const* argv )
cout << DBServer::help_print() << endl; cout << DBServer::help_print() << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
std::string DBServer_SQLite::getMonitInfo( const std::string& params )
{
ostringstream inf;
inf << "Database: "
<< "[ ping=" << PingTime
<< " reconnect=" << ReconnectTime
<< " qbufSize=" << qbufSize
<< " ]" << endl
<< " connection: " << (connect_ok ? "OK" : "FAILED") << endl;
{
uniset_rwmutex_rlock lock(mqbuf);
inf << " buffer size: " << qbuf.size() << endl;
}
inf << " lastError: " << db->error() << endl;
return inf.str();
}
// -----------------------------------------------------------------------------
...@@ -168,6 +168,7 @@ namespace uniset ...@@ -168,6 +168,7 @@ namespace uniset
virtual void sysCommand( const uniset::SystemMessage* sm ) override; virtual void sysCommand( const uniset::SystemMessage* sm ) override;
virtual void sensorInfo( const uniset::SensorMessage* sm ) override; virtual void sensorInfo( const uniset::SensorMessage* sm ) override;
virtual void confirmInfo( const uniset::ConfirmMessage* cmsg ) override; virtual void confirmInfo( const uniset::ConfirmMessage* cmsg ) override;
virtual std::string getMonitInfo( const std::string& params ) override;
bool writeToBase( const std::string& query ); bool writeToBase( const std::string& query );
void createTables( SQLiteInterface* db ); void createTables( SQLiteInterface* db );
......
...@@ -58,6 +58,8 @@ namespace uniset ...@@ -58,6 +58,8 @@ namespace uniset
static std::string help_print(); static std::string help_print();
virtual uniset::SimpleInfo* getInfo( const char* userparam = "" ) override;
protected: protected:
virtual void processingMessage( const uniset::VoidMessage* msg ) override; virtual void processingMessage( const uniset::VoidMessage* msg ) override;
...@@ -65,7 +67,8 @@ namespace uniset ...@@ -65,7 +67,8 @@ namespace uniset
virtual void confirmInfo( const uniset::ConfirmMessage* cmsg ) {} virtual void confirmInfo( const uniset::ConfirmMessage* cmsg ) {}
virtual bool activateObject() override; virtual bool activateObject() override;
virtual void initDBServer() {}; virtual void initDBServer() {}
virtual std::string getMonitInfo( const std::string& params ){ return ""; }
std::shared_ptr<LogAgregator> loga; std::shared_ptr<LogAgregator> loga;
......
...@@ -141,3 +141,12 @@ std::string DBServer::help_print() ...@@ -141,3 +141,12 @@ std::string DBServer::help_print()
return h.str(); return h.str();
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
SimpleInfo* DBServer::getInfo( const char* userparam )
{
uniset::SimpleInfo_var i = UniSetObject::getInfo(userparam);
const std::string inf = getMonitInfo( std::string(userparam) );
i->info = inf.c_str();
return i._retn();
}
//--------------------------------------------------------------------------------------------
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