Commit 84e76893 authored by fionera's avatar fionera

Updated ALL

parent 8d9133c6
var util = require('util');
var EventEmitter = require('events').EventEmitter;
var http = require("http");
var request = require('request');
var Flukso = function(hostname, pathname) {
var self = this;
var regexp = /([0-9]+)\]\]$/; // /\(([0-9]+) hosts* up\)/;
this.pollPower = function() {
http.request({ host: hostname, path: pathname }, function(response) {
var str = '';
response.on('data', function(chunk) {
str += chunk;
});
response.on('end', function () {
var matches = regexp.exec(str);
if(matches != null && matches.length == 2) {
request({url: "http://" + hostname + pathname}, function(error, res, response) {
if (error) {
self.emit('failed', error)
} else {
var matches = regexp.exec(response);
if(matches != null && matches.length == 2) {
var time = Date.now();
var num = matches[1];
self.emit('done', parseInt(num));
}
});
}).end();
}
});
};
};
......
......@@ -2,6 +2,8 @@ var redis = require("redis");
var util = require('util');
var EventEmitter = require('events').EventEmitter;
var exec = require('child_process').exec;
var moment = require('moment');
var redisprefix = "ippoll:";
......
{
"name": "statusbot",
"description": "ctdo status bot",
"version": "0.0.2",
"private": true,
"dependencies": {
"express": "^3.4",
"connect-flash": "^0.1.1",
"net-snmp": "^1.1.8",
"redis": "^0.8.5",
"underscore": "^1.5.2",
"jade": "^0.35",
"socket.io": "^0.9.16",
"moment": "^2.3.1"
},
"main": "statusbot"
"name": "statusbot",
"description": "ctdo status bot",
"version": "0.0.1",
"private": true,
"dependencies": {
"body-parser": "1.14.2",
"connect-flash": "0.1.1",
"cookie-parser": "1.4.0",
"cookie-session": "2.0.0-alpha.1",
"events": "1.1.0",
"express": "4.13.3",
"jade": "1.11.0",
"moment": "2.11.0",
"net-snmp": "1.1.14",
"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(),
server = require('http').createServer(app),
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 moment = require('moment');
var SnmpMac = require("./snmp-mac");
var IpPoll = require("./ip-poll");
var Flukso = require("./flukso");
......@@ -86,8 +88,8 @@ flukso.on('done', function (num) {
io.sockets.emit('sdata', {data: simpleanswer});
});
io.configure(function () {
io.set('log level', 0);
flukso.on('failed', function (error) {
console.log("Flukso: " + error);
});
function work() {
......@@ -102,19 +104,17 @@ setInterval(flukso.pollPower, 5000);
flukso.pollPower();
app.set('snmpMac', snmpMac); //TODO: wie kann man das schoener machen? (Modul in die Routes reintun)
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
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(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.disable('x-powered-by');
app.enable('trust proxy');
app.get('/api/spaceapi/v13', function (req, res) {
......
......@@ -39,7 +39,7 @@ block content
h2 Personen anwesend:
span(ng-repeat="name in simple.names")
{{name}}
| {{name}}
span(ng-show=" ! $last ")
| , <!-- -->
......
!!!5
doctype html
html(ng-app="roomstateapp")
head
title #{title} - CTDO Raumstatus
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment