removed usercount, user<->mac mapping and redis stuff, removed snmp checks since this all is not working anymore due to changed infrastructure in the ctdo
This commit is contained in:
parent
81634750e3
commit
1241022d9f
|
@ -1,4 +1,4 @@
|
||||||
var redis = require("redis");
|
//var redis = require("redis");
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
var exec = require('child_process').exec;
|
var exec = require('child_process').exec;
|
||||||
|
@ -10,10 +10,11 @@ var redisprefix = "ippoll:";
|
||||||
var IpPoll = function(switchaddr, hostsaddr) {
|
var IpPoll = function(switchaddr, hostsaddr) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var redisClient = redis.createClient();
|
// var redisClient = redis.createClient();
|
||||||
var regexp = /\(([0-9]+) hosts* up\)/;
|
var regexp = /\(([0-9]+) hosts* up\)/;
|
||||||
var nmap = "nmap -n -sP ";
|
var nmap = "nmap -n -sP ";
|
||||||
|
|
||||||
|
/*
|
||||||
redisClient.on("connect", function () {
|
redisClient.on("connect", function () {
|
||||||
console.log("IP-Poll: connected to redis");
|
console.log("IP-Poll: connected to redis");
|
||||||
self.emit('ready');
|
self.emit('ready');
|
||||||
|
@ -36,7 +37,7 @@ var IpPoll = function(switchaddr, hostsaddr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};*/
|
||||||
|
|
||||||
this.pollState = function() {
|
this.pollState = function() {
|
||||||
exec(nmap + switchaddr, function (error, stdout, stderr) {
|
exec(nmap + switchaddr, function (error, stdout, stderr) {
|
||||||
|
@ -51,6 +52,7 @@ var IpPoll = function(switchaddr, hostsaddr) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
this.getHistory = function(start, end, callback) {
|
this.getHistory = function(start, end, callback) {
|
||||||
|
|
||||||
redisClient.zrangebyscore(redisprefix + 'onlinecount', "-inf", "+inf", function(err, replies) {
|
redisClient.zrangebyscore(redisprefix + 'onlinecount', "-inf", "+inf", function(err, replies) {
|
||||||
|
@ -63,7 +65,7 @@ var IpPoll = function(switchaddr, hostsaddr) {
|
||||||
|
|
||||||
callback(data);
|
callback(data);
|
||||||
});
|
});
|
||||||
};
|
};*/
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(IpPoll, EventEmitter);
|
util.inherits(IpPoll, EventEmitter);
|
||||||
|
|
|
@ -2,6 +2,7 @@ exports.index = function (req, res) {
|
||||||
res.render('index', { title: 'Home' })
|
res.render('index', { title: 'Home' })
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
exports.db = function (req, res) {
|
exports.db = function (req, res) {
|
||||||
res.render('database', { title: 'Manage MAC' })
|
res.render('database', { title: 'Manage MAC' })
|
||||||
};
|
};
|
||||||
|
@ -45,3 +46,4 @@ exports.form = function (req, res) {
|
||||||
res.redirect("/db");
|
res.redirect("/db");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
*/
|
|
@ -6,7 +6,7 @@ var cookieParser = require('cookie-parser');
|
||||||
var bodyParser = require('body-parser');
|
var bodyParser = require('body-parser');
|
||||||
var cookieSession = require('cookie-session');
|
var cookieSession = require('cookie-session');
|
||||||
var flash = require('connect-flash');
|
var flash = require('connect-flash');
|
||||||
var SnmpMac = require("./snmp-mac");
|
//var SnmpMac = require("./snmp-mac");
|
||||||
var IpPoll = require("./ip-poll");
|
var IpPoll = require("./ip-poll");
|
||||||
var Flukso = require("./flukso");
|
var Flukso = require("./flukso");
|
||||||
var routes = require("./routes");
|
var routes = require("./routes");
|
||||||
|
@ -68,8 +68,9 @@ var usercountanswer = {at: 0, current_value: 0, datapoints: [
|
||||||
{at: 0, value: 0}
|
{at: 0, value: 0}
|
||||||
]};
|
]};
|
||||||
|
|
||||||
var snmpMac = new SnmpMac("juni.ctdo.de", "ctdo23");
|
//var snmpMac = new SnmpMac("juni.ctdo.de", "ctdo23");
|
||||||
var ippoll = new IpPoll("flipdot.raum.ctdo.de", "195.160.169.30-120");
|
//var ippoll = new IpPoll("flipdot.raum.ctdo.de", "195.160.169.30-120");
|
||||||
|
var ippoll = new IpPoll("flipdot.raum.ctdo.de");
|
||||||
var flukso = new Flukso("flukso.raum.ctdo.de", "/sensor/cf00e0b22230f4a8870af58f2b8719dd");
|
var flukso = new Flukso("flukso.raum.ctdo.de", "/sensor/cf00e0b22230f4a8870af58f2b8719dd");
|
||||||
var mqtt = mqttClient.connect('mqtt://raum.ctdo.de');
|
var mqtt = mqttClient.connect('mqtt://raum.ctdo.de');
|
||||||
var connected = false;
|
var connected = false;
|
||||||
|
@ -77,6 +78,7 @@ var connected = false;
|
||||||
var port = '9911';
|
var port = '9911';
|
||||||
var address = 'localhost';
|
var address = 'localhost';
|
||||||
|
|
||||||
|
/*
|
||||||
snmpMac.on('done', function (res) {
|
snmpMac.on('done', function (res) {
|
||||||
simpleanswer.names = res;
|
simpleanswer.names = res;
|
||||||
simpleanswer.lastchange = new Date().getTime();
|
simpleanswer.lastchange = new Date().getTime();
|
||||||
|
@ -87,6 +89,7 @@ ippoll.on('doneCount', function (num) {
|
||||||
simpleanswer.lastchange = new Date().getTime();
|
simpleanswer.lastchange = new Date().getTime();
|
||||||
ippoll.pollState();
|
ippoll.pollState();
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
ippoll.on('doneState', function (state) {
|
ippoll.on('doneState', function (state) {
|
||||||
spaceanswer.state.open = state;
|
spaceanswer.state.open = state;
|
||||||
|
@ -96,6 +99,7 @@ ippoll.on('doneState', function (state) {
|
||||||
io.sockets.emit('sdata', {data: simpleanswer});
|
io.sockets.emit('sdata', {data: simpleanswer});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
flukso.on('done', function (num) {
|
flukso.on('done', function (num) {
|
||||||
simpleanswer.power = num;
|
simpleanswer.power = num;
|
||||||
spaceanswer.sensors.power_consumption[0].value = num;
|
spaceanswer.sensors.power_consumption[0].value = num;
|
||||||
|
@ -122,8 +126,9 @@ function sendSimple () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function work() {
|
function work() {
|
||||||
snmpMac.poll();
|
/* snmpMac.poll();
|
||||||
ippoll.pollCount();
|
ippoll.pollCount();*/
|
||||||
|
ippoll.pollState();
|
||||||
sendSimple();
|
sendSimple();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +138,7 @@ work();
|
||||||
setInterval(flukso.pollPower, 5000);
|
setInterval(flukso.pollPower, 5000);
|
||||||
flukso.pollPower();
|
flukso.pollPower();
|
||||||
|
|
||||||
app.set('snmpMac', snmpMac); //TODO: wie kann man das schoener machen? (Modul in die Routes reintun)
|
//app.set('snmpMac', snmpMac);
|
||||||
|
|
||||||
app.use(express.static('public'));
|
app.use(express.static('public'));
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
|
@ -158,13 +163,13 @@ app.get('/api/simple/v2', function (req, res) {
|
||||||
res.send(simpleanswer);
|
res.send(simpleanswer);
|
||||||
});
|
});
|
||||||
app.get('/api/usercount', function (req, res) {
|
app.get('/api/usercount', function (req, res) {
|
||||||
ippoll.getHistory("-inf", "+inf", function (data) {
|
/*ippoll.getHistory("-inf", "+inf", function (data) {
|
||||||
usercountanswer.datapoints.length = 0;
|
usercountanswer.datapoints.length = 0;
|
||||||
usercountanswer.at = simpleanswer.lastchange;
|
usercountanswer.at = simpleanswer.lastchange;
|
||||||
usercountanswer.current_value = simpleanswer.count;
|
usercountanswer.current_value = simpleanswer.count;
|
||||||
usercountanswer.datapoints = data;
|
usercountanswer.datapoints = data; */
|
||||||
res.send(usercountanswer);
|
res.send(usercountanswer);
|
||||||
});
|
//});
|
||||||
});
|
});
|
||||||
|
|
||||||
function getstatusImage(req, res) {
|
function getstatusImage(req, res) {
|
||||||
|
@ -185,8 +190,8 @@ app.get('/api/simple/image.png', function (req, res) {
|
||||||
getstatusImage(req, res);
|
getstatusImage(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/db', routes.db);
|
//app.get('/db', routes.db);
|
||||||
app.post('/form', routes.form);
|
//app.post('/form', routes.form);
|
||||||
app.get('/', routes.index);
|
app.get('/', routes.index);
|
||||||
|
|
||||||
//server.listen(3000, 'localhost');
|
//server.listen(3000, 'localhost');
|
||||||
|
|
|
@ -4,11 +4,17 @@ block content
|
||||||
|
|
||||||
.intro
|
.intro
|
||||||
p
|
p
|
||||||
|
//-
|
||||||
| Hier siehst du den aktuellen Status von uns. Die Daten werden vom Router und unserem Flukso
|
| Hier siehst du den aktuellen Status von uns. Die Daten werden vom Router und unserem Flukso
|
||||||
| eingesammelt. Die Anzahl der Geräte und der Status selber werden Minütlich abgefragt. Unseren
|
| eingesammelt. Die Anzahl der Geräte und der Status selber werden Minütlich abgefragt. Unseren
|
||||||
| Energieverbrauch bekommst du alle fünf Sekunden neu. Den Status "geöffnet" oder "geschlossen"
|
| Energieverbrauch bekommst du alle fünf Sekunden neu. Den Status "geöffnet" oder "geschlossen"
|
||||||
| bestimmt das Programm mit einem ping auf den Switch im Raum. Mit dem Knopf unter dem Stromverbrauch
|
| bestimmt das Programm mit einem ping auf den Switch im Raum. Mit dem Knopf unter dem Stromverbrauch
|
||||||
| kannst du einschalten, dass du eine Benachrichtigung bei einer Änderung bekommst. Der Tab muss dafür offen bleiben.
|
| kannst du einschalten, dass du eine Benachrichtigung bei einer Änderung bekommst. Der Tab muss dafür offen bleiben.
|
||||||
|
| Hier siehst du den aktuellen Status von uns. Die Daten werden von unserem Flukso
|
||||||
|
| eingesammelt. Der Status selber wird Minütlich abgefragt. Unseren
|
||||||
|
| Energieverbrauch bekommst du alle fünf Sekunden neu. Den Status "geöffnet" oder "geschlossen"
|
||||||
|
| bestimmt das Programm mit einem ping auf den Switch im Raum. Mit dem Knopf unter dem Stromverbrauch
|
||||||
|
| kannst du einschalten, dass du eine Benachrichtigung bei einer Änderung bekommst. Der Tab muss dafür offen bleiben.
|
||||||
|
|
||||||
.ink-grid(ng-controller='StatusCtrl')
|
.ink-grid(ng-controller='StatusCtrl')
|
||||||
.column-group.gutters
|
.column-group.gutters
|
||||||
|
@ -29,6 +35,7 @@ block content
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-
|
||||||
.large-50.medium-80.small-100
|
.large-50.medium-80.small-100
|
||||||
h2 Anzahl Geräte im LAN:
|
h2 Anzahl Geräte im LAN:
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,9 @@ html(ng-app="roomstateapp")
|
||||||
nav.ink-navigation
|
nav.ink-navigation
|
||||||
ul.menu.horizontal
|
ul.menu.horizontal
|
||||||
li: a(href="/") Raumstatus
|
li: a(href="/") Raumstatus
|
||||||
|
//-
|
||||||
li: a(href='/db') Name verwalten
|
li: a(href='/db') Name verwalten
|
||||||
|
|
||||||
li: a(href="//www.chaostreff-dortmund.de/") CTDO Webseite
|
li: a(href="//www.chaostreff-dortmund.de/") CTDO Webseite
|
||||||
li: a(href="//wiki.ctdo.de/") CTDO Wiki
|
li: a(href="//wiki.ctdo.de/") CTDO Wiki
|
||||||
li: a(href="https://repos.ctdo.de/ctdo/raumstatus/tree/master") Source
|
li: a(href="https://repos.ctdo.de/ctdo/raumstatus/tree/master") Source
|
||||||
|
|
Loading…
Reference in New Issue