Exemplo n.º 1
0
    def output(self, months=3):
        """Render out the image of the rrd"""
        def1 = DEF(rrdfile=self.datafile, vname='queue', dsName=self.ds1.name)
        line1 = LINE(defObj=def1,
                     color='#01FF13',
                     legend='Queue Depth',
                     stack=True)
        # area1 = AREA(defObj=def1, color='#FFA902', legend='Bookmarks')

        # Let's configure some custom colors for the graph
        ca = ColorAttributes()
        ca.back = '#333333'
        ca.canvas = '#333333'
        ca.shadea = '#000000'
        ca.shadeb = '#111111'
        ca.mgrid = '#CCCCCC'
        ca.axis = '#FFFFFF'
        ca.frame = '#AAAAAA'
        ca.font = '#FFFFFF'
        ca.arrow = '#FFFFFF'

        # Now that we've got everything set up, let's make a graph
        start_date = time.mktime((today - timedelta(days=7)).timetuple())
        end_date = time.mktime(today.timetuple())
        g = Graph(self.outputfile,
                  start=int(start_date),
                  end=int(end_date),
                  vertical_label='count',
                  color=ca)
        g.data.extend([def1, line1])

        if not os.path.exists(os.path.dirname(self.outputfile)):
            os.makedirs(os.path.dirname(self.outputfile))

        g.write()
Exemplo n.º 2
0
 def graph_request(self, period='day'):
     def1 = DEF(rrdfile=self.rrdfile, vname='request', dsName="requests", cdef="AVERAGE")
     
     vdef1 = VDEF(vname='max', rpn='request,MAXIMUM')
     vdef2 = VDEF(vname='avg', rpn='request,AVERAGE')
     vdef3 = VDEF(vname='last', rpn='request,LAST')
     
     area1 = AREA(defObj=def1, color='#336600', legend='Requests')
     gprint1 = GPRINT(vdef1, "Max\\: %5.1lf %S")
     gprint2 = GPRINT(vdef2, "Avg\\: %5.1lf %S")
     gprint3 = GPRINT(vdef3, "Current\\: %5.1lf %Sreq/sec")
     
     ca = ColorAttributes()
     ca.back = '#333333'
     ca.canvas = '#333333'
     ca.shadea = '#000000'
     ca.shadeb = '#111111'
     ca.mgrid = '#CCCCCC'
     ca.axis = '#FFFFFF'
     ca.frame = '#AAAAAA'
     ca.font = '#FFFFFF'
     ca.arrow = '#FFFFFF'
     
     img = "request-%s.png" % period
     imgname = self.static_path +"/"+ img
     start = '-1'+period
     
     g = Graph(imgname, imgformat='PNG', step=start, vertical_label='request/sec', color=ca, width=700, height=150)
     g.data.extend([def1, vdef1, vdef2, vdef3, area1, gprint1, gprint2, gprint3])
     g.write()
Exemplo n.º 3
0
def render(stringName, key, startTime, endTime):
        if debug: print "Enter Function render(filename, value)"
	
        #balken zeichnen
        def1 = DEF(rrdfile = baseDir + stringName + "_" + key + ".rrd", vname='kW', dsName="kW")  #command fetches data from the rrd
	area1 = AREA(defObj=def1, color='#FFA902', legend='kW')
        
        #mittelwert linie zeichnen (muss noch berechnet werden
        line1 = LINE(value=100, color='#990000', legend='Average')

	# Let's configure some custom colors for the graph
	ca = ColorAttributes()
	ca.back = '#333333'
	ca.canvas = '#333333'
	ca.shadea = '#000000'
	ca.shadeb = '#111111'
	ca.mgrid = '#CCCCCC'
	ca.axis = '#FFFFFF'
	ca.frame = '#AAAAAA'
	ca.font = '#FFFFFF'
	ca.arrow = '#FFFFFF'

	# Now that we've got everything set up, let's make a graph
	#startTime = endTime - (10 * 60 * 60) #10h anzeigen, sollte noch variabel sein
	g = Graph(baseDir + stringName + "_" + key + ".png", start=startTime, end=endTime, vertical_label='data', color=ca)
	g.data.extend([def1, area1, line1])

	g.width = 800
	g.height = 400
	g.write()
Exemplo n.º 4
0
    def __init__(self, devices, plugin, data_source,
                 time_from=time()-60*60, time_to=time(),
                 width=settings.GRAPH_WIDTH, height=settings.GRAPH_HEIGHT,
                 mode=AGGREGATED, comment="", add_comment=True):
        """
        Constructor.
        Needed parameters: list of devices, plugin name, data source name
        Optional parameters: time_from and time_to (default before 1 hour till now),
        width and height of graph in pixel, mode aggregated or multi-line, comment

        To set multi-line graph use mode=rrdscout.MULTI_LINE
        """
        self.devices = devices
        self.plugin = plugin
        self.data_source = data_source
        self.time_from = time_from
        self.time_to = time_to
        self.width = width
        self.height = height
        self.mode = mode
        self.title = ""
        self.y_label = ""
        self.attachment_name = ""
        self.comment = comment
        self.add_comment = add_comment
        self.out_file = tempfile.NamedTemporaryFile('rw', suffix='.%s' % settings.GRAPH_FORMAT, dir=settings.TEMP_DIR, delete=True)

        self._defs = []
        self._cdefs = []
        self._def_map = {}
        self._cdef_map = {}
        self._cdef_values = {}
        self._metadata = {}
        self._lines = []
        self._areas = {}
        self._vdefs = []
        self._gprints = []
        self._got_errors = False
        self._cf_map = {'min': 'MINIMUM',
                       'max': 'MAXIMUM',
                       'average': 'AVERAGE'}

        graph_color = ColorAttributes()
        graph_color.back = settings.COLOR_BACK
        graph_color.canvas = settings.COLOR_CANVAS
        graph_color.font = settings.COLOR_FONT
        graph_color.shadea = settings.COLOR_SHADEA
        graph_color.shadeb = settings.COLOR_SHADEB
        graph_color.mgrid = settings.COLOR_MGRID
        graph_color.axis = settings.COLOR_AXIS
        graph_color.arrow = settings.COLOR_ARROW

        self.graph = PyrrdGraph(self.out_file.name,
                                start=self.time_from,
                                end=self.time_to,
                                width=self.width,
                                height=self.height,
                                color=graph_color)
