Created
February 19, 2017 04:34
-
-
Save mwdchang/1e64fe1f9ddf541af68886627ada44f0 to your computer and use it in GitHub Desktop.
OICR proxy dashboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"cmd": "ssh -D9002 proxy-something.lalala.com", | |
"des": "SOCK5 Proxy to proxy-something" | |
}, | |
{ | |
"cmd": "ssh -D9003 proxy-something-else.lalala.com", | |
"des": "SOCK5 Proxy to hproxy-dev" | |
}, | |
{ | |
"cmd": "ssh -L 9999:es.lalala.com:9300 -N cool-dude@proxy-something.lalala.com ssh -L 9300:localhost:9300 -N -p", | |
"des": "ElassticSearch Prod" | |
}, | |
{ | |
"cmd": "ssh -L 9998:es.lalala.com:9200 -N cool-dude@proxy-something.lalala.com ssh -L 9200:localhost:9200 -N -p", | |
"des": "ElassticSearch Prod Web" | |
}, | |
{ | |
"cmd": "ssh -L 50001:postgres.lalala.com:5432 -N cool-dude@proxy-something.lalala.com ssh -L 5432:localhost:5432 -N -p", | |
"des": "!! TEMP PostgreSQL Production" | |
}, | |
{ | |
"cmd": "ssh -L 50002:mongo.lalala.com:27017 -N cool-dude@proxy-something.lalala.com ssh -L 27017:localhost:27017 -N -p", | |
"des": "!! TEMP MongoDB Production" | |
}, | |
{ | |
"cmd": "ssh -L 8888:localhost:8888 cool-dude@hproxy-dev.lalala.com", | |
"des": "Jerry server" | |
}, | |
{ | |
"cmd": "ssh -L 7777:localhost:7777 cool-dude@proxy-something.lalala.com", | |
"des": "Shane server" | |
}, | |
{ | |
"cmd": "ssh -v -L9002:localhost:9000 cool-dude@chicken.com ssh -D 9000 cool-dude@proxy-something.lalala.com", | |
"des": "Chicken Proxy" | |
}, | |
{ | |
"cmd": "~/elasticsearch-1.4.4/bin/elasticsearch", | |
"des": "ElasticSearch local" | |
}, | |
{ | |
"cmd": "~/mongodb-osx-x86_64-2.4.1/bin/mongod", | |
"des": "Mongo local" | |
}, | |
{ | |
"cmd": "grunt --gruntfile ~/workspace/dcc/dcc-portal/dcc-portal-ui/src/main/js/Gruntfile.js server", | |
"des": "Grunt server task" | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title> Port Forward </title> | |
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css"> | |
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
<script src="d3.v3.min.js" charset="utf-8"></script> | |
<link rel="stylesheet" src="bootstrap.css"> | |
<style> | |
</style> | |
</head> | |
<body style="margin:15px"> | |
<div style="padding-left:10%; padding-right:10%"> | |
<span> Processes/Port Dash</span> | |
<br> | |
<hr> | |
<div id="forward"> | |
</div> | |
</div> | |
<script> | |
function refresh() { | |
d3.json("/config", function(data) { | |
d3.select("#forward").selectAll("*").remove(); | |
var table = d3.select("#forward").append("table") | |
.classed("table",true) | |
.classed("table-bordered",true) | |
.classed("table-condensed", true) | |
.append("tbody"); | |
data.forEach(function(config, idx) { | |
var cmd = config.cmd; | |
var des = config.des; | |
var stat = config.status; | |
var stdout = ""; | |
if (config.stdout) { | |
console.log("Proc: ", config.proc); | |
stdout = config.stdout; | |
} | |
// console.log(config); | |
var tr = table.append("tr"); | |
tr.style("background-color", function() { | |
if (stat === "running") { | |
return d3.rgb(40, 230, 55); | |
} else if (stat === "stopped") { | |
return d3.rgb(230, 100, 25); | |
} | |
}); | |
tr.append("td").append("button") | |
.classed("button", true) | |
.text(function() { | |
if (stat === "running") { | |
return "Stop"; | |
} else { | |
return "Start"; | |
} | |
}) | |
.on("click", function() { | |
console.log("Stat is", stat) | |
if (stat != "running" ) { | |
// Start | |
console.log("Starting", idx); | |
d3.json("/start?idx=" + idx, function(d){ console.log(d);}); | |
d3.select(this).text(""); | |
d3.select(this).append("i").classed("glyphicon", true).classed("glyphicon-refresh", true); | |
} else { | |
// Stop | |
console.log("Stopping"); | |
d3.json("/stop?idx=" + idx, function(d){ console.log(d);}); | |
d3.select(this).text(""); | |
d3.select(this).append("i").classed("glyphicon", true).classed("glyphicon-refresh", true); | |
} | |
}); | |
tr.append("td").text(des); | |
tr.append("td").style("font-size", "11px").style("max-width", "400px").text(cmd); | |
tr.append("td").text(stat); | |
tr.append("td").text(stdout); | |
}); | |
}); | |
} | |
refresh(); | |
window.setInterval( refresh, 5000); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var static = require('node-static'); | |
var request = require("request"); | |
var express = require('express'); | |
var sys = require('sys'); | |
var exec = require('child_process').exec; | |
var fs = require('fs'); | |
//////////////////////////////////////////////////////////////////////////////// | |
// NodeJS server for spawning child proxy tasks | |
//////////////////////////////////////////////////////////////////////////////// | |
var file = new(static.Server)('/Users/dchang/test'); | |
var app = express(); | |
var config = []; | |
fs.readFile("config.json", "utf-8", function(err, data) { | |
console.log(data); | |
config = JSON.parse(data); | |
config.forEach(function(c) { | |
c.proc = null; // Process handle | |
c.status = "not started"; | |
}) | |
}); | |
function start( cmd ) { | |
var child; | |
child = exec(cmd, function(err, stdout, stderr) { | |
console.log(stdout); | |
}); | |
child.stdout.on('data', function(data){ | |
console.log('stdout:'+data); | |
//if (! child.stdout) child.stdout = ""; | |
//child.stdout += data; | |
}); | |
child.stderr.on('data', function(data){ | |
console.log('stderr:'+data); | |
}); | |
child.stdin.on('data', function(data){ | |
console.log('stdin:'+data); | |
}); | |
return child; | |
} | |
app.get("/stop", function(req, res) { | |
var idx = req.query.idx; | |
config[idx].proc.kill(); | |
config[idx].status = "stopped"; | |
delete config[idx].proc; | |
return res.send("200"); | |
}); | |
app.get("/start", function(req, res) { | |
var idx = req.query.idx; | |
config[idx].proc = start( config[idx].cmd ); | |
config[idx].status = "running"; | |
console.log("starting........."); | |
return res.send("200"); | |
}); | |
app.get("/config", function(req, res) { | |
res.set("Content-Type", "application/json"); | |
var cc = [] | |
config.forEach(function(c) { | |
if (c.proc) { | |
// If error try to kill process | |
if (c.proc.exitCode && c.proc.exitCode != 0) { | |
console.log("killing...."); | |
c.status = "stopped"; | |
c.proc.kill(); | |
delete c.proc; | |
} | |
} | |
cc.push({ | |
cmd: c.cmd, | |
// stdout: c.proc? c.proc.stdout : "", | |
des: c.des, | |
status: c.status | |
}); | |
}); | |
//console.log(cc); | |
res.send(cc); | |
}); | |
//////////////////////////////////////////////////////////////////////////////// | |
// This needs to go last | |
//////////////////////////////////////////////////////////////////////////////// | |
app.get(/\w*/, function(req, res){ | |
file.serve(req, res); | |
}); | |
app.listen(54321); | |
console.log('Listening on port 54321. Cheers!...'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment