from rrdweb import rrd
rrd_path = "rrd/armo.switches.pvl_atk-luokka.rrd"
out_path = "img/armo.switches.pvl_atk-luokka.png"
detail_size = (600, 200)
# common options for all output
detail_opts = dict(
# output
imgformat = "PNG",
lazy = True,
# dimensions
width = detail_size[0],
height = detail_size[1],
color = [
# disable border
# border = 0,
"SHADEA#ffffff00",
"SHADEB#ffffff00",
# keep background transparent
"BACK#ffffff00",
"SHADEB#ffffff00",
],
# labels
vertical_label = "bits/s",
units = "si",
# use logarithmic scaling
logarithmic = True,
# smooth out lines
slope_mode = True,
)
graph_opts = dict(
daily = dict(
# labels
x_grid = "MINUTE:15:HOUR:1:HOUR:4:0:%H:%M",
# general info
title = "Daily Traffic @ armo.switches.pvl -> atk-luokka",
# interval
start = "-24h",
),
)
rrd.graph(out_path,
# data sources, bytes/s
r'DEF:in0=%s:ds0:AVERAGE' % rrd_path,
r'DEF:out0=%s:ds1:AVERAGE' % rrd_path,
# data, bits/s
'CDEF:in=in0,8,*',
'CDEF:out=out0,8,*',
# values
'VDEF:in_max=in,MAXIMUM',
'VDEF:in_avg=in,AVERAGE',
'VDEF:in_min=in,MINIMUM',
'VDEF:out_max=out,MAXIMUM',
'VDEF:out_avg=out,AVERAGE',
'VDEF:out_min=out,MINIMUM',
# legend/graph
"COMMENT:%4s" % "",
"COMMENT:%11s" % "Maximum",
"COMMENT:%11s" % "Average",
"COMMENT:%11s\\l" % "Minimum",
"LINE1:in#0000FF:%4s" % "In",
'GPRINT:in_max:%6.2lf %Sbps',
'GPRINT:in_avg:%6.2lf %Sbps',
'GPRINT:in_min:%6.2lf %Sbps\\l',
"LINE1:out#00CC00:%4s" % "Out",
'GPRINT:out_max:%6.2lf %Sbps',
'GPRINT:out_avg:%6.2lf %Sbps',
'GPRINT:out_min:%6.2lf %Sbps\\l',
)