X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;ds=sidebyside;f=src%2Froutes%2Findex.js;h=51f81466c032defce62f7f0eb50113ad219a620f;hb=0435950ac163f7cd63ba0bbd3d4882820d9f53fb;hp=371ba2c4837f08b4b9e31bd1288ce3e301477168;hpb=bc809c6977606f57fd4e4fbae288524a7bae5c33;p=VSoRC%2F.git diff --git a/src/routes/index.js b/src/routes/index.js index 371ba2c..51f8146 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -33,7 +33,7 @@ router.get('/free', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("free -b | grep Mem | awk '{print $7}'", function(error, stdout, stderr) { + child = exec("free -b | grep Mem | awk '{print $3}'", function(error, stdout, stderr) { console.log("free"); res.send(stdout); }); @@ -44,7 +44,7 @@ router.get('/mpstat', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("mpstat 1 1| grep all | awk '{print $13}'", function(error, stdout, stderr) { + child = exec("mpstat 1 1| grep all | grep Average | awk '{print $12}'", function(error, stdout, stderr) { console.log("mpstat"); res.send(stdout); }); @@ -55,7 +55,7 @@ router.get('/ifstat', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("ifstat -n -b -i wlp2s0 0.3 1 | grep [0-9]$", function(error, stdout, stderr) { + child = exec("ifstat -n -b -i eth0 0.3 1 | grep [0-9]$", function(error, stdout, stderr) { console.log("ifstat"); res.send(stdout); }); @@ -71,11 +71,61 @@ router.get('/gettopo', (req, res) => { }); }); +router.get('/net', (req, res) => { + var sys = require('sys') + var exec = require('child_process').exec; + var child; + child = exec("cd /home/pi/scripts && echo net > fifo", function(error, stdout, stderr) { + console.log("pingall"); + res.send(stdout); + }); +}); + +router.get('/nodes', (req, res) => { + var sys = require('sys') + var exec = require('child_process').exec; + var child; + child = exec("cd /home/pi/scripts && echo nodes > fifo", function(error, stdout, stderr) { + console.log("pingall"); + res.send(stdout); + }); +}); + +router.get('/status', (req, res) => { + var sys = require('sys') + var exec = require('child_process').exec; + var child; + child = exec("cd /home/pi/scripts && echo status > fifo", function(error, stdout, stderr) { + console.log("pingall"); + res.send(stdout); + }); +}); + +router.get('/intfs', (req, res) => { + var sys = require('sys') + var exec = require('child_process').exec; + var child; + child = exec("cd /home/pi/scripts && echo intfs > fifo", function(error, stdout, stderr) { + console.log("pingall"); + res.send(stdout); + }); +}); + +router.get('/iperf', (req, res) => { + var sys = require('sys') + var exec = require('child_process').exec; + var child; + child = exec("cd /home/pi/scripts && echo iperf > fifo", function(error, stdout, stderr) { + console.log("pingall"); + res.send(stdout); + }); +}); + router.get('/pingall', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi && echo pingall > fifo", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && echo pingall > fifo", function(error, stdout, stderr) { console.log("pingall"); res.send(stdout); }); @@ -84,7 +134,7 @@ router.get('/placement', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi && echo placement > fifo", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && echo placement > fifo", function(error, stdout, stderr) { console.log("placement"); res.send(stdout); }); @@ -94,7 +144,7 @@ router.get('/getvsorcdata', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi && cat aichivo 2>&1", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && cat aichivo 2>&1", function(error, stdout, stderr) { console.log("getting vsorc data"); res.send(stdout); }); @@ -103,7 +153,7 @@ router.get('/getcontrollerdata', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi && cat controllerout 2>&1", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && cat controllerout 2>&1", function(error, stdout, stderr) { console.log("getting controller data"); res.send(stdout); }); @@ -151,7 +201,7 @@ router.get('/startcontroller', (req, res) => { var child; //cd /home/pi && setsid $(cat /home/pi/ejecutarcontroller.sh | grep sudo) >/dev/null 2>&1 < /dev/null & //cd /home/pi && ./ejecutarcontroller.sh > /dev/null 2>&1 < /dev/null & //comando anterior - child = exec("cd /home/pi && rm controllerout && touch controllerout && ./ejecutarcontroller.sh > controllerout 2>&1 &", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && touch controllerout && ./ejecutarcontroller.sh > controllerout 2>&1 &", function(error, stdout, stderr) { console.log("controller started"); res.send(stdout); }); @@ -161,7 +211,7 @@ router.get('/stopcontroller', (req, res) => { var sys = require('sys') var exec = require('child_process').exec; var child; - child = exec("cd /home/pi && rm controllerout && sudo kill $(ps aux | grep python | grep ryu | awk {'print $2'})", function(error, stdout, stderr) { + child = exec("cd /home/pi/scripts && rm controllerout && sudo kill $(ps aux | grep python | grep ryu | awk {'print $2'})", function(error, stdout, stderr) { console.log("controller stopped"); res.send(stdout); }); @@ -178,20 +228,20 @@ router.get('/startvsorc', (req, res) => { request = JSON.parse(req.query.topology) console.log("Topology is : \n"+ request); //controlar que solo se haga un arranque por vez y agregar el exec 3>fifo - child0 = exec("cd /home/pi && echo \""+request+"\" > data", function(error, stdout, stderr) { + child0 = exec("cd /home/pi/scripts && echo \""+request+"\" > data", function(error, stdout, stderr) { console.log(stdout + stderr); answer+=stdout; }); - child1 = exec("cd /home/pi && mkfifo fifo && rm aichivo && touch aichivo", function(error, stdout, stderr) { + child1 = exec("cd /home/pi/scripts && mkfifo fifo && touch aichivo", function(error, stdout, stderr) { console.log(stdout + stderr); answer+=stdout; }); - child2 = exec("exec 3>fifo", function(error, stdout, stderr) { + child2 = exec("cd /home/pi/scripts && exec 3>fifo", function(error, stdout, stderr) { console.log(stdout + stderr); answer+=stdout; }); //child3 uses tail so it can read from fifo even after a EOF - child3 = exec("cd /home/pi && tail -n +1 -f fifo | sudo ./clusterGRE.py > aichivo 2>&1 &", function(error, stdout, stderr) { + child3 = exec("cd /home/pi/scripts && tail -n +1 -f fifo | sudo ./clusterGRE.py > aichivo 2>&1 &", function(error, stdout, stderr) { console.log(stdout + stderr); answer+=stdout; }); @@ -206,7 +256,7 @@ router.get('/stopvsorc', (req,res) =>{ var child3; var payload console.log("erasing..."); - child1 = exec("cd /home/pi && exec 3>&- && rm fifo && rm aichivo", function(error, stdout, stderr) { + child1 = exec("cd /home/pi/scripts && exec 3>&- && rm fifo && rm aichivo", function(error, stdout, stderr) { console.log(stdout); payload+="rm done\n\n"+stdout; @@ -219,7 +269,7 @@ router.get('/stopvsorc', (req,res) =>{ payload+="killed\n\n"+stdout; }); console.log("Multisshing and cleaning..."); - child3 = exec("cd /home/pi && ./multissh.sh sudo -E mn -c; sudo -E mn -c", function(error, stdout, stderr) { + child3 = exec("cd /home/pi/scripts && ./multissh.sh sudo -E mn -c; sudo -E mn -c", function(error, stdout, stderr) { console.log(stdout); console.log("multisshed"); payload+="Multisshed\n\n"+stdout;