Exemplo n.º 5
0
    def __init__(self, devices, plugin, data_source,
                 time_from=time()-60*60, time_to=time(),
                 width=settings.GRAPH_WIDTH, height=settings.GRAPH_HEIGHT,
                 mode=AGGREGATED, comment="", add_comment=True):
        """
        Constructor.
        Needed parameters: list of devices, plugin name, data source name
        Optional parameters: time_from and time_to (default before 1 hour till now),
        width and height of graph in pixel, mode aggregated or multi-line, comment

        To set multi-line graph use mode=rrdscout.MULTI_LINE
        """
        self.devices = devices
        self.plugin = plugin
        self.data_source = data_source
        self.time_from = time_from
        self.time_to = time_to
        self.width = width
        self.height = height
        self.mode = mode
        self.title = ""
        self.y_label = ""
        self.attachment_name = ""
        self.comment = comment
        self.add_comment = add_comment
        self.out_file = tempfile.NamedTemporaryFile('rw', suffix='.png', dir=settings.TEMP_DIR, delete=True)

        self._defs = []
        self._cdefs = []
        self._def_map = {}
        self._cdef_map = {}
        self._cdef_values = {}
        self._metadata = {}
        self._lines = []
        self._areas = {}
        self._vdefs = []
        self._gprints = []
        self._got_errors = False
        self._cf_map = {'min': 'MINIMUM',
                       'max': 'MAXIMUM',
                       'average': 'AVERAGE'}

        graph_color = ColorAttributes()
        graph_color.back = '#ffffff'
        graph_color.shadea = '#ffffff'
        graph_color.shadeb = '#ffffff'

        self.graph = PyrrdGraph(self.out_file.name,
                                start=self.time_from,
                                end=self.time_to,
                                width=self.width,
                                height=self.height,
                                color=graph_color)
Exemplo n.º 6
0
def color_style():
    ca = ColorAttributes()
    ca.back = '#333333'
    ca.canvas = '#333333'
    ca.shadea = '#000000'
    ca.shadeb = '#111111'
    ca.mgrid = '#CCCCCC'
    ca.axis = '#FFFFFF'
    ca.frame = '#AAAAAA'
    ca.font = '#FFFFFF'
    ca.arrow = '#FFFFFF'
    return ca
Exemplo n.º 7
0
def color():
    ca = ColorAttributes()
    ca.back = "#CCCDE2"  # background
    ca.canvas = "#FFFFFF"  # the background of the actual graph
    ca.shadea = "#000000"  # left and top border
    ca.shadeb = "#111111"  # right and bottom border
    ca.mgrid = "#6666CC"  # maior grid
    ca.axis = "#000000"  # axis of the graph
    ca.frame = "#CCCDE2"  # line around the color spots
    ca.font = "#000000"  # color of the font
    ca.arrow = "#CC0000"  # arrow head pointing up and forward
    return ca
Exemplo n.º 8
0
    def output(self, months=3):
        """Render out the image of the rrd"""
        def1 = DEF(rrdfile=self.datafile,
            vname='bookmark_count',
            dsName=self.ds1.name)
        def2 = DEF(rrdfile=self.datafile,
            vname='unique_count',
            dsName=self.ds2.name)
        def3 = DEF(rrdfile=self.datafile,
            vname='tag_count',
            dsName=self.ds3.name)
        line1 = LINE(defObj=def1,
            color='#01FF13',
            legend='Bookmarks',
            stack=True)
        line2 = LINE(defObj=def2,
            color='#DA7202',
            legend='Unique',
            stack=True)
        line3 = LINE(defObj=def3, color='#BD4902', legend='Tags', stack=True)

        # area1 = AREA(defObj=def1, color='#FFA902', legend='Bookmarks')
        # area2 = AREA(defObj=def2, color='#DA7202', legend='Unique')
        # area3 = AREA(defObj=def3, color='#BD4902', legend='Tags')

        # Let's configure some custom colors for the graph
        ca = ColorAttributes()
        ca.back = '#333333'
        ca.canvas = '#333333'
        ca.shadea = '#000000'
        ca.shadeb = '#111111'
        ca.mgrid = '#CCCCCC'
        ca.axis = '#FFFFFF'
        ca.frame = '#AAAAAA'
        ca.font = '#FFFFFF'
        ca.arrow = '#FFFFFF'

        # Now that we've got everything set up, let's make a graph
        start_date = time.mktime((today - timedelta(weeks=28)).timetuple())
        end_date = time.mktime(today.timetuple())
        g = Graph(self.outputfile,
            start=int(start_date),
            end=int(end_date),
            vertical_label='count',
            color=ca)
        g.data.extend([def1, def2, def3, line3, line2, line1])

        if not os.path.exists(os.path.dirname(self.outputfile)):
            os.makedirs(os.path.dirname(self.outputfile))

        g.write()
Exemplo n.º 9
0
def rrd_stuff():
        
    filename = 'test.rrd'
    
    #dataSource = from_file()
    
    
    #def1 = DEF(rrdfile=filename, vname='myspeed',
    #          dsName=dataSource.name)
    def1 = DEF(rrdfile=filename, vname='myspeed',
              dsName='speed')
    
    cdef1 = CDEF(vname='kmh', rpn='%s,3600,*' % def1.vname)
    cdef2 = CDEF(vname='fast', rpn='kmh,100,GT,kmh,0,IF')
    cdef3 = CDEF(vname='good', rpn='kmh,100,GT,0,kmh,IF')
    vdef1 = VDEF(vname='mymax', rpn='%s,MAXIMUM' % def1.vname)
    vdef2 = VDEF(vname='myavg', rpn='%s,AVERAGE' % def1.vname)
    
    line1 = LINE(value=100, color='#990000', legend='Maximum Allowed')
    area1 = AREA(defObj=cdef3, color='#006600', legend='Good Speed')
    area2 = AREA(defObj=cdef2, color='#CC6633', legend='Too Fast')
    line2 = LINE(defObj=vdef2, color='#000099', legend='My Average',
                 stack=True)
    gprint1 = GPRINT(vdef2, '%6.2lf kph')
    
    
    from pyrrd.graph import ColorAttributes
    ca = ColorAttributes()
    ca.back = '#333333'
    ca.canvas = '#333333'
    ca.shadea = '#000000'
    ca.shadeb = '#111111'
    ca.mgrid = '#CCCCCC'
    ca.axis = '#FFFFFF'
    ca.frame = '#AAAAAA'
    ca.font = '#FFFFFF'
    ca.arrow = '#FFFFFF'
    
    from pyrrd.graph import Graph
    graphfile = "rrdgraph.png"
    g = Graph(graphfile, start=920805000, end=920810000,
             vertical_label='km/h', color=ca)
    g.data.extend([def1, cdef1, cdef2, cdef3, vdef1, vdef2, line1, area1,
                   area2, line2, gprint1])
    g.write()
