Compare commits

...

2 Commits

Author SHA1 Message Date
Fred Boniface 07d281a56b Frontend: Adjust Stats display
Signed-off-by: Fred Boniface <fred@fjla.uk>
2023-02-02 18:53:29 +00:00
Fred Boniface be745978bb FullStack: Expand stats page
Signed-off-by: Fred Boniface <fred@fjla.uk>
2023-02-02 18:50:47 +00:00
4 changed files with 48 additions and 10 deletions

View File

@ -75,6 +75,7 @@ async function query(collection, query){
var qcursor = qcoll.find(query) var qcursor = qcoll.find(query)
qcursor.project({_id: 0}) qcursor.project({_id: 0})
log.out(`dbAccess.query: Running Query: ${JSON.stringify(query)}`) log.out(`dbAccess.query: Running Query: ${JSON.stringify(query)}`)
increment(collection)
return (await qcursor.toArray()); return (await qcursor.toArray());
} }
@ -98,15 +99,15 @@ async function increment(target) {
let col = db.collection("meta"); let col = db.collection("meta");
let update = {} let update = {}
update[target] = 1 update[target] = 1
col.updateOne({target: "ext_api"}, {$inc:update}) col.updateOne({target: "counters"}, {$inc:update})
return; return;
} }
async function createCount() { async function createCount() {
await client.connect(); await client.connect();
let col = db.collection("meta"); let col = db.collection("meta");
var filter = {type: "count", target: "ext_api"}; var filter = {type: "count", target: "counters"};
var update = {$set:{since: new Date, type: "count", target: "ext_api"}}; var update = {$set:{since: new Date, type: "count", target: "counters"}};
var options = {upsert: true}; // If document isn't present will insert. var options = {upsert: true}; // If document isn't present will insert.
try { try {
var result = await col.updateOne(filter,update,options) var result = await col.updateOne(filter,update,options)

View File

@ -15,7 +15,7 @@ async function getCorpus(){
} }
async function hits(){ 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`) log.out(`listServices.meta: fetched server meta`)
let out = {} let out = {}
out.host = os.hostname() out.host = os.hostname()

View File

@ -14,7 +14,11 @@ async function display(data) {
document.getElementById('server_host').textContent = `HOST: ${data.host}`; document.getElementById('server_host').textContent = `HOST: ${data.host}`;
let dat = data.dat[0] let dat = data.dat[0]
console.log(JSON.stringify(dat)) console.log(JSON.stringify(dat))
document.getElementById('time').textContent = `COUNTER START TIME: ${dat.since}`; document.getElementById('time').textContent = dat.since;
document.getElementById('ldbws').textContent = dat.ldbws || "0"; document.getElementById('ldbws').textContent = dat.ldbws || "0";
document.getElementById('ldbsvws').textContent = dat.ldbsvws || "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";
} }

View File

@ -4,15 +4,48 @@
<title>OwlBoard - STATS</title> <title>OwlBoard - STATS</title>
<script src="./js/stat.js"></script> <script src="./js/stat.js"></script>
</head> </head>
<body> <body style="text-align:center">
<h1>OwlBoard Server Stats</h1> <h1>OwlBoard Server Stats</h1>
<h2 id="server_host"></h2> <h2 id="server_host"></h2>
<p id="time"></p> <p>Counters Reset - <span id="time"></span></p>
<table style="margin:auto;text-align:center;">
<tr>
<th>Resource</th>
<th>Hit Count</th>
</tr>
<tr>
<td>LDBWS</td>
<td id="ldbws"></td>
</tr>
<tr>
<td>LDBSVWS</td>
<td id="ldbsvws"></td>
</tr>
<tr>
<td>DB-CORPUS</td>
<td id="corpus"></td>
</tr>
<tr>
<td>DB-Stations</td>
<td id="stations"></td>
</tr>
<tr>
<td>DB-Users</td>
<td id="users"></td>
</tr>
<tr>
<td>DB-Meta</td>
<td id="meta"></td>
</tr>
</table>
<!--
<h3>LDBWS API Hits: <span id="ldbws"></span></h3> <h3>LDBWS API Hits: <span id="ldbws"></span></h3>
<h3>LDBSVWS API Hits: <span id="ldbsvws"></span></h3> <h3>LDBSVWS API Hits: <span id="ldbsvws"></span></h3>
<h3>CORPUS DB Lookups: <span id="corpus"></span></h3>
<h3>Station DB Lookups: <span id="stations"></span></h3>
<h3>User DB Queries: <span id="users"></span></h3> -->
<br><br> <br><br>
<p>Multiple servers can be attached to one database. All servers sharing this servers DB are represented in these statistics, <p>The statistics represent hits & queries on all servers attached to the database.
responses that do not lead to an upstream API hit are not counted. Multiple servers are served by each database server.</p>
</p>
</body> </body>
</html> </html>