mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Include number of active clients in the response of GET /api/stats/summary
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -469,6 +469,10 @@ components:
|
||||
clients:
|
||||
type: object
|
||||
properties:
|
||||
active:
|
||||
type: integer
|
||||
description: Number of active clients (seen in the last 24 hours)
|
||||
example: 10
|
||||
total:
|
||||
type: integer
|
||||
description: Total number of clients seen by FTL
|
||||
|
||||
@@ -106,7 +106,21 @@ int api_stats_summary(struct ftl_conn *api)
|
||||
JSON_ADD_NUMBER_TO_OBJECT(replies, get_query_reply_str(reply), counters->reply[reply]);
|
||||
JSON_ADD_ITEM_TO_OBJECT(queries, "replies", replies);
|
||||
|
||||
// Count clients that have been active within the most recent 24 hours
|
||||
unsigned int activeclients = 0;
|
||||
for(int clientID=0; clientID < counters->clients; clientID++)
|
||||
{
|
||||
// Get client pointer
|
||||
const clientsData* client = getClient(clientID, true);
|
||||
if(client == NULL)
|
||||
continue;
|
||||
|
||||
if(client->count > 0)
|
||||
activeclients++;
|
||||
}
|
||||
|
||||
cJSON *clients = JSON_NEW_OBJECT();
|
||||
JSON_ADD_NUMBER_TO_OBJECT(clients, "active", activeclients);
|
||||
JSON_ADD_NUMBER_TO_OBJECT(clients, "total", counters->clients);
|
||||
|
||||
cJSON *gravity = JSON_NEW_OBJECT();
|
||||
|
||||
Reference in New Issue
Block a user