Skip to content

Commit 0a6fbb2

Browse files
committed
server stats publish
1 parent 367ba79 commit 0a6fbb2

File tree

6 files changed

+37
-0
lines changed

6 files changed

+37
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ add_executable(
254254
src/infoLoggerServer.cxx
255255
src/InfoLoggerDispatch.cxx
256256
src/InfoLoggerDispatchBrowser.cxx
257+
src/InfoLoggerDispatchStats.cxx
257258
src/ConfigInfoLoggerServer.cxx
258259
src/infoLoggerMessageDecode.c
259260
src/InfoLoggerMessageHelper.cxx

src/ConfigInfoLoggerServer.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,13 @@ void ConfigInfoLoggerServer::readFromConfigFile(ConfigFile& config)
3838

3939
config.getOptionalValue<int>(INFOLOGGER_CONFIG_SECTION_NAME_SERVER ".serverPortTx", serverPortTx);
4040
config.getOptionalValue<int>(INFOLOGGER_CONFIG_SECTION_NAME_SERVER ".maxClientsTx", maxClientsTx);
41+
42+
config.getOptionalValue<int>(INFOLOGGER_CONFIG_SECTION_NAME_SERVER ".statsEnabled", statsEnabled);
43+
config.getOptionalValue<int>(INFOLOGGER_CONFIG_SECTION_NAME_SERVER ".statsPort", statsPort);
44+
config.getOptionalValue<int>(INFOLOGGER_CONFIG_SECTION_NAME_SERVER ".statsMaxClients", statsMaxClients);
45+
config.getOptionalValue<int>(INFOLOGGER_CONFIG_SECTION_NAME_SERVER ".statsPublishInterval", statsPublishInterval);
46+
config.getOptionalValue<int>(INFOLOGGER_CONFIG_SECTION_NAME_SERVER ".statsResetInterval", statsResetInterval);
47+
config.getOptionalValue<int>(INFOLOGGER_CONFIG_SECTION_NAME_SERVER ".statsHistory", statsHistory);
48+
4149
}
4250

src/ConfigInfoLoggerServer.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ class ConfigInfoLoggerServer
5050
// settings for infoBrowser clients
5151
int serverPortTx = INFOLOGGER_DEFAULT_SERVER_TX_PORT;
5252
int maxClientsTx = 100;
53+
54+
// settings for infoLoggerStats clients
55+
int statsEnabled = 1; // flag to enable/disable feature
56+
int statsPort = INFOLOGGER_DEFAULT_SERVER_STATS_PORT; // TCP/IP port number
57+
int statsMaxClients = 5; // max number of clients connections allowed
58+
int statsPublishInterval = 5 ; // publish interval time (seconds)
59+
int statsResetInterval = 60; // size of the stats window (seconds)
60+
int statsHistory = 600; // backlog of stats kept and published (seconds)
5361
};
5462

5563
#endif // SRC_CONFIGINFOLOGGERSERVER_H_

src/InfoLoggerDispatch.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,18 @@ class InfoLoggerDispatchSQL : public InfoLoggerDispatch
9696
std::unique_ptr<InfoLoggerDispatchSQLImpl> dPtr;
9797
};
9898

99+
// a class to dispatch stats about online messages
100+
class InfoLoggerDispatchStatsImpl;
101+
class InfoLoggerDispatchStats : public InfoLoggerDispatch
102+
{
103+
public:
104+
InfoLoggerDispatchStats(ConfigInfoLoggerServer* theConfig, SimpleLog* theLog);
105+
~InfoLoggerDispatchStats();
106+
int customMessageProcess(std::shared_ptr<InfoLoggerMessageList> msg);
107+
int customLoop();
108+
109+
private:
110+
std::unique_ptr<InfoLoggerDispatchStatsImpl> dPtr;
111+
};
99112
#endif
100113

src/infoLoggerDefaults.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// default infoLoggerServer listening port for infoBrowser
3030
#define INFOLOGGER_DEFAULT_SERVER_TX_PORT 6102
3131

32+
// default infoLoggerServer listening port for stats plublish
33+
#define INFOLOGGER_DEFAULT_SERVER_STATS_PORT 6103
34+
3235
// default listening socket name for infoLoggerD
3336
#define INFOLOGGER_DEFAULT_LOCAL_SOCKET "infoLoggerD"
3437

src/infoLoggerServer.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ InfoLoggerServer::InfoLoggerServer(int argc, char* argv[]) : Daemon(argc, argv)
132132
try {
133133
//dispatchEngines.push_back(std::make_unique<InfoLoggerDispatchPrint>(&log));
134134
dispatchEngines.push_back(std::make_unique<InfoLoggerDispatchOnlineBrowser>(&configInfoLoggerServer, &log));
135+
136+
if (configInfoLoggerServer.statsEnabled) {
137+
dispatchEngines.push_back(std::make_unique<InfoLoggerDispatchStats>(&configInfoLoggerServer, &log));
138+
}
135139

136140
if (configInfoLoggerServer.dbEnabled) {
137141
#ifdef WITH_MYSQL

0 commit comments

Comments
 (0)