Exemplo n.º 10
0
  def _render(self, params):
    ca = ColorAttributes()
    ca.back = '#333333'
    ca.canvas = '#333333'
    ca.shadea = '#000000'
    ca.shadeb = '#111111'
    ca.mgrid = '#CCCCCC'
    ca.axis = '#FFFFFF'
    ca.frame = '#AAAAAA'
    ca.font = '#FFFFFF'
    ca.arrow = '#FFFFFF'

    currentTime = int(time.time())

    start = currentTime - getIntOrElse(params, "start", (3 * hour))
    end = currentTime - getIntOrElse(params, "end", 0)
    logarithmic = getBooleanOrElse(params, "logarithmic", False)
    step = getIntOrElse(params, "step", 60)
    width = getIntOrElse(params, "width", 800)
    height = getIntOrElse(params, "height", 400)
    graphs = getStringOrElse(params, "graphs", getAllZaehlerNames())

    upperlimit = getIntOrElse(params, "upperlimit", None)
    lowerlimit = getIntOrElse(params, "lowerlimit", None)

    generated_file = "/tmp/%d-%d.png" % (time.time(),random.randint(0, 100000))

    g = Graph(generated_file, start=start, end=end, vertical_label='100mWh/min', color=ca)
    g.data.extend(self._createLines(graphs))
    g.width = width
    g.height = height
    g.step = step
    g.logarithmic = logarithmic

    if upperlimit:
      g.upper_limit=upperlimit
    if lowerlimit:
      g.lower_limit=lowerlimit

    g.rigid=True
    g.write()

    return generated_file
Exemplo n.º 11
0
    def _initialize(self):
        """ set up erything we need """

        # Let's configure some custom colors for the graph
        ca = ColorAttributes()
        ca.back = '#333333'
        ca.canvas = '#333333'
        ca.shadea = '#000000'
        ca.shadeb = '#111111'
        ca.mgrid = '#CCCCCC'
        ca.axis = '#FFFFFF'
        ca.frame = '#AAAAAA'
        ca.font = '#FFFFFF'
        ca.arrow = '#FFFFFF'

        # Let's set up the objects that will be added to the graphs
        result = []
        for graphName, graphData in graphsDefinition.items():
            tmp = []
            for sourceName, sourceData in graphData["sources"].items():
                def1 = DEF(rrdfile=self._filename, vname=sourceName, dsName=sourceName)
                tmp.append(def1)
                if sourceName.startswith("zaehlerstand"):
                  cdef1 = CDEF(vname='verbrauchpros-'+def1.vname, rpn='%s,86400,*' % def1.vname)
                  tmp.append(cdef1) 
                if sourceData["type"] == "line":
                    tmp.append(LINE(value=sourceName, color=sourceData["color"], legend=sourceData["title"]))
                elif sourceData["type"] == "area":
                    tmp.append(AREA(value=sourceName, color=sourceData["color"], legend=sourceData["title"]))
                
            # Now that we've got everything set up, let's make a graph
            g = Graph('dummy.png', vertical_label=graphData["verticalLabel"], color=ca)
            g.data.extend(tmp)
            g.title = '"%s"' % graphData["title"]
            # create a new variable
            g.filenameBase = graphName
            if graphData.get("logarithmic"):
              g.logarithmic=True  
            result.append(g)
        return result
        device_def.append(DEF(rrdfile=rrdfile[i], vname=dsName[i] + "_data", dsName=dsName[i], cdef="LAST"))
        device_line.append(LINE(defObj=device_def[i], color=colors[i], legend=sensor_name[i] + " Temperature"))
        device_aver.append(VDEF(vname=dsName[i] + "_aver", rpn="%s,AVERAGE" % device_def[i].vname))
        device_val.append(GPRINT(device_aver[i], "Average " + sensor_name[i] + " Temperature: %6.2lf Degrees F"))

    # Graph Comment

    cmt = COMMENT(comment)

    # Define Graph Colors
    #    black background:
    black_bkgnd = ColorAttributes()
    black_bkgnd.back = "#000000"
    black_bkgnd.canvas = "#333333"
    black_bkgnd.shadea = "#000000"
    black_bkgnd.shadeb = "#111111"
    black_bkgnd.mgrid = "#CCCCCC"
    black_bkgnd.axis = "#FFFFFF"
    black_bkgnd.frame = "#0000AA"
    black_bkgnd.font = "#FFFFFF"
    black_bkgnd.arrow = "#FFFFFF"

    #    white background:
    white_bkgnd = ColorAttributes()
    white_bkgnd.back = "#FFFFFF"
    white_bkgnd.canvas = "#EEEEEE"
    white_bkgnd.shadea = "#000000"
    white_bkgnd.shadeb = "#111111"
    white_bkgnd.mgrid = "#444444"
    white_bkgnd.axis = "#000000"
    white_bkgnd.frame = "#0000AA"
Exemplo n.º 13
0
def2 = DEF(rrdfile=myRRD.filename, vname='mysilliness', dsName=ds2.name)
def3 = DEF(rrdfile=myRRD.filename, vname='myinsanity', dsName=ds3.name)
def4 = DEF(rrdfile=myRRD.filename, vname='mydementia', dsName=ds4.name)
vdef1 = VDEF(vname='myavg', rpn='%s,AVERAGE' % def1.vname)
area1 = AREA(defObj=def1, color='#FFA902', legend='Raw Data 4')
area2 = AREA(defObj=def2, color='#DA7202', legend='Raw Data 3')
area3 = AREA(defObj=def3, color='#BD4902', legend='Raw Data 2')
area4 = AREA(defObj=def4, color='#A32001', legend='Raw Data 1')
line1 = LINE(defObj=vdef1, color='#01FF13', legend='Average', stack=True)

# Let's configure some custom colors for the graph
ca = ColorAttributes()
ca.back = '#333333'
ca.canvas = '#333333'
ca.shadea = '#000000'
ca.shadeb = '#111111'
ca.mgrid = '#CCCCCC'
ca.axis = '#FFFFFF'
ca.frame = '#AAAAAA'
ca.font = '#FFFFFF'
ca.arrow = '#FFFFFF'

# Now that we've got everything set up, let's make a graph
startTime = endTime - 3 * month
g = Graph(graphfile,
          start=startTime,
          end=endTime,
          vertical_label='data',
          color=ca)
