X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fsimulator-group%2Fsim-monitor.js;h=7d7ffdf80533bc1c381417b3ae61b07944fe468c;hb=49f0e5ab01b51aee8713a17aed86cd6d229b40cc;hp=b746ae5df3d8cbe502eafcaa90b37172c62af80a;hpb=647744d8ab625d28ea0ecda3e6741e23ba9b0bc7;p=nonrtric.git diff --git a/test/simulator-group/sim-monitor.js b/test/simulator-group/sim-monitor.js index b746ae5d..7d7ffdf8 100644 --- a/test/simulator-group/sim-monitor.js +++ b/test/simulator-group/sim-monitor.js @@ -30,6 +30,7 @@ var PRODSTUB_PORT="8092" var http = require('http'); var express = require('express'); +const { POINT_CONVERSION_HYBRID } = require('constants') var app = express(); var fieldSize=32; @@ -197,6 +198,9 @@ var ps_producer_type_arr=new Array(0) var ps_producer_jobs_arr=new Array(0) var ps_producer_delivery_arr=new Array(0) +//Full CR DB +var cr_db={} + //Counts the number of get request for the html page var getCtr=0 @@ -204,6 +208,8 @@ var refreshCount_pol=-1 var refreshCount_ecs=-1 +var refreshCount_cr=-1 + var ricbasename="ricsim" function fetchAllMetrics_pol() { @@ -611,6 +617,58 @@ function fetchAllMetrics_ecs() { }, 500) } +function fetchAllMetrics_cr() { + + console.log("Fetching CR DB - timer:" + refreshCount_ecs) + + if (refreshCount_cr < 0) { + refreshCount_cr = -1 + return + } else { + refreshCount_cr = refreshCount_cr - 1 + } + setTimeout(() => { + + if (checkFunctionFlag("cr_stat")) { + getSimCtr(LOCALHOST+CR_PORT+"/db", 0, function(data, index) { + ecs4="" + try { + cr_db=JSON.parse(data); + } + catch (err) { + cr_db={} + } + }); + clearFlag("cr_stat") + } + fetchAllMetrics_cr(); + }, 500) +} + +// Monitor for CR db +app.get("/mon3",function(req, res){ + + console.log("Creating CR DB page - timer: " + refreshCount_ecs) + + if (refreshCount_cr < 0) { + refreshCount_cr=5 + fetchAllMetrics_cr() + } + refreshCount_cr=5 + var json_str=JSON.stringify(cr_db, null, 1) + var htmlStr = "" + + "" + + "" + + ""+ //2 sec auto refresh + "CR DB dump"+ + "" + + "" + + json_str + + "" + + ""; + res.send(htmlStr); +}) + // Monitor for ECS app.get("/mon2",function(req, res){ @@ -831,4 +889,5 @@ var httpPort=9999; httpServer.listen(httpPort); console.log("Simulator monitor listening (http) at "+httpPort); console.log("Open the web page on localhost:9999/mon to view the policy statistics page.") -console.log("Open the web page on localhost:9999/mon2 to view the enrichment statistics page.") \ No newline at end of file +console.log("Open the web page on localhost:9999/mon2 to view the enrichment statistics page.") +console.log("Open the web page on localhost:9999/mon3 to view CR DB in json.") \ No newline at end of file