diff options
author | makefu <github@syntax-fehler.de> | 2011-11-07 18:18:03 +0100 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2011-11-07 18:18:03 +0100 |
commit | cbf6455e58624dc3394b8506481e4b6e5ee58094 (patch) | |
tree | ecd43fb47357fb6bf1ee2dabccbf74850ead3079 | |
parent | 1d7d5f8eafb7197387c57e1a85f704de04f00c5b (diff) | |
parent | 207a4ec405d3229a9d2e200b7803c3068d513265 (diff) |
Merge branch 'master' of github.com:krebscode/painload
-rw-r--r-- | census/Makefile | 3 | ||||
-rwxr-xr-x | census/arping.py | 3 | ||||
-rwxr-xr-x | census/arping_users.py | 27 | ||||
-rwxr-xr-x | census/sched-arping | 8 | ||||
-rw-r--r-- | streams/stream.db | 1 |
5 files changed, 34 insertions, 8 deletions
diff --git a/census/Makefile b/census/Makefile index 2c6c1c03..9993bf2a 100644 --- a/census/Makefile +++ b/census/Makefile @@ -1,6 +1,5 @@ .phony: all all: arping.py arping_users.py - echo "call python ./arping_users.py v" install: - apt-get install python-scapy + ./sched-arping diff --git a/census/arping.py b/census/arping.py index 3cffa6be..ed257441 100755 --- a/census/arping.py +++ b/census/arping.py @@ -11,11 +11,10 @@ try: from scapy.all import * #might throws "no such module" def arpingy(iprange="10.42.1.0/24",iface='eth0'): - log.debug("pinging "+ str(iprange)) """Arping function takes IP Address or Network, returns nested mac/ip list""" try: conf.verb=0 - ans,unans=arping(iprange,iface=iface,timeout=0.4,retry=1) + ans,unans=arping(iprange,iface=iface,timeout=3,retry=1) collection = [] for snd, rcv in ans: diff --git a/census/arping_users.py b/census/arping_users.py index f4f356bf..eb47f308 100755 --- a/census/arping_users.py +++ b/census/arping_users.py @@ -1,11 +1,11 @@ #!/usr/bin/python import subprocess,re,logging,sys - +import json from arping import arpingy from multiprocessing import Pool -logging.basicConfig(level=logging.DEBUG) +logging.basicConfig(level=logging.WARNING) log = logging.getLogger("main") -DEV='eth0' +DEV='eth1' MAC_NAMES='mac_names.lst' data = [] my_addr = False @@ -29,12 +29,14 @@ def load_names(mac_file): names[mac] = name.replace('\n','') f.close() return names + def print_config(): log.info("My Addr : %s" %str(my_addr)) log.info("MAC Names file: %s " %MAC_NAMES) log.debug("Loaded names : ") for mac,name in my_names.iteritems(): log.debug("%s => %s" %(mac,name)) + def init(): my_addr = get_own_addr() my_names = load_names(MAC_NAMES) @@ -52,22 +54,39 @@ def main(): data.append({'iprange':'10.42.'+str(first)+'.'+str(second),'iface':DEV}) try: log.info("creating new Pool") - p = Pool(30) + p = Pool(35) ret = filter(lambda x:x , p.map(arping_helper, data)) log.info("killing it") p.terminate() except Exception as e: print 'you fail '+str(e) + sys.exit(1) myip,mymac = get_own_addr() ret.append([mymac,myip]) + print_json(ret) + #print_names(ret) + +def print_names(ret): for p in ret: if not quiet: print p[0] + " => " + p[1] if p[1] in names: print names[p[1]]+ " is online" +def print_json(ret): + from time import time + output = {} + output["timestamp"] = time() + for i in ret: + mac = i[0] + ip = i[1] + if i[0] not in output: + output[mac] = [] + output[mac].append(ip) + print json.dumps(output) + if __name__ == "__main__": log.debug("starting arping_users") main() diff --git a/census/sched-arping b/census/sched-arping new file mode 100755 index 00000000..d281cac3 --- /dev/null +++ b/census/sched-arping @@ -0,0 +1,8 @@ +#!/bin/sh + +TMP=`mktemp` +crontab -l >$TMP + +echo "23 * * * * $PWD/arping_users.py > $PWD/../db/arping" | +../util/bin/magic "arping" create $TMP +crontab $TMP diff --git a/streams/stream.db b/streams/stream.db index 1d7bb15e..263e95b4 100644 --- a/streams/stream.db +++ b/streams/stream.db @@ -4,6 +4,7 @@ http://streams.xenim.de/radiotux.ogg radiotux http://bassdrive.com/v2/streams/BassDrive.pls bassdrive http://somafm.com/illstreet.pls illstreet http://localhost:8000/stream.ogg icecast +http://localhost:8000/shice.ogg shice http://stream2.jungletrain.net:8000 jungletrain http://playlist.tormentedradio.com/tormentedradio.pls tormented http://filebitch.shack:8000 mpd |