g.data.extend([def1, def2, def3, def4, vdef1, area4, area3, area2, area1])
g.write()
Exemplo n.º 14
0
# Let's set up the objects that will be added to the graph
def1 = DEF(rrdfile=myRRD.filename, vname="in", dsName=ds1.name)
def2 = DEF(rrdfile=myRRD.filename, vname="out", dsName=ds2.name)
# Here we're just going to mulitply the in bits by 100, solely for
# the purpose of display
cdef1 = CDEF(vname="hundredin", rpn="%s,%s,*" % (def1.vname, 100))
cdef2 = CDEF(vname="negout", rpn="%s,-1,*" % def2.vname)
area1 = AREA(defObj=cdef1, color="#FFA902", legend="Bits In")
area2 = AREA(defObj=cdef2, color="#A32001", legend="Bits Out")

# Let's configure some custom colors for the graph
ca = ColorAttributes()
ca.back = "#333333"
ca.canvas = "#333333"
ca.shadea = "#000000"
ca.shadeb = "#111111"
ca.mgrid = "#CCCCCC"
ca.axis = "#FFFFFF"
ca.frame = "#AAAAAA"
ca.font = "#FFFFFF"
ca.arrow = "#FFFFFF"

# Now that we've got everything set up, let's make a graph
g = Graph("dummy.png", end=endTime, vertical_label="Bits", color=ca)
g.data.extend([def1, def2, cdef1, cdef2, area2, area1])
g.title = '"In- and Out-bound Traffic Across Local Router"'
# g.logarithmic = ' '

# Iterate through the different resoltions for which we want to
# generate graphs.
for time, step in times:
Exemplo n.º 15
0
def GenerateGraph():

    data = db.GetDataHumidityRrd(10000)
    #print len(data)

    filename = 'humidity.rrd'
    graphfile = 'humidity.png'
    graphfileLg = 'humidity-large.png'

    day = 24 * 60 * 60
    week = 7 * day
    month = day * 30
    quarter = month * 3
    half = 365 * day / 2
    year = 365 * day

    startTime = data[0][0] -1
    endTime   = data[-1][0]
    step = 1000
    maxSteps = int((endTime-startTime)/step)

    # Let's create and RRD file and dump some data in it
    dss = []
    ds1 = DS(dsName='humidity', dsType='GAUGE', heartbeat=60)
    dss.extend([ds1])

    #week: RA:AVERAGE:0.5:6:336
    #For Daily Graph, every 5 minute average for 24 hours:
    #RRA:AVERAGE:0.5:1:288
    rra1 = RRA(cf='AVERAGE', xff=0.5, steps=1, rows=1440)

    #For Weekly Graph, every 30 minute average for 7 days:
    #RRA:AVERAGE:0.5:6:336
    #rra1 = RRA(cf='AVERAGE', xff=0.5, steps=6, rows=336)

    #For Monthly Graph, every 2 hour average for 30 days:
    #RRA:AVERAGE:0.5:24:360
    #rra1 = RRA(cf='AVERAGE', xff=0.5, steps=32, rows=1080)

    #For Yearly Graph, every 1 day average for 365 days:
    #RRA:AVERAGE:0.5:288:365
    #rra1 = RRA(cf='AVERAGE', xff=0.5, steps=96, rows=365)

    rras = []
    #rra1 = RRA(cf='AVERAGE', xff=0.5, steps=24, rows=1460)
    rras.append(rra1)

    myRRD = RRD(filename, ds=dss, rra=rras, start=startTime)
    myRRD.create()

    # let's generate some data...
    currentTime = startTime
    i = 0
    for row in data:
        timestamp = row[0]
        value1 = row[1]

        # lets update the RRD/purge the buffer ever 100 entires
        i = i + 1
        if i % 100 == 0:
            myRRD.update(debug=False)

        # when you pass more than one value to update buffer like this,
        # they get applied to the DSs in the order that the DSs were
        # "defined" or added to the RRD object.
        myRRD.bufferValue(timestamp, value1)
    # add anything remaining in the buffer
    myRRD.update()

    # Let's set up the objects that will be added to the graph
    def1 = DEF(rrdfile=myRRD.filename, vname='anturi1', dsName=ds1.name)
    vdef1 = VDEF(vname='myavg', rpn='%s,AVERAGE' % def1.vname)
    sensor1 = LINE(defObj=def1, color='#4544FC', legend='anturi1')
    line1 = LINE(defObj=vdef1, color='#01FF13', legend='Average', stack=True)

    # Let's configure some custom colors for the graph
    ca = ColorAttributes()
    ca.back = '#000000'
    ca.canvas = '#000000'
    ca.shadea = '#000000'
    ca.shadeb = '#111111'
    ca.mgrid = '#CCCCCC'
    ca.axis = '#FFFFFF'
    ca.frame = '#AAAAAA'
    ca.font = '#FFFFFF'
    ca.arrow = '#FFFFFF'

    # Now that we've got everything set up, let's make a graph
    #startTime = endTime - 3 * month
    g = Graph(graphfile, start=startTime, end=endTime, vertical_label='kosteus', color=ca)
    g.data.extend([def1, vdef1, sensor1])
    g.write()

    g.filename = graphfileLg
    g.width = 690
    g.height = 300
    g.write()
Exemplo n.º 16
0
def draw_graph(data, group):
  ## Graph bytes_in, bytes_out, request, by time+group
  filename = 'network.rrd'
  graphfile_traffic = 'traffic%s.png' %group
#  graphfileLg_traffic = 'traffic-large.png'
  graphfile_request = 'request%s.png' %group
#  graphfileLg_request = 'request-large'
  
  #define times
  hour = 60 * 60
  day = 24 * 60 * 60
  week = 7 * day
  month = day * 30
  quarter = month * 3
  half = 365 * day / 2
  year = 365 * day
  delta = settings.DELTA * hour
  step = 1
  endTime = int(time.time()) - 600
  startTime = endTime - 360000
  maxSteps = int((endTime-startTime)/step)
  
  # create RRD file
 
