changed nmap timing,
added label to gage, cleaned up a bit, removed redis foo from flukso code since it is not needed
This commit is contained in:
parent
0dd746c47f
commit
b89ebeaf4f
|
@ -1,24 +1,12 @@
|
|||
var redis = require("redis");
|
||||
var util = require('util');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var http = require("http");
|
||||
|
||||
var redisprefix = "flukso:";
|
||||
|
||||
var Flukso = function(hostname, pathname) {
|
||||
var self = this;
|
||||
|
||||
var redisClient = redis.createClient();
|
||||
var regexp = /([0-9]+)\]\]$/; // /\(([0-9]+) hosts* up\)/;
|
||||
|
||||
|
||||
redisClient.on("connect", function () {
|
||||
console.log("connected to redis");
|
||||
self.emit('ready');
|
||||
});
|
||||
|
||||
this.pollPower = function() {
|
||||
|
||||
http.request({ host: hostname, path: pathname }, function(response) {
|
||||
var str = '';
|
||||
|
||||
|
@ -27,39 +15,16 @@ var Flukso = function(hostname, pathname) {
|
|||
});
|
||||
|
||||
response.on('end', function () {
|
||||
// console.log("http received: " + str);
|
||||
|
||||
var matches = regexp.exec(str);
|
||||
if(matches != null && matches.length == 2) {
|
||||
var time = Date.now();
|
||||
|
||||
redisClient.zremrangebyscore(redisprefix + 'power', "-inf", time - 7*24*60*1000);
|
||||
|
||||
var num = matches[1];
|
||||
|
||||
redisClient.zadd(redisprefix + 'power', time, time + "|" + num, function() {
|
||||
self.emit('done', parseInt(num));
|
||||
});
|
||||
}
|
||||
});
|
||||
}).end();
|
||||
};
|
||||
|
||||
// this.getHistory = function(start, end, callback) {
|
||||
//
|
||||
// redisClient.zrangebyscore(redisprefix + 'power', start, end, function(err, replies) {
|
||||
// var data = [];
|
||||
//
|
||||
// replies.forEach(function (reply, i) {
|
||||
// var line = reply.split('|');
|
||||
// data.push( { at: moment(parseInt(line[0])).format(), value: line[1] });
|
||||
// });
|
||||
//
|
||||
// callback(data);
|
||||
// });
|
||||
// };
|
||||
};
|
||||
|
||||
util.inherits(Flukso, EventEmitter);
|
||||
|
||||
module.exports = Flukso;
|
||||
|
|
|
@ -10,7 +10,7 @@ var IpPoll = function(switchaddr, hostsaddr) {
|
|||
|
||||
var redisClient = redis.createClient();
|
||||
var regexp = /\(([0-9]+) hosts* up\)/;
|
||||
var nmap = "nmap -n -sP -T3 ";
|
||||
var nmap = "nmap -n -sP -T2 ";
|
||||
|
||||
redisClient.on("connect", function () {
|
||||
console.log("connected to redis");
|
||||
|
|
|
@ -10,8 +10,8 @@ angular.module('roomstateapp.controllers', []).
|
|||
url: '/api/simple/v2'
|
||||
}).
|
||||
success(function (data, status, headers, config) {
|
||||
$scope.simple = data;
|
||||
gpower.refresh(message.data.power);
|
||||
$scope.simple = data;
|
||||
}).
|
||||
error(function (data, status, headers, config) {
|
||||
//$scope.name = 'Error!'
|
||||
|
@ -20,8 +20,8 @@ angular.module('roomstateapp.controllers', []).
|
|||
|
||||
Socket.on('sdata', function(message) {
|
||||
console.log("received data from server: " + message.data.names);
|
||||
$scope.simple = message.data;
|
||||
gpower.refresh(message.data.power);
|
||||
$scope.simple = message.data;
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -75,8 +75,10 @@ gpower = new JustGage({
|
|||
id: "gauge",
|
||||
value: 0,
|
||||
min: 0,
|
||||
max: 15000,
|
||||
title: "Power"
|
||||
max: 60000,
|
||||
title: " ",
|
||||
label: "Watt",
|
||||
showMinMax: false
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
exports.index = function (req, res) {
|
||||
res.render('index', { title: 'Home', status: req.flash('status') })
|
||||
res.render('index', { title: 'Home' })
|
||||
};
|
||||
|
||||
exports.db = function (req, res) {
|
||||
res.render('database', { title: 'Manage MAC', status: req.flash('status') })
|
||||
res.render('database', { title: 'Manage MAC' })
|
||||
};
|
||||
|
||||
exports.form = function (req, res) {
|
||||
|
|
|
@ -2,6 +2,13 @@ extend layout
|
|||
|
||||
block content
|
||||
|
||||
.intro
|
||||
p
|
||||
| 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
|
||||
| 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.
|
||||
|
||||
.ink-grid(ng-controller='StatusCtrl')
|
||||
.column-group.gutters
|
||||
.large-20.medium-20.small-100
|
||||
|
@ -22,7 +29,7 @@ block content
|
|||
|
||||
|
||||
.large-50.medium-80.small-100
|
||||
h2 Anzahl Geräte:
|
||||
h2 Anzahl Geräte im LAN:
|
||||
|
||||
#graph
|
||||
|
||||
|
|
|
@ -19,13 +19,6 @@ html(ng-app="roomstateapp")
|
|||
header
|
||||
h1 chaostreff status
|
||||
|
||||
.intro
|
||||
p
|
||||
| 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
|
||||
| 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.
|
||||
|
||||
.main-content
|
||||
block content
|
||||
|
||||
|
|
Loading…
Reference in New Issue