Q: Updating bokeh plot with output of another script My goal is to create a bokeh script that shows the processor and memory usage of several machines in my network. The first script pulls the cpu and memory usage, and the bokeh script shows a time series plot of these stats over the last few seconds.
I have copy pasted some bokeh code (thanks internet) that updates two plots in a line based on random numbers every 500 seconds:
import numpy as np
from bokeh.plotting import figure, curdoc
from bokeh.driving import linear
from bokeh.layouts import layout
import random
tools = 'pan'

@linear()
def update(step):
    # Instead of random numbers, fetch stats from another script                                                      
    ds1.data['x'].append(step)
    ds1.data['y'].append(random.randint(0,100))
    ds2.data['x'].append(step)
    ds2.data['y'].append(random.randint(0,100))
    ds1.trigger('data', ds1.data, ds1.data)
    ds2.trigger('data', ds2.data, ds2.data)
# don't get this yet, but @linear is a decorator. Instead of having @linear(), we could also have                     
# update = linear(update)                                                                                             

p = figure(plot_width=400, plot_height=400)
r1 = p.line([], [], color="firebrick", line_width=2, legend='line1')
r2 = p.line([], [], color="navy", line_width=2, legend='line2')


ds1 = r1.data_source
ds2 = r2.data_source

curdoc().add_root(  p  )

# Add a periodic callback to be run every 500 milliseconds                                                            
curdoc().add_periodic_callback(update, 500)

Let's assume the first script pulls tuples of memory/cpu usage every 500 ms, how would I get the bokeh script to fetch that information? Once I have that information, I'll be set.
The only idea I have right now is to write the output of the first script to a dict/json/h5 file, and have the bokeh script read it and append that data to the plot. I'm wondering if there is a better way.

A: Since the update script is just grabbing some numbers, your best bet is probably wrapping that thing inside an update function, processing those numbers so they fit a ColumnDataSource, then update the main CDS, which will then update the plot. Something like:
def update():
    # Do stuff to get new data
    numbers = get_usage()

    # Process new data into a CDS friendly format
    data1, data2 = process_numbers(numbers)

    # Update plot_source, this being whatever source is 
    r1_source.data = data1
    r2_source.data = data2

curdoc().add_periodic_callback(update, 500)

