var http = require('http'); var express = require('express'); var app = express(); //I am alive app.get("/",function(req, res){ res.send("ok"); }) //Get parameter valuye from other server function getSimCtr(url, cb) { var data = ''; http.get(url, (resp) => { // A chunk of data has been recieved. resp.on('data', (chunk) => { data += chunk; }); // The whole response has been received. resp.on('end', () => { //Pad data to fixed length var i = 20-data.length; while(i>0) { data = data+" "; i--; } cb(data); }); }).on("error", (err) => { console.log("Error: " + err.message); cb("no response"); }); }; //Status variables, for parameters values fetched from other simulators var mr1, mr2, mr3, mr4, mr5, mr6, mr7, mr8, mr9, mr10; var dr1, dr2, dr3, dr4, dr5, dr6, dr7, dr8, dr9, dr10; var drr1, drr2, drr3, drr4, drr5, drr6; //Heartbeat var var dfc1; app.get("/mon",function(req, res){ //DFC getSimCtr("http://127.0.0.1:8100/heartbeat", function(data) { dfc1 = data; }); //MR getSimCtr("http://127.0.0.1:2222/ctr_requests", function(data) { mr1 = data; }); getSimCtr("http://127.0.0.1:2222/ctr_responses", function(data) { mr2 = data; }); getSimCtr("http://127.0.0.1:2222/ctr_unique_files", function(data) { mr3 = data; }); getSimCtr("http://127.0.0.1:2222/tc_info", function(data) { mr4 = data; }); getSimCtr("http://127.0.0.1:2222/ctr_events", function(data) { mr5 = data; }); getSimCtr("http://127.0.0.1:2222/execution_time", function(data) { mr6 = data; }); getSimCtr("http://127.0.0.1:2222/ctr_unique_PNFs", function(data) { mr7 = data; }); getSimCtr("http://127.0.0.1:2222/exe_time_first_poll", function(data) { mr8 = data; }); getSimCtr("http://127.0.0.1:2222/ctr_files", function(data) { mr9 = data; }); getSimCtr("http://127.0.0.1:2222/status", function(data) { mr10 = data; }); //DR getSimCtr("http://127.0.0.1:3906/ctr_publish_query", function(data) { dr1 = data; }); getSimCtr("http://127.0.0.1:3906/ctr_publish_query_published", function(data) { dr2 = data; }); getSimCtr("http://127.0.0.1:3906/ctr_publish_query_not_published", function(data) { dr3 = data; }); getSimCtr("http://127.0.0.1:3906/ctr_publish_req", function(data) { dr4 = data; }); getSimCtr("http://127.0.0.1:3906/ctr_publish_req_redirect", function(data) { dr5 = data; }); getSimCtr("http://127.0.0.1:3906/ctr_publish_req_published", function(data) { dr6 = data; }); getSimCtr("http://127.0.0.1:3906/ctr_published_files", function(data) { dr7 = data; }); getSimCtr("http://127.0.0.1:3906/tc_info", function(data) { dr8 = data; }); getSimCtr("http://127.0.0.1:3906/execution_time", function(data) { dr9 = data; }); getSimCtr("http://127.0.0.1:3906/ctr_double_publish", function(data) { dr10 = data; }); //DR REDIR getSimCtr("http://127.0.0.1:3908/ctr_publish_requests", function(data) { drr1 = data; }); getSimCtr("http://127.0.0.1:3908/ctr_publish_responses", function(data) { drr2 = data; }); getSimCtr("http://127.0.0.1:3908/tc_info", function(data) { drr3 = data; }); getSimCtr("http://127.0.0.1:3908/execution_time", function(data) { drr4 = data; }); getSimCtr("http://127.0.0.1:3908/time_lastpublish", function(data) { drr5 = data; }); getSimCtr("http://127.0.0.1:3908/dwl_volume", function(data) { drr6 = data; }); //Build web page var str = "" + "" + "
" + ""+ //5 sec auto reefresh "