Skip to content
Snippets Groups Projects
Commit eb0b56c4 authored by Martin Gels's avatar Martin Gels
Browse files

bug 1005: Updated get BGP stats.

parent 0102e2d5
No related branches found
No related tags found
No related merge requests found
#!/bin.rd/sh
#LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
PATH=$PATH:/usr/local/bin:/opt/lofar/bin:/cephome/gels/projects/LOFAR/RTCP/Run/src/
#export LD_LIBRARY_PATH PATH
getStats
exit 0
......@@ -205,6 +205,8 @@ if __name__ == '__main__':
os.remove(MSdatabaseFile)
except:
print 'caught exception'
import traceback
traceback.print_exc()
sys.exit(1)
obsID = 'L' + dateStr[0] + '_' + '%05d' % measurementnumber
......
......@@ -16,6 +16,8 @@ class Station(object):
def getPset(self, partition):
return IONodes.get(partition).index(self.ionode)
def getIONode(self):
return self.ionode
CS001_lba0 = [Station('CS001LBA_LBA0', '10.170.0.1', ['10.170.0.1:4346'])]
......
#!/usr/bin/env python
import os
import sys
import signal
import threading
import time
from Stations import *
from optparse import OptionParser
command = '"(' + os.getcwd() + '/BGPStats.sh)" 2>/dev/null'
killcommand = 'killall BGLStats 2> /dev/null'
killcommand2 = 'killall tcpdump 2> /dev/null'
def failed(ionode):
print
print ('No LOFAR data on IO node ' + ionode +'. Either the station data is not arriving, or')
print ('the Blue Gene/L partition is not active.')
class CommandThread(threading.Thread):
def __init__(self, commandstring, ionode):
threading.Thread.__init__(self)
self.commandstring = commandstring
self.ionode = ionode
def run(self):
# this may hang for a very long time
os.system(self.commandstring)
if __name__ == '__main__':
parser = OptionParser()
parser.add_option("--stationlist", default="CS001_lba0", action="store", type="string", dest="stationlist", help="Stations to check. Use either a station name (e.g. LBA) or 'all' for all CS1 stations.")
# parse the options
(options, args) = parser.parse_args()
# read the stations from Stations.py
# todo: WARNING this is very dangerous, because there could be any code in the station string
# the exec should probably be replaced by something safer, but this is only a temporary script
# This way is convenient because a user can say CS10_4dipoles + CS01_4dipoles
try:
exec('stationList =' + options.stationlist)
except:
print 'Cannot parse station configuration: ' + str(options.stationlist)
sys.exit(1)
threads = []
for ionode in stationList:
t = CommandThread('ssh ' + str(ionode.getIONode()) + ' ' + command, ionode.getIONode())
threads.append(t)
t.setDaemon(1)
t.start()
time.sleep(1)
for t in threads:
t.join(3)
if (t.isAlive()):
failed(t.ionode)
killstring = 'ssh ' + t.ionode + ' ' + killcommand
os.system(killstring)
killstring = 'ssh ' + t.ionode + ' ' + killcommand2
os.system(killstring)
else:
threads.remove(t)
signal.alarm(0)
sys.exit(0)
......@@ -3,7 +3,7 @@
# Do the first part in a shell script so the startup delay is
# less unpredictable
DATAFILE='/tmp/CURINPUT'
tcpdump -c 10 -i eth1 -X -s 62 -e -n 2> /dev/null > $DATAFILE
tcpdump -c 10 -i eth0 -X -s 62 -e -n 2> /dev/null > $DATAFILE
ifconfig | grep HW | awk '{print $1, $5;}' > $DATAFILE.MACS
ifconfig |grep inet\ addr|awk '{print $2;}'|cut -b 1-5 --complement > $DATAFILE.IPS
......@@ -11,6 +11,10 @@ python <<EOF
import sys
import time
from sets import Set
#index of board in the sourceMac
bordIndex = 4
class Packet(object):
"""
......@@ -34,8 +38,6 @@ class Packet(object):
lofarMacStart = '10:fa:00:'
#index of station in the sourceMac
stationIndex = 3
#index of board in the sourceMac
bordIndex = 5
#index of the formatstring in the EPAheader
formatIndex = 4
......@@ -67,7 +69,8 @@ class Packet(object):
srcMac, dstMac = self.getMacs()
if not srcMac.startswith(self.lofarMacStart):
return 'not a LOFAR station'
return 'CS' + str(int(srcMac.split(':')[self.stationIndex], 16)) + ' board ' + str(int(srcMac.split(':')[self.bordIndex], 16))
return 'CS' + str(int(srcMac.split(':')[self.stationIndex], 16)) + ' board ' + str(int(srcMac.split(':')[bordIndex], 16))
except IndexError:
return 'not a LOFAR station'
def getBeamletAndTimes(self):
......@@ -120,19 +123,29 @@ def parsefile(inputfile):
return packets
packets = parsefile('$DATAFILE')
# store all unique (by macs) packets and remember only the first one
streams = dict()
lBoardIds = set()
for packet in reversed(packets):
IDFound = 0
ml = packet.getMacs()
for id in lBoardIds:
if ml[0].split(':')[bordIndex] == id:
IDFound = 1
break
if not IDFound:
lBoardIds.add(ml[0].split(':')[bordIndex])
# if a newer one was already found, it is now forgotten
if not IDFound:
streams[ml] = packet
mymacs = open('$DATAFILE.MACS').readlines()
myips = open('$DATAFILE.IPS').readlines()
# analyze each packet for each data stream
print
print ('Found the following datastreams:')
# some methods for easier formatting
......@@ -144,7 +157,6 @@ def printokornot(text):
print (' ??? ' + text)
for (srcMac, dstMac), packet in streams.iteritems():
print
beamlets, times = packet.getBeamletAndTimes()
utcTime = packet.getUTC()
packetLength = packet.getLength()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment