Skip to content

Commit

Permalink
monitor AI servers
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Mar 6, 2015
1 parent d483a29 commit c0506b0
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions bin/aimon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
var HttpClient = require('request');

var nginx = (function () {/*
server 216.218.250.236:9000 weight=8; # salim2
server 91.209.78.225:9000 weight=12; # hexal
# server 91.121.16.158:9009 weight=4; # matthews (openings)
# server 23.251.154.68:9009 weight=8; # nafis (expired)
server 91.121.7.111:9009 weight=2; # paul
# server 198.52.200.14:9009 weight=8; # drazak (expired)
server jaldus.ddns.net:9009 weight=8; # jaldus
server 91.121.223.148:9009 weight=4; # neary (ks3)
server yubaba.mindleaking.org:10080 weight=3; # sarken
server karmeliet.darklord.fr:9452 weight=3; # pat
*/}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1];

var servers = nginx.split(/\n/).map(function(line) {
return line.trim();
}).filter(function(line) {
return line.length && line[0] != '#';
}).map(function(line) {
return line.split(' ')[1];
});

function checks() {
servers.forEach(function(server) {
var url = 'http://' + server + '/ai/move';
HttpClient({
url: url,
timeout: 8000
}, function (error, response, body) {
if (error)
console.log('[ERROR] ' + error + ' ' + server);
else if (body.length != 4)
console.log('[ERROR] ' + body + ' ' + server);
else
process.stdout.write('.');
// console.log('[OK] ' + body + ' ' + server);
});
});
}

setInterval(checks, 10 * 60 * 1000);
checks();

0 comments on commit c0506b0

Please sign in to comment.