In [1]:
import math
import pandas as pd
import BQhelper as bq
import matplotlib.pyplot as plt
bq.project = "mlab-sandbox"
# bq.dataset = 'mattmathis'
# bq.UnitTestRunQuery()
# bq.UnitTestWriteQuery()
In [2]:
query="""
SELECT
a.TestTime,
client.IP,
a.MeanThroughputMbps,
node._instruments
# FROM `mlab-sandbox.mm_unified_testing.unified_downloads`
FROM `measurement-lab.ndt.unified_downloads`
WHERE client.IP in ( {clientIP} )
AND test_date > '2019-03-01'
ORDER BY TestTime
"""
In [7]:
%matplotlib nbagg
# from matplotlib import interactive
# interactive(True)
plt.ion()
clients = [
'69.68.23.44', # Max deltaMean
'96.229.66.58' # Max deltaMax
]
def plotMultiBeacons(clients, columns = 1, width=10):
clist = '"'+'", "'.join(clients)+'"'
data=bq.QueryTimestampTimeseries(query, clientIP=clist)
rows = math.ceil(len(clients) / float(columns))
figLen = math.ceil(width/float(columns)*rows) # assume square
plt.rcParams['figure.figsize'] = [width, figLen]
for i, client in enumerate(clients):
cdata = data[data['IP'] == client]
cur = plt.subplot(rows, columns, i+1)
plt.title('Beacon: '+client)
plt.plot(cdata['MeanThroughputMbps'], 'b.')
plt.show()
# plotMultiBeacons(clients, 2, width=10)
In [9]:
# Timerseries from top 10 at mlab-sandbox.mattmathis.mlab3_ddos
beacons = [
'96.245.122.246',
'71.186.165.126',
'69.6.160.214',
'75.144.168.137',
'69.145.80.74',
'199.167.185.49',
'208.83.208.124',
'52.20.240.27',
'75.98.98.34',
'100.21.131.186',
]
plotMultiBeacons(beacons, 2, width=10)
In [5]:
clist = '"'+'", "'.join(clients)+'"'
data=bq.QueryTimestampTimeseries(query, clientIP=clist)
In [6]:
print (data)
data.count(axis=1)
Out[6]: