Porting loganalyser tools to pandas + jupyter notebooks


In [12]:
%matplotlib inline
from loganalyser import vmstat, plot

LINUX_VMSTAT


In [13]:
cpu = vmstat.parse('data/supercars-oscounters-13102912.tgz', './vmstat.txt.13102912', 'Europe/Berlin')
cpu.head() # note timestamps are in UTC! (workaround for to_json)


Out[13]:
idle system user wait timestamp
0 89 2 3 6 2013-10-29 11:45:00
1 99 1 0 0 2013-10-29 11:45:05
2 99 0 0 1 2013-10-29 11:45:10
3 100 0 0 0 2013-10-29 11:45:15
4 100 0 0 0 2013-10-29 11:45:20

In [14]:
# find out boundaries to select a timeframe -> use ms since epoch
# in a next version boundaries are provided by ipython widgets!
import datetime
from pytz import timezone
print cpu.ix[100]
# proper way with tz http://www.saltycrane.com/blog/2009/05/converting-time-zones-datetime-objects-python/
ts = timezone('Europe/Berlin').localize(datetime.datetime.strptime('2013-10-29 12:53:20', '%Y-%m-%d %H:%M:%S'))
print int(ts.strftime("%s")) * 1000


idle                          99
system                         0
user                           1
wait                           0
timestamp    2013-10-29 11:53:20
Name: 100, dtype: object
1383047600000

In [15]:
plot.set_styles(['stacked',])


Out[15]:

In [16]:
plot = reload(plot)
plot.draw_graph('stacked', cpu.to_json(orient='records'),
                {'start': 1383047600000, 'end': 1383048600000, 'yaxis': "CPU utilization [%]"})


Out[16]:

In [ ]: