aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorffki-rz root user <root@freifunk.in-kiel.de>2014-09-29 23:55:14 +0200
committerffki-rz root user <root@freifunk.in-kiel.de>2014-09-29 23:55:14 +0200
commit6cf55b922b8067635b015e32c1b665f1a9034f41 (patch)
treef29d29b57a72047a7a3c0e5199c3651512a411a6
parent162b30f3a61958dbad4b4c4f9439b80082a33153 (diff)
Umbauten
-rw-r--r--.gitignore2
-rwxr-xr-xbat2nodes.py8
-rw-r--r--crontab13
-rwxr-xr-xget-nodes.pl4
-rwxr-xr-xmkmap.sh4
-rw-r--r--rrddb.py3
6 files changed, 18 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore
index 46b6ddc..2eec147 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
*.pyc
-aliases.json
nosuchnode.rrd
+json
nodedb
nodeplots
diff --git a/bat2nodes.py b/bat2nodes.py
index 1e55b3e..73329bc 100755
--- a/bat2nodes.py
+++ b/bat2nodes.py
@@ -63,24 +63,24 @@ if options['alfred']:
af = alfred()
db.import_aliases(af.aliases())
-db.load_state("state.json")
+db.load_state("json/state.json")
# remove nodes that have been offline for more than 30 days
db.prune_offline(time.time() - 30*86400)
-db.dump_state("state.json")
+db.dump_state("json/state.json")
scriptdir = os.path.dirname(os.path.realpath(__file__))
m = D3MapBuilder(db)
#Write nodes json
-nodes_json = open(options['destination_directory'] + '/nodes.json.new','w')
+nodes_json = open(options['destination_directory'] + '/json/nodes.json.new','w')
nodes_json.write(m.build())
nodes_json.close()
#Move to destination
-os.rename(options['destination_directory'] + '/nodes.json.new',options['destination_directory'] + '/nodes.json')
+os.rename(options['destination_directory'] + '/json/nodes.json.new',options['destination_directory'] + '/json/nodes.json')
rrd = rrd(scriptdir + "/nodedb/", options['destination_directory'] + "/nodes")
rrd.update_database(db)
diff --git a/crontab b/crontab
index c65e08f..33be193 100644
--- a/crontab
+++ b/crontab
@@ -1,15 +1,16 @@
+MAILTO=ffki-noc@in-kiel.de
+
# Freifunk Map Updates
-PATH=/opt/alfred/vis:/opt/alfred-json:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+PATH=/opt/alfred/vis:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-* * * * * root (DEBUG=1 /opt/ffmap/get-nodes.pl && /usr/local/sbin/fastd-update > /dev/null ) ; /opt/ffmap/mkmap.sh /var/www/ffmap/
+* * * * * root (DEBUG=1 /opt/ffmap-backend/get-nodes.pl && /usr/local/sbin/fastd-update > /dev/null ) ; /opt/ffmap-backend/mkmap.sh /opt/ffmap-backend/
+* * * * * root (DEBUG=1 /usr/local/sbin/fastd-update > /dev/null ) ; /opt/ffmap-backend/mkmap.sh /opt/ffmap-backend/
* * * * * root /usr/local/bin/check-gateway
-*/5 * * * * root /usr/local/bin/update-vnstat.sh
-
-0 0 * * * root find /opt/ffmap/nodedb/ -name '*.rrd' -ctime 8 -execdir rm '{}' +
-0 1 * * * root find /opt/ffmap/nodeplots/ -name '*.png' -ctime 1 -execdir rm '{}' +
+0 0 * * * root find /opt/ffmap-backend/nodedb/ -name '*.rrd' -ctime 8 -execdir rm '{}' +
+0 1 * * * root find /opt/ffmap-backend/nodeplots/ -name '*.png' -ctime 1 -execdir rm '{}' +
# EOF
diff --git a/get-nodes.pl b/get-nodes.pl
index 0e8f2ed..baf43cd 100755
--- a/get-nodes.pl
+++ b/get-nodes.pl
@@ -107,10 +107,10 @@ $mw->list (
}
) || die $mw->{error}->{code} . ': ' . $mw->{error}->{details};
-open(my $f,">","/opt/ffmap/aliases.json.new");
+open(my $f,">","/opt/ffmap-backend/json/aliases.json.new");
print $f encode_json($nodes);
close($f);
-rename "/opt/ffmap/aliases.json.new", "/opt/ffmap/aliases.json";
+rename "/opt/ffmap-backend/json/aliases.json.new", "/opt/ffmap-backend/json/aliases.json";
__END__
diff --git a/mkmap.sh b/mkmap.sh
index 22e0019..3613a87 100755
--- a/mkmap.sh
+++ b/mkmap.sh
@@ -2,11 +2,11 @@
DEST="$1"
-[ "$DEST" ] || exit 1
+[ -d "$DEST" ] || exit 1
cd "$(dirname "$0")"/
#./ffhlwiki.py http://freifunk.metameute.de/wiki/Knoten > aliases_hl.json
#./ffhlwiki.py http://freifunk.metameute.de/wiki/Moelln:Knoten > aliases_moelln.json
-./bat2nodes.py -A -a aliases.json -d $DEST
+./bat2nodes.py -A -a json/aliases.json -d $DEST
diff --git a/rrddb.py b/rrddb.py
index 6f48913..36e4682 100644
--- a/rrddb.py
+++ b/rrddb.py
@@ -30,7 +30,8 @@ class rrd:
nodes = db.get_nodes()
clientCount = sum(map(lambda d: d.clientcount, nodes))
- self.globalDb.update(len(nodes), clientCount)
+ curtime = time.time() - 60
+ self.globalDb.update(len(list(filter(lambda x: x.lastseen >= curtime, nodes))), clientCount)
for node in nodes:
rrd = NodeRRD(
os.path.join(self.dbPath, str(node.id).replace(':', '') + '.rrd'),