#  DSTYPE
#  Counter:Use this format with value of snmp MIB like traffic counter or 
#  packet number for a interface. 
#  Gauge:Use this format for value like temperature,  indicator of pressure.
#  Derive:Use this format if you variation or settings.DELTA between a moment and 
#  an another moment like the rate of of people entering or leaving a
#  room and derive works exactly like COUNTER but without overflow checks.
#  Absolute:Use this format when you count the number of mail after an alert. 
#   
#  HEARTBEAT
#  Is define the frequency between each update of value in the database but some time
#  it is possible to have UNKNOWN value.
#  MIN AND MAX are optional parameters witch define the range of your data source (DS).
#  If your value is out of the range the value will be defined as UNKNOWN.
#  If you don not know exactly the range of you value you can set the MIN and MAX value with 
#  U for unknown

  dss = []
  ds1 = DS(dsName='bytes_out', dsType='ABSOLUTE', heartbeat=200)
  ds2 = DS(dsName='bytes_in', dsType='ABSOLUTE', heartbeat=200)
  ds3 = DS(dsName='request', dsType='COUNTER', heartbeat=200)
  dss.extend([ds1, ds2, ds3])
  
  rras1 = []
  rra1 = RRA(cf='AVERAGE', xff=0.5, steps=1, rows=1440)
  rra2 = RRA(cf='AVERAGE', xff=0.5, steps=6, rows=2016)
  rra3 = RRA(cf='AVERAGE', xff=0.5, steps=60, rows=720)
  rras1.extend([rra1, rra2, rra3])
  
  myRRD = RRD(filename, step=step, ds=dss, rra=rras1, start=startTime)
  myRRD.create(debug=False)
  
  ## RRD update
  
  counter = 0
  for i in data:
    counter += 1
    bytes_in = i['bytes_in'] 
    bytes_out = i['bytes_out'] 
    requests = i['request'] 
    times = i['time'] 
    print bytes_out/1000000
    myRRD.bufferValue(times, bytes_out, bytes_in, requests)
    if counter % 100 == 0:
      myRRD.update(debug=True)
  myRRD.update(debug=True)
  
  ## RRD graph
  
  def1 = DEF(rrdfile=myRRD.filename, vname='output', dsName=ds1.name)
  def2 = DEF(rrdfile=myRRD.filename, vname='input', dsName=ds2.name)
  def3 = DEF(rrdfile=myRRD.filename, vname='request', dsName=ds3.name)
  vdef11 = VDEF(vname='max_out', rpn='%s,MAXIMUM' % def1.vname)
  vdef12 = VDEF(vname='avg_out', rpn='%s,AVERAGE' % def1.vname)
  vdef21 = VDEF(vname='max_in', rpn='%s,MAXIMUM' % def2.vname)
  vdef22 = VDEF(vname='avg_in', rpn='%s,AVERAGE' % def2.vname)
  vdef31 = VDEF(vname='max_request', rpn='%s,MAXIMUM' % def3.vname)
  vdef32 = VDEF(vname='avg_request', rpn='%s,AVERAGE' % def3.vname)
  
  line1 = LINE(2, defObj=def1, color='#2029CC', legend='Out')
  line2 = LINE(2, defObj=def2, color='#00FF00', legend='In')
  line3 = LINE(2, defObj=def3, color='#FF0000', legend='Request')
  gprint11 = GPRINT(vdef11, 'max\\: %5.1lf %Sbps')
  gprint12 = GPRINT(vdef12, 'avg\\: %5.1lf %Sbps\\n')
  gprint21 = GPRINT(vdef21, 'max\\: %5.1lf %Sbps')
  gprint22 = GPRINT(vdef22, 'avg\\: %5.1lf %Sbps\\n')
  gprint31 = GPRINT(vdef31, 'max\\: %5.1lf %S')
  gprint32 = GPRINT(vdef32, 'avg\\: %5.1lf %S\\n')
  
  
  # ColorAttributes
  ca = ColorAttributes()
  ca.back = '#CCCDE2'  #background
  ca.canvas = '#FFFFFF'#the background of the actual graph
  ca.shadea = '#000000'#left and top border
  ca.shadeb = '#111111'#right and bottom border
  ca.mgrid = '#6666CC' #maior grid
  ca.axis = '#000000'  #axis of the graph
  ca.frame = '#CCCDE2' #line around the color spots
  ca.font = '#000000'  #color of the font
  ca.arrow = '#CC0000' # arrow head pointing up and forward
  
## graph traffic
  g = Graph(graphfile_traffic, end=endTime, vertical_label='Bytes/s', color=ca)
  g.data.extend([def1, def2, vdef11, vdef12, vdef21, vdef22, line1, gprint11, gprint12, line2, gprint21, gprint22])
  g.title = '"report traffic %s"'%group
  
  g.start=endTime - delta
  g.step = step
  g.width = 397
  g.height = 182
  g.write(debug=True)
  
#  g.filename = graphfileLg_traffic
#  g.width = 800
#  g.height = 400
#  g.write()

## graph request
  g1 = Graph(graphfile_request, end=endTime, vertical_label='Request/s', color=ca)
  g1.data.extend([def3, vdef31, vdef32, line3, gprint31, gprint32])
  g1.title = '"report request %s"'%group

  g1.start=endTime - settings.DELTA
  g1.step = step
  g1.width = 397
  g1.height = 182
  g1.write(debug=False)
Exemplo n.º 17
0
def draw_total(res):
  ## graph total(bytes_out, bytes_in, request) by time
  
  # define name
  filename = 'total.rrd'
  graphfile_total_traffic = 'total_traffic.png' 
#  graphfileLg_total_traffic = 'total_traffic-large.png'
  graphfile_total_request = 'total_request.png'
