Skip to content
Snippets Groups Projects
Commit 8dfbba2f authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Track/log/publish-to-MQTT services server (total) client highwater mark

Like the other servers.

A sysop likely would want to know which services/protocols had what
utilization (as a portion of the total highwater mark), so that'll have to
be added later.
parent 9a599dfa
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
Pipeline #6494 passed
...@@ -62,6 +62,7 @@ static char* text[TOTAL_TEXT]; ...@@ -62,6 +62,7 @@ static char* text[TOTAL_TEXT];
static volatile bool terminated=false; static volatile bool terminated=false;
static time_t uptime=0; static time_t uptime=0;
static ulong served=0; static ulong served=0;
static volatile uint32_t client_highwater=0;
static str_list_t pause_semfiles; static str_list_t pause_semfiles;
static str_list_t recycle_semfiles; static str_list_t recycle_semfiles;
static str_list_t shutdown_semfiles; static str_list_t shutdown_semfiles;
...@@ -210,8 +211,17 @@ static ulong active_clients(void) ...@@ -210,8 +211,17 @@ static ulong active_clients(void)
static void update_clients(void) static void update_clients(void)
{ {
ulong client_count = active_clients();
if(startup!=NULL && startup->clients!=NULL) if(startup!=NULL && startup->clients!=NULL)
startup->clients(startup->cbdata,active_clients()); startup->clients(startup->cbdata, client_count);
if(client_count > client_highwater) {
client_highwater = client_count;
if(client_highwater > 1)
lprintf(LOG_NOTICE, "New active client highwater mark: %u"
,client_highwater);
mqtt_pub_uintval(&mqtt, TOPIC_SERVER, "highwater", client_highwater);
}
} }
static void client_on(SOCKET sock, client_t* client, bool update) static void client_on(SOCKET sock, client_t* client, bool update)
...@@ -1762,7 +1772,7 @@ static void cleanup(int code) ...@@ -1762,7 +1772,7 @@ static void cleanup(int code)
thread_down(); thread_down();
if(terminated || code) if(terminated || code)
lprintf(LOG_INFO,"#### Services thread terminated (%lu clients served)",served); lprintf(LOG_INFO,"#### Services thread terminated (%lu clients served, %u concurrently)",served, client_highwater);
set_state(SERVER_STOPPED); set_state(SERVER_STOPPED);
mqtt_shutdown(&mqtt); mqtt_shutdown(&mqtt);
if(startup!=NULL && startup->terminated!=NULL) if(startup!=NULL && startup->terminated!=NULL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment