From be745978bbe1e30992b8770a30a65a54e35d4d6a Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Thu, 2 Feb 2023 18:50:47 +0000 Subject: [PATCH] FullStack: Expand stats page Signed-off-by: Fred Boniface --- src/services/dbAccess.services.js | 7 +++--- src/services/list.services.js | 2 +- static/js/stat.js | 4 ++++ static/stat.html | 39 ++++++++++++++++++++++++++++--- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/services/dbAccess.services.js b/src/services/dbAccess.services.js index 44c36c2..4d3467d 100644 --- a/src/services/dbAccess.services.js +++ b/src/services/dbAccess.services.js @@ -75,6 +75,7 @@ async function query(collection, query){ var qcursor = qcoll.find(query) qcursor.project({_id: 0}) log.out(`dbAccess.query: Running Query: ${JSON.stringify(query)}`) + increment(collection) return (await qcursor.toArray()); } @@ -98,15 +99,15 @@ async function increment(target) { let col = db.collection("meta"); let update = {} update[target] = 1 - col.updateOne({target: "ext_api"}, {$inc:update}) + col.updateOne({target: "counters"}, {$inc:update}) return; } async function createCount() { await client.connect(); let col = db.collection("meta"); - var filter = {type: "count", target: "ext_api"}; - var update = {$set:{since: new Date, type: "count", target: "ext_api"}}; + var filter = {type: "count", target: "counters"}; + var update = {$set:{since: new Date, type: "count", target: "counters"}}; var options = {upsert: true}; // If document isn't present will insert. try { var result = await col.updateOne(filter,update,options) diff --git a/src/services/list.services.js b/src/services/list.services.js index f26722a..a84d099 100644 --- a/src/services/list.services.js +++ b/src/services/list.services.js @@ -15,7 +15,7 @@ async function getCorpus(){ } async function hits(){ - var dat = await db.query("meta", {target: "ext_api"}); + var dat = await db.query("meta", {target: "counters"}); log.out(`listServices.meta: fetched server meta`) let out = {} out.host = os.hostname() diff --git a/static/js/stat.js b/static/js/stat.js index 1f13bfc..6298e13 100644 --- a/static/js/stat.js +++ b/static/js/stat.js @@ -17,4 +17,8 @@ async function display(data) { document.getElementById('time').textContent = `COUNTER START TIME: ${dat.since}`; document.getElementById('ldbws').textContent = dat.ldbws || "0"; document.getElementById('ldbsvws').textContent = dat.ldbsvws || "0"; + document.getElementById('corpus').textContent = dat.corpus || "0"; + document.getElementById('stations').textContent = dat.stations || "0"; + document.getElementById('users').textContent = dat.user || "0"; + document.getElementById('meta').textContent = dat.meta || "0"; } \ No newline at end of file diff --git a/static/stat.html b/static/stat.html index 4efacee..a3db7c4 100644 --- a/static/stat.html +++ b/static/stat.html @@ -8,11 +8,44 @@

OwlBoard Server Stats

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ResourceHit Count
LDBWS
LDBSVWS
DB-CORPUS
DB-Stations
DB-Users
DB-Meta
+

-

Multiple servers can be attached to one database. All servers sharing this servers DB are represented in these statistics, - responses that do not lead to an upstream API hit are not counted. -

+

The statistics represent hits & queries on all servers attached to the database. + Multiple servers are served by each database server.

\ No newline at end of file