#  graphfileLg_total_request = 'total_request-large'
  
  #define times
  hour = 60 * 60
  day = 24 * 60 * 60
  week = 7 * day
  month = day * 30
  quarter = month * 3
  half = 365 * day / 2
  year = 365 * day
  delta = settings.DELTA * hour
  step = 1
  endTime = int(time.time()) - 600
  startTime = endTime - 360000
  maxSteps = int((endTime-startTime)/step)
  
  ## Create RRD 
  dss = []
  ds1 = DS(dsName='total_bytes_out', dsType='ABSOLUTE', heartbeat=200)
  ds2 = DS(dsName='total_bytes_in', dsType='ABSOLUTE', heartbeat=200)
  ds3 = DS(dsName='total_request', dsType='ABSOLUTE', heartbeat=200)
  dss.extend([ds1, ds2, ds3])

  rras1 = []
  rra1 = RRA(cf='AVERAGE', xff=0.5, steps=1, rows=1440)
  rra2 = RRA(cf='AVERAGE', xff=0.5, steps=6, rows=2016)
  rra3 = RRA(cf='AVERAGE', xff=0.5, steps=60, rows=720)
  rras1.extend([rra1, rra2, rra3])
  
  myRRD = RRD(filename, step=step, ds=dss, rra=rras1, start=startTime)
  myRRD.create(debug=False)
  
  ## RRD update
  counter = 0
  for i in res:
    counter += 1
    total_bytes_in = int(i['total_bytes_in']) 
    total_bytes_out = int(i['total_bytes_out']) 
    total_requests = int(i['total_request']) 
    t_times = int(i['time']) 
    print total_bytes_out/1000000
    myRRD.bufferValue(t_times, total_bytes_out, total_bytes_in, total_requests)
    if counter % 100 == 0:
      myRRD.update(debug=True)
  myRRD.update(debug=True)
  
  
  ## RRD graph
  def1 = DEF(rrdfile=myRRD.filename, vname='output', dsName=ds1.name, cdef='AVERAGE')
  def2 = DEF(rrdfile=myRRD.filename, vname='input', dsName=ds2.name, cdef='AVERAGE')
  def3 = DEF(rrdfile=myRRD.filename, vname='request', dsName=ds3.name, cdef='AVERAGE')
  
  # Out
  vdef11 = VDEF(vname='max_out', rpn='%s,MAXIMUM' % def1.vname)
  vdef12 = VDEF(vname='avg_out', rpn='%s,AVERAGE' % def1.vname)
  vdef13 = VDEF(vname='min_out', rpn='%s,MINIMUM' % def1.vname)
  
  line1 = LINE(2, defObj=def1, color='#2029CC', legend='Out')
  gprint11 = GPRINT(vdef11, 'max\\: %5.1lf %Sbps')
  gprint12 = GPRINT(vdef12, 'avg\\: %5.1lf %Sbps')
  gprint13 = GPRINT(vdef13, 'min\\: %5.1lf %Sbps\\n')
  
  # In
  vdef21 = VDEF(vname='max_in', rpn='%s,MAXIMUM' % def2.vname)
  vdef22 = VDEF(vname='avg_in', rpn='%s,AVERAGE' % def2.vname)
  
  line2 = LINE(2, defObj=def2, color='#00FF00', legend='In')
  gprint21 = GPRINT(vdef21, 'max\\: %5.1lf %Sbps')
  gprint22 = GPRINT(vdef22, 'avg\\: %5.1lf %Sbps\\n')
  
  # Request
  vdef31 = VDEF(vname='max_request', rpn='%s,MAXIMUM' % def3.vname)
  vdef32 = VDEF(vname='avg_request', rpn='%s,AVERAGE' % def3.vname)
  
  line3 = LINE(2, defObj=def3, color='#FF0000', legend='Request')
  gprint31 = GPRINT(vdef31, 'max\\: %5.1lf %S')
  gprint32 = GPRINT(vdef32, 'avg\\: %5.1lf %S\\n')
  
  # ColorAttributes
  ca = ColorAttributes()
  ca.back = '#CCCDE2'  #background
  ca.canvas = '#FFFFFF'#the background of the actual graph
  ca.shadea = '#000000'#left and top border
  ca.shadeb = '#111111'#right and bottom border
  ca.mgrid = '#6666CC' #major grid
  ca.axis = '#000000'  #axis of the graph
  ca.frame = '#CCCDE2' #line around the color spots
  ca.font = '#000000'  #color of the font
  ca.arrow = '#CC0000' # arrow head pointing up and forward
  
  
  ##  
  g = Graph(graphfile_total_traffic, end=endTime, vertical_label='Bytes/s', color=ca)
  g.data.extend([def1, def2, vdef11, vdef12, vdef13, vdef21, vdef22, line1, gprint11, gprint12, gprint13, line2, gprint21, gprint22])
  g.title = '"report total traffic"'

  g.start = endTime - delta
  
  g.step = step
  g.width = 397
  g.height = 182
  g.write(debug=True)
  
#  g.filename = graphfileLg_total_traffic
#  g.width = 800
#  g.height = 400
#  g.write()
#  
##
  g1 = Graph(graphfile_total_request, end=endTime, vertical_label='Request/s', color=ca)
  g1.data.extend([def3, vdef31, vdef32, line3, gprint31, gprint32])
  g1.title = '"report total request"'

  g1.start = endTime - settings.DELTA
  g1.step = step
  g1.width = 397
  g1.height = 182
  g1.write(debug=True)
                rpn='%s,AVERAGE' % device_def[i].vname))
        device_val.append(GPRINT(device_aver[i], 'Average ' +
                sensor_name[i] + ' Temperature: %6.2lf Degrees F'))
                        

    # Graph Comment    

    cmt = COMMENT(comment)

    # Define Graph Colors
    #    black background:
    black_bkgnd = ColorAttributes()
    black_bkgnd.back = '#000000'
    black_bkgnd.canvas = '#333333'
    black_bkgnd.shadea = '#000000'
    black_bkgnd.shadeb = '#111111'
    black_bkgnd.mgrid = '#CCCCCC'
    black_bkgnd.axis = '#FFFFFF'
    black_bkgnd.frame = '#0000AA'
    black_bkgnd.font = '#FFFFFF'
    black_bkgnd.arrow = '#FFFFFF'

    #    white background:
    white_bkgnd = ColorAttributes()
    white_bkgnd.back = '#FFFFFF'
    white_bkgnd.canvas = '#EEEEEE'
    white_bkgnd.shadea = '#000000'
    white_bkgnd.shadeb = '#111111'
    white_bkgnd.mgrid = '#444444'
    white_bkgnd.axis = '#000000'
    white_bkgnd.frame = '#0000AA'
Exemplo n.º 19
0
def2 = DEF(rrdfile=myRRD.filename, vname='mysilliness', dsName=ds2.name)
def3 = DEF(rrdfile=myRRD.filename, vname='myinsanity', dsName=ds3.name)
def4 = DEF(rrdfile=myRRD.filename, vname='mydementia', dsName=ds4.name)
vdef1 = VDEF(vname='myavg', rpn='%s,AVERAGE' % def1.vname)
area1 = AREA(defObj=def1, color='#FFA902', legend='Raw Data 4')
area2 = AREA(defObj=def2, color='#DA7202', legend='Raw Data 3')
area3 = AREA(defObj=def3, color='#BD4902', legend='Raw Data 2')
area4 = AREA(defObj=def4, color='#A32001', legend='Raw Data 1')
line1 = LINE(defObj=vdef1, color='#01FF13', legend='Average', stack=True)

