X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fsimulator-group%2Fsim-monitor.js;h=f993410fc510c454ce3c4550accd5bb3cdae39b3;hb=d2aeca8843fe3ffca2e73dec5b64daeef0dda938;hp=17d3205833e5db32307dac0f98e26fb97698f032;hpb=8d10bf1fee8093ec4c2a3d3530fded002daf83b6;p=nonrtric.git diff --git a/test/simulator-group/sim-monitor.js b/test/simulator-group/sim-monitor.js index 17d32058..f993410f 100644 --- a/test/simulator-group/sim-monitor.js +++ b/test/simulator-group/sim-monitor.js @@ -17,16 +17,21 @@ # */ -// Sim mon server - query the agent and the simulators for counters and other data +// Sim mon server - query the a1pms and the simulators for counters and other data // Presents a web page on localhost:9999/mon var LOCALHOST="http://127.0.0.1:" var MRSTUB_PORT="3905" -var AGENT_PORT="8081" +var A1PMS_PORT="8081" var CR_PORT="8090" +var ICS_PORT="8083" +var PRODSTUB_PORT="8092" +var RC_PORT="8680" + var http = require('http'); var express = require('express'); +const { POINT_CONVERSION_HYBRID } = require('constants') var app = express(); var fieldSize=32; @@ -37,11 +42,10 @@ app.get("/",function(req, res){ res.send("ok"); }) -//Get parameter valuue from other server +//Get parameter value from other server function getSimCtr(url, index, cb) { var data = ''; - //console.log("URL: "+ url + " - ") try { http.get(url, (resp) => { // A chunk of data has been recieved. @@ -66,7 +70,7 @@ function getSimCtr(url, index, cb) { } catch(err) { cb("no response", index); } -}; +} //Format a comma separated list of data to a html-safe string with fixed fieldsizes @@ -118,9 +122,9 @@ function formatIdRowCompact(commaList) { } //Pad a string upto a certain size using a pad string -function padding(val, fieldSize, pad) { +function padding(val, size, pad) { var s=""+val; - for(var i=s.length;i { - console.log("Fetching all metics data") - if (refreshInterval < 20000) { - refreshInterval+=100 - } if (getCtr%3 == 0) { //Extract the port numbers from the running simulators, for every 3 calls const { exec } = require('child_process'); - exec('docker ps --filter "name='+ricbasename+'" --format "{{.Names}} {{.Ports}}" | sed s/0.0.0.0:// | cut -d \'>\' -f1 | sed \'s/[[-]]*$//\'', (err, stdout, stderr) => { + exec('docker ps --filter "name='+ricbasename+'" --filter "network=nonrtric-docker-net" --format "{{.Names}} {{.Ports}}" | sed s/0.0.0.0:// | cut -d \'>\' -f1 | sed \'s/[[-]]*$//\'', (err, stdout, stderr) => { var simulators = "" simulators=`${stdout}`.replace(/(\r\n|\n|\r)/gm," "); @@ -205,7 +244,7 @@ function fetchAllMetrics() { var sims=simulators.split(" ") simnames=[] simports=[] - for(i=0;i { + + if (checkFunctionFlag("ics_stat")) { + getSimCtr(LOCALHOST+ICS_PORT+"/status", 0, function(data, index) { + try { + var jd=JSON.parse(data); + ics1=jd["status"] + ics2=""+jd["no_of_producers"] + ics3=""+jd["no_of_types"] + ics4=""+jd["no_of_jobs"] + } + catch (err) { + ics1="error response" + ics2="error response" + ics3="error response" + ics4="error response" + } + }); + clearFlag("ics_stat") + } + if (checkFunctionFlag("ics_types")) { + getSimCtr(LOCALHOST+ICS_PORT+"/ei-producer/v1/eitypes", 0, function(data, index) { + var tmp_ics_types="-" + try { + var jd=JSON.parse(data); + for(var i=0;i { + + if (checkFunctionFlag("cr_stat")) { + getSimCtr(LOCALHOST+CR_PORT+"/db", 0, function(data, index) { + try { + cr_db=JSON.parse(data); + } + catch (err) { + cr_db={} + } + }); + clearFlag("cr_stat") + } + fetchAllMetrics_cr(); + }, 500) +} + +function fetchAllMetrics_rc() { + + console.log("Fetching RC services - timer:" + refreshCount_ics) + + if (refreshCount_rc < 0) { + refreshCount_rc = -1 + return + } else { + refreshCount_rc = refreshCount_rc - 1 + } + setTimeout(() => { + + if (checkFunctionFlag("rc_stat")) { + getSimCtr(LOCALHOST+RC_PORT+"/services", 0, function(data, index) { + var tmp_serv="" + try { + var jd=JSON.parse(data); + for(var i=0;i 0) { + tmp_serv=tmp_serv+"," + } + tmp_serv=tmp_serv+jd[i]["name"] + } - fetchAllMetrics(); - }, refreshInterval) + } + catch (err) { + tmp_serv="no_response" + } + rc_services=tmp_serv + }); + clearFlag("rc_stat") + } + fetchAllMetrics_rc(); + }, 500) } -fetchAllMetrics(); +// Monitor for CR db +app.get("/mon3",function(req, res){ -setInterval(() => { - console.log("Setting interval "+refreshInterval+"ms") -}, refreshInterval) + console.log("Creating CR DB page - timer: " + refreshCount_ics) + 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 ICS +app.get("/mon2",function(req, res){ + + console.log("Creating information metrics - timer: " + refreshCount_ics) + + if (refreshCount_ics < 0) { + refreshCount_ics=5 + fetchAllMetrics_ics() + } + refreshCount_ics=5 + + var summary=req.query.summary + + if (summary == undefined) { + return res.redirect('/mon2?summary=false'); + } + + //Build web page + var htmlStr = "" + + "" + + "" + + ""+ //2 sec auto refresh + "information coordinator service and producer stub"+ + "" + + "" + + "" + if (summary == "false") { + htmlStr=htmlStr+"

