+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) {
+ 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_ecs)
+
+ 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<jd.length;i++) {
+ if (tmp_serv.length > 0) {
+ tmp_serv=tmp_serv+","
+ }
+ tmp_serv=tmp_serv+jd[i]["name"]
+ }
+
+ }
+ catch (err) {
+ tmp_serv="no_response"
+ }
+ rc_services=tmp_serv
+ });
+ clearFlag("rc_stat")
+ }
+ fetchAllMetrics_rc();
+ }, 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 = "<!DOCTYPE html>" +
+ "<html>" +
+ "<head>" +
+ "<meta http-equiv=\"refresh\" content=\"2\">"+ //2 sec auto refresh
+ "<title>CR DB dump</title>"+
+ "</head>" +
+ "<body style=\"white-space: pre-wrap\">" +
+ json_str +
+ "</body>" +
+ "</html>";
+ res.send(htmlStr);
+})
+