# Let's configure some custom colors for the graph
ca = ColorAttributes()
ca.back = '#333333'
ca.canvas = '#333333'
ca.shadea = '#000000'
ca.shadeb = '#111111'
ca.mgrid = '#CCCCCC'
ca.axis = '#FFFFFF'
ca.frame = '#AAAAAA'
ca.font = '#FFFFFF'
ca.arrow = '#FFFFFF'

# Now that we've got everything set up, let's make a graph
startTime = endTime - 3 * month
g = Graph(graphfile, start=startTime, end=endTime, vertical_label='data', color=ca)
g.data.extend([def1, def2, def3, def4, vdef1, area4, area3, area2, area1])
g.write()

g.filename = graphfileLg
g.width = 800
g.height = 400
Exemplo n.º 20
0
def drawgraph(req, graphid):
	now = int(time.time())
	ginfo = Rrdgraph.objects.get(pk=graphid)
	gobjects = GraphItems.objects.filter(graph__id=graphid).order_by('seq')
	gitems = []
	secondsago = secsago(req)
	if secondsago == 0:
		secondsago = 3600
	#	secsago = ginfo.timespan
	
	end = int(req.GET.get('end', now))
	start = int(req.GET.get('start', end - secondsago))


	for gobject in gobjects: #cycle through graph items...need to order this above

            if gobject.itemtype == 'S': #Handle Static RRD DataSources
		rootdir = gobject.rrdds.rootdir.path
		subpath = gobject.rrdds.subpath
		rrdds = gobject.rrdds.ds
		filename = rootdir + '/' + gobject.rrdds.subpath
		rra = gobject.rra
		namesuff = str(gobject.seq)
		legendtext = subpath+" "+rrdds+" "+rra+ " "
                gitems.append(DEF(rrdfile=filename, vname='d'+namesuff, dsName=rrdds))
		gitems.append(CDEF(vname='c'+namesuff, rpn='%s' % 'd'+namesuff))
		linetype = gobject.linetype.upper()
		mycolor = '#' + gobject.color + gobject.transparency
		if linetype == 'A':
			gitems.append(AREA(value='c'+namesuff, color=mycolor, legend=legendtext, stack=gobject.stack))
		elif linetype[:1] == 'L':
			gitems.append(LINE(linetype[-1:], 'c'+namesuff, color=mycolor, legend=legendtext, stack=gobject.stack))
		else:
			gitems.append(LINE(0, 'c'+namesuff, color=mycolor, legend=legendtext, stack=gobject.stack))

	    if gobject.itemtype == 'R':  #Handle Regex
	     	regtextarr = gobject.option_text.rsplit(' ',2)
	        rrddslist = Rrdfiles.objects.filter(rootdir__name__regex=regtextarr[0]).filter(subpath__regex=regtextarr[1]).filter(ds__regex=regtextarr[2])
		i = 0

		colors = []
		colorset = GraphItemColorCycleColor.objects.filter(name='weeee').order_by('seq')
		for x in colorset:
		     	colors.append(str('#' + x.color))

		for rrdds in rrddslist:
			rootdir = rrdds.rootdir.path
			subpath = rrdds.subpath
			rrdds = rrdds.ds
			filename = rootdir + subpath
			rra = gobject.rra
			linetype = gobject.linetype.upper()
			mycolor = colors[i % len(colors)]
			namesuff = str(gobject.seq) + '_' + str(i)
			legendtext = subpath+" "+rrdds+" ("+rra+ ") "
                	gitems.append(DEF(rrdfile=filename, vname='d'+namesuff, dsName=rrdds))
			gitems.append(CDEF(vname='c'+namesuff, rpn='%s' % 'd'+namesuff))
			if linetype == 'A':
				gitems.append(AREA(value='c'+namesuff, color=mycolor, legend=legendtext, stack=gobject.stack))
			elif linetype[:1] == 'L':
				gitems.append(LINE(linetype[-1:], 'c'+namesuff, color=mycolor, legend=legendtext, stack=gobject.stack))
			else:
				gitems.append(LINE(0, 'c'+namesuff, color=mycolor, legend=legendtext, stack=gobject.stack))
			prnFmt = '%6.2lf'
			vdef = VDEF(vname='va'+namesuff, rpn='%s,AVERAGE' % ('d'+namesuff) )
			gitems.append(vdef)
			gitems.append(GPRINT(vdef, ('Avg\:'+prnFmt)))
			vdef = VDEF(vname='vn'+namesuff, rpn='%s,MINIMUM' % ('d'+namesuff) )
			gitems.append(vdef)
			gitems.append(GPRINT(vdef, ('Min\:'+prnFmt)))
			vdef = VDEF(vname='vx'+namesuff, rpn='%s,MAXIMUM' % ('d'+namesuff) )
			gitems.append(vdef)
			gitems.append(GPRINT(vdef, ('Max\:'+prnFmt)))
			vdef = VDEF(vname='vl'+namesuff, rpn='%s,LAST' % ('d'+namesuff) )
			gitems.append(vdef)
			gitems.append(GPRINT(vdef, ('LAST\:'+prnFmt+'\\n')))
			#gitems.append(COMMENT('\\n', False))
			i = i + 1

	    if gobject.itemtype == 'C':  #Handle Custom CDEFS
		pass

	    if gobject.itemtype == 'V': #Handle Custom VDEFs
		pass
	cs = req.GET.get('cs', ginfo.gcolorscheme)
	colsch = GraphColorScheme.objects.get(pk=cs)
   	ca = ColorAttributes()
   	ca.back = '#' + colsch.cback + colsch.tback
   	ca.canvas = '#' + colsch.ccanvas + colsch.tcanvas
   	ca.shadea = '#' + colsch.cshadea + colsch.tshadea
   	ca.shadeb = '#' + colsch.cshadeb + colsch.tshadeb
   	ca.mgrid = '#' + colsch.cmgrid + colsch.tmgrid
   	ca.axis = '#' + colsch.caxis + colsch.taxis
   	ca.frame = '#' + colsch.cframe + colsch.tframe
   	ca.font = '#' + colsch.cfont + colsch.tfont
   	ca.arrow = '#' + colsch.carrow + colsch.tarrow
	#make a pyrrd Graph object, destination standard out (-)
	g = Graph('-', imgformat='png', start=start, end=end, color=ca, vertical_label='"'+ginfo.vertical_label+'"')
	#populate it with our url params, defaulting to Rrdgraph instance (ginfo) options
	fullsizemode = req.GET.get('fullsizemode')
	if (fullsizemode in ['0', 'False' , 'false', 'no', 'No']):
		g.full_size_mode = False
	else:
		g.full_size_mode = True
	graphonly = req.GET.get('graphonly')
	if (graphonly in ['1', 'True' , 'true', 'yes']):
		g.only_graph = True
	noleg = req.GET.get('nolegend')
	if (noleg in ['1', 'True' , 'true', 'yes']):
		g.no_legend = True
	log = req.GET.get('logarithmic')

	if (log in ['1', 'True' , 'true', 'yes', 'Yes']):
		g.logarithmic = True
	elif (log in ['0', 'False' , 'false', 'no', 'No']):
		g.logarithmic = False
	else:
		g.logarithmic = getattr(ginfo, 'logarithmic', False)
	g.disable_rrdtool_tags = True
	g.height = req.GET.get('height', 600)
	g.width = req.GET.get('width', 1200)
	g.title = '"'+ginfo.name+'"' 
	g.data.extend(gitems)  #write in our gitems we generated
	a = g.write()	#gets the binary image finally
	#minetype #just a thing to cause an error and debug
    	return HttpResponse(a,mimetype="image/png")