Set query param '?summary' to true to only show summary statistics.

" + } else { + htmlStr=htmlStr+"

Set query param '?summary' to false to only show full statistics

" + } + if (ics_job_status.length > 10) { + htmlStr=htmlStr+"
Avoid running the server for large number of producers and/or jobs
" + } + htmlStr=htmlStr+"
" + + "

Information Coordinator Service

" + + "" + + "Status:..........." + formatDataRow(ics1) + "
" + + "Producers:........" + formatDataRow(ics2) + "
" + + "Types:............" + formatDataRow(ics3) + "
" + + "Jobs:............." + formatDataRow(ics4) + "
" + + "
" + if (summary == "false") { + htmlStr=htmlStr+ + "

Details

" + + "" + + "Producer ids:....." + formatDataRow(ics_producers) + "
" + + "Type ids:........." + formatDataRow(ics_types) + "
" + + "
"; + for(var i=0;i" + htmlStr=htmlStr+s + } + } + htmlStr=htmlStr+"
"; + for(i=0;i" + htmlStr=htmlStr+s + } + } + htmlStr=htmlStr+"
"; + for(i=0;i" + htmlStr=htmlStr+s + } + } + htmlStr=htmlStr+"
"; + for(i=0;i" + htmlStr=htmlStr+s + } + } + htmlStr=htmlStr+"
"+"
" + + "
" + } + + htmlStr=htmlStr+ + "

Producer stub

" + + "" + + "Producers:........" + formatDataRow(ps2) + "
" + + "Types:............" + formatDataRow(ps3) + "
" + + "Jobs:............." + formatDataRow(ps4) + "
" + + "
" + if (summary == "false") { + htmlStr=htmlStr+ + "

Details

" + + "" + + "Producer ids:....." + formatDataRow(ps_producers) + "
" + + "Type ids:........." + formatDataRow(ps_types) + "
" + + "
"; + for(i=0;i" + htmlStr=htmlStr+s + } + } + htmlStr=htmlStr+"
"; + for(i=0;i" + htmlStr=htmlStr+s + } + } + htmlStr=htmlStr+"
"; + for(i=0;i" + htmlStr=htmlStr+s + } + } + } + htmlStr=htmlStr+ + "
" + + "" + + ""; + res.send(htmlStr); +}) + +// Monitor for policy management app.get("/mon",function(req, res){ + console.log("Creating policy metrics page " + refreshCount_pol) + + if (refreshCount_pol < 0) { + refreshCount_pol=5 + fetchAllMetrics_pol() + } + refreshCount_pol=5 + + if (refreshCount_rc < 0) { + refreshCount_rc=5 + fetchAllMetrics_rc() + } + refreshCount_rc=5 + var bn=req.query.basename + a1pmsprefix=req.query.a1pmsprefix - if (bn == undefined) { + console.log("A1PMS"+a1pmsprefix) + if ((bn == undefined) || (a1pmsprefix == undefined)) { getCtr=0 - return res.redirect('/mon?basename=ricsim'); + return res.redirect('/mon?basename=ricsim&a1pmsprefix=/a1-policy/v2'); } else { ricbasename=bn } - refreshInterval=2000 - //Build web page + //Build web page var htmlStr = "" + "" + "" + ""+ //2 sec auto refresh - "Policy Agent and simulator monitor"+ + "Policy Management Service and simulator monitor"+ "" + "" + "" + "

Change basename in url if other ric sim prefix is used

" + + "

Change a1pmsprefix in url if a1pms with other prefix is used

" + "
" + - "

Policy agent

" + + "

Policy Management Service

" + "" + "Status:..............................." + formatDataRow(ag1) + "
" + "Services:............................." + formatIdRowCompact(ag2) + "
" + "Types:................................" + formatIdRowCompact(ag3) + "
" + "Number of instances:.................." + formatDataRow(ag4) + "
" + + "Near-RT RICs:........................." + formatDataRow(ag5) + "
" + "
" + "

MR Stub interface

" + ""+ @@ -417,23 +966,29 @@ app.get("/mon",function(req, res){ "Fetched responses.............................." + formatDataRow(mr5) + "
" + "Current responses waiting......................" + formatDataRow(mr6) + "
" + "
"+ - "

Callback receiver

" + + "

Callback|Notification receiver

" + "" + "Callbacks received:..................." + formatDataRow(cr1) + "
" + "Callbacks fetched:...................." + formatDataRow(cr2) + "
" + "Number of waiting callback messages:.." + formatDataRow(cr3) + "
" + "
" + - "

Near-RT RIC Simulators

" + + "

R-APP Catalogue

" + + "" + + "Services:............................." + formatIdRowCompact(rc_services) + "
" + + "
" + + "

Near-RT RIC | A1 Simulators

" + "" htmlStr=htmlStr+padding("Near-RT RIC Simulator name", 35," ") htmlStr=htmlStr+padding("Types", 10," ") - htmlStr=htmlStr+padding("Instances", 10," ")+"
" - htmlStr=htmlStr+padding("",55,"=")+"
" + htmlStr=htmlStr+padding("Instances", 12," ") + htmlStr=htmlStr+padding("Data delivery", 12," ")+"
" + htmlStr=htmlStr+padding("",70,"=")+"
" for(var simIndex=0;simIndex"; } @@ -469,4 +1024,6 @@ var httpServer = http.createServer(app); 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 statistics page.") \ No newline at end of file +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 information statistics page.") +console.log("Open the web page on localhost:9999/mon3 to view CR DB in json.") \ No newline at end of file