Updated ALL
This commit is contained in:
parent
8d9133c6d3
commit
84e7689377
|
@ -1,28 +1,24 @@
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
var http = require("http");
|
var request = require('request');
|
||||||
|
|
||||||
var Flukso = function(hostname, pathname) {
|
var Flukso = function(hostname, pathname) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var regexp = /([0-9]+)\]\]$/; // /\(([0-9]+) hosts* up\)/;
|
var regexp = /([0-9]+)\]\]$/; // /\(([0-9]+) hosts* up\)/;
|
||||||
|
|
||||||
this.pollPower = function() {
|
this.pollPower = function() {
|
||||||
http.request({ host: hostname, path: pathname }, function(response) {
|
request({url: "http://" + hostname + pathname}, function(error, res, response) {
|
||||||
var str = '';
|
if (error) {
|
||||||
|
self.emit('failed', error)
|
||||||
response.on('data', function(chunk) {
|
} else {
|
||||||
str += chunk;
|
var matches = regexp.exec(response);
|
||||||
});
|
if(matches != null && matches.length == 2) {
|
||||||
|
|
||||||
response.on('end', function () {
|
|
||||||
var matches = regexp.exec(str);
|
|
||||||
if(matches != null && matches.length == 2) {
|
|
||||||
var time = Date.now();
|
var time = Date.now();
|
||||||
var num = matches[1];
|
var num = matches[1];
|
||||||
self.emit('done', parseInt(num));
|
self.emit('done', parseInt(num));
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}).end();
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ 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;
|
||||||
|
var moment = require('moment');
|
||||||
|
|
||||||
|
|
||||||
var redisprefix = "ippoll:";
|
var redisprefix = "ippoll:";
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,24 @@
|
||||||
{
|
{
|
||||||
"name": "statusbot",
|
"name": "statusbot",
|
||||||
"description": "ctdo status bot",
|
"description": "ctdo status bot",
|
||||||
"version": "0.0.2",
|
"version": "0.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^3.4",
|
"body-parser": "1.14.2",
|
||||||
"connect-flash": "^0.1.1",
|
"connect-flash": "0.1.1",
|
||||||
"net-snmp": "^1.1.8",
|
"cookie-parser": "1.4.0",
|
||||||
"redis": "^0.8.5",
|
"cookie-session": "2.0.0-alpha.1",
|
||||||
"underscore": "^1.5.2",
|
"events": "1.1.0",
|
||||||
"jade": "^0.35",
|
"express": "4.13.3",
|
||||||
"socket.io": "^0.9.16",
|
"jade": "1.11.0",
|
||||||
"moment": "^2.3.1"
|
"moment": "2.11.0",
|
||||||
},
|
"net-snmp": "1.1.14",
|
||||||
"main": "statusbot"
|
"path": "0.12.7",
|
||||||
|
"redis": "2.4.2",
|
||||||
|
"request": "2.67.0",
|
||||||
|
"socket.io": "1.4.3",
|
||||||
|
"underscore": "1.8.3",
|
||||||
|
"util": "0.10.3"
|
||||||
|
},
|
||||||
|
"main": "statusbot"
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,10 @@ var express = require('express'),
|
||||||
app = express(),
|
app = express(),
|
||||||
server = require('http').createServer(app),
|
server = require('http').createServer(app),
|
||||||
io = require('socket.io').listen(server);
|
io = require('socket.io').listen(server);
|
||||||
|
var cookieParser = require('cookie-parser');
|
||||||
|
var bodyParser = require('body-parser');
|
||||||
|
var cookieSession = require('cookie-session');
|
||||||
var flash = require('connect-flash');
|
var flash = require('connect-flash');
|
||||||
var moment = require('moment');
|
|
||||||
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");
|
||||||
|
@ -86,8 +88,8 @@ flukso.on('done', function (num) {
|
||||||
io.sockets.emit('sdata', {data: simpleanswer});
|
io.sockets.emit('sdata', {data: simpleanswer});
|
||||||
});
|
});
|
||||||
|
|
||||||
io.configure(function () {
|
flukso.on('failed', function (error) {
|
||||||
io.set('log level', 0);
|
console.log("Flukso: " + error);
|
||||||
});
|
});
|
||||||
|
|
||||||
function work() {
|
function work() {
|
||||||
|
@ -102,19 +104,17 @@ 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); //TODO: wie kann man das schoener machen? (Modul in die Routes reintun)
|
||||||
app.set('views', __dirname + '/views');
|
|
||||||
|
app.use(express.static('public'));
|
||||||
|
app.use(cookieParser());
|
||||||
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
app.use(bodyParser.json({ extended: true }));
|
||||||
|
app.use(cookieSession({secret: 'steam-stalker', cookie: {maxAge: 60000}}));
|
||||||
|
app.use(flash());
|
||||||
|
|
||||||
|
app.set(__dirname + '/views');
|
||||||
app.set('view engine', 'jade');
|
app.set('view engine', 'jade');
|
||||||
app.disable('x-powered-by');
|
app.disable('x-powered-by');
|
||||||
app.configure('development', function () {
|
|
||||||
app.use(express.errorHandler());
|
|
||||||
app.locals.pretty = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
app.use(express.static(__dirname + '/public'));
|
|
||||||
app.use(express.bodyParser());
|
|
||||||
app.use(express.cookieParser('chaostreff'));
|
|
||||||
app.use(express.session({cookie: {maxAge: 60000}}));
|
|
||||||
app.use(flash());
|
|
||||||
app.enable('trust proxy');
|
app.enable('trust proxy');
|
||||||
|
|
||||||
app.get('/api/spaceapi/v13', function (req, res) {
|
app.get('/api/spaceapi/v13', function (req, res) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ block content
|
||||||
h2 Personen anwesend:
|
h2 Personen anwesend:
|
||||||
|
|
||||||
span(ng-repeat="name in simple.names")
|
span(ng-repeat="name in simple.names")
|
||||||
{{name}}
|
| {{name}}
|
||||||
|
|
||||||
span(ng-show=" ! $last ")
|
span(ng-show=" ! $last ")
|
||||||
| , <!-- -->
|
| , <!-- -->
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
!!!5
|
doctype html
|
||||||
html(ng-app="roomstateapp")
|
html(ng-app="roomstateapp")
|
||||||
head
|
head
|
||||||
title #{title} - CTDO Raumstatus
|
title #{title} - CTDO Raumstatus
|
||||||
|
|
Loading…
Reference in New Issue