Exemplo n.º 21
0
    def graph_connection(self, period='day'):
        def1 = DEF(rrdfile=self.rrdfile, vname='connections', dsName="connections", cdef="AVERAGE")
        def2 = DEF(rrdfile=self.rrdfile, vname='reading', dsName="reading", cdef="AVERAGE")
        def3 = DEF(rrdfile=self.rrdfile, vname='writing', dsName="writing", cdef="AVERAGE")
        def4 = DEF(rrdfile=self.rrdfile, vname='waiting', dsName="waiting", cdef="AVERAGE")

        # TOTAL
        vdef1 = VDEF(vname='max', rpn='connections,MAXIMUM')
        vdef2 = VDEF(vname='avg', rpn='connections,AVERAGE')
        vdef3 = VDEF(vname='last', rpn='connections,LAST')
        vdef4 = VDEF(vname='min', rpn='connections,MINIMUM')

        line1 = LINE(1, defObj=def1, color='#22FF22', legend='Total')
        gprint1 = GPRINT(vdef1, "Max\\: %5.1lf %S")
        gprint2 = GPRINT(vdef2, "Avg\\: %5.1lf %S")
        gprint3 = GPRINT(vdef3, "Current\\: %5.1lf %S")
        gprint4 = GPRINT(vdef4, "Min\\: %5.1lf %S\\n")

        # READING
        reading_vdef1 = VDEF(vname='rmax', rpn='reading,MAXIMUM')
        reading_vdef2 = VDEF(vname='ravg', rpn='reading,AVERAGE')
        reading_vdef3 = VDEF(vname='rlast', rpn='reading,LAST')
        reading_vdef4 = VDEF(vname='rmin', rpn='reading,MINIMUM')

        line2 = LINE(1, defObj=def2, color='#0022FF', legend='Reading')
        reading_gprint1 = GPRINT(reading_vdef1, "Max\\: %5.1lf %S")
        reading_gprint2 = GPRINT(reading_vdef2, "Avg\\: %5.1lf %S")
        reading_gprint3 = GPRINT(reading_vdef3, "Current\\: %5.1lf %S")
        reading_gprint4 = GPRINT(reading_vdef4, "Min\\: %5.1lf %S\\n")

        # writing
        writing_vdef1 = VDEF(vname='wmax', rpn='writing,MAXIMUM')
        writing_vdef2 = VDEF(vname='wavg', rpn='writing,AVERAGE')
        writing_vdef3 = VDEF(vname='wlast', rpn='writing,LAST')
        writing_vdef4 = VDEF(vname='wmin', rpn='writing,MINIMUM')

        line3 = LINE(1, defObj=def3, color='#FF0000', legend='Writing')
        writing_gprint1 = GPRINT(writing_vdef1, "Max\\: %5.1lf %S")
        writing_gprint2 = GPRINT(writing_vdef2, "Avg\\: %5.1lf %S")
        writing_gprint3 = GPRINT(writing_vdef3, "Current\\: %5.1lf %S")
        writing_gprint4 = GPRINT(writing_vdef4, "Min\\: %5.1lf %S\\n")

        # WAITING
        waiting_vdef1 = VDEF(vname='wamax', rpn='waiting,MAXIMUM')
        waiting_vdef2 = VDEF(vname='waavg', rpn='waiting,AVERAGE')
        waiting_vdef3 = VDEF(vname='walast', rpn='waiting,LAST')
        waiting_vdef4 = VDEF(vname='wamin', rpn='waiting,MINIMUM')

        line4 = LINE(1, defObj=def4, color='#00AAAA', legend='Waiting')
        waiting_gprint1 = GPRINT(waiting_vdef1, "Max\\: %5.1lf %S")
        waiting_gprint2 = GPRINT(waiting_vdef2, "Avg\\: %5.1lf %S")
        waiting_gprint3 = GPRINT(waiting_vdef3, "Current\\: %5.1lf %S")
        waiting_gprint4 = GPRINT(waiting_vdef4, "Min\\: %5.1lf %S\\n")

        ca = ColorAttributes()
        ca.back = '#333333'
        ca.canvas = '#333333'
        ca.shadea = '#000000'
        ca.shadeb = '#111111'
        ca.mgrid = '#CCCCCC'
        ca.axis = '#FFFFFF'
        ca.frame = '#AAAAAA'
        ca.font = '#FFFFFF'
        ca.arrow = '#FFFFFF'

        img = "connection-%s.png" % period
        imgname = self.static_path +"/"+ img
        start = '-1'+period

        g = Graph(imgname, imgformat='PNG', step=start, vertical_label='connections', color=ca, width=700, height=150)
        g.data.extend([def1, vdef1, vdef2, vdef3, vdef4, line1, gprint1, gprint2, gprint3, gprint4])
        g.data.extend([def2, reading_vdef1, reading_vdef2, reading_vdef3, reading_vdef4, line2, reading_gprint1, reading_gprint2, reading_gprint3, reading_gprint4])
        g.data.extend([def3, writing_vdef1, writing_vdef2, writing_vdef3, writing_vdef4, line3, writing_gprint1, writing_gprint2, writing_gprint3, writing_gprint4])
        g.data.extend([def4, waiting_vdef1, waiting_vdef2, waiting_vdef3, waiting_vdef4, line4, waiting_gprint1, waiting_gprint2, waiting_gprint3, waiting_gprint4])
        g.write()