js gurus,
I'm creating my first node.js server/client reporting app. It gathers data via rest APIs to keep a pulse on web services I use such as CloudFlare.com, UptimeRobot.com, etc. In addition (where I need help), I'd like to connect my local reporting node.js server to my production node.js server, which will report CPU load and available memory in intervals.
Starting on the production server, here's what I have so far:
(function(){
var status = {load: 0.9, usedMem: 0.5}; //contians this machine's memory usage and average CPU loads, just some basic values here to get things started, no assistance needed with getting those values
///////////////////////////////////
//socket server
///////////////////////////////////
var app = require('express')()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server);
server.listen(3000);
io.sockets.on('connection', function (socket) {
socket.emit('status', status); //NOT SO FAST! I need to authenticate before giving away this stuff!!!
});
})();
And here's the 'client' side (although the client will be server, which collects and delivers this and other data to an actual browser client):
(function(){
var socket = io.connect('http://localhost:3000'); //too easy, right?
socket.on('status', function (data) {
console.log(data);
});
})();
It would terrify me to actually use this in a production environment. Any thoughts on how to "simply" tighten this up? For the most part, only one other machine will/should have access to the production server's node.js server. However, I'll likely need to set up access for a few people to access the reporting server eventually.
Thank you for any tips and pointers in advance. I truly appreciate it.