test.py
changeset 25 9fa9d881fd87
parent 24 29a523db66a8
parent 20 86bbabd10ff6
child 26 d275edd72861
equal deleted inserted replaced
24:29a523db66a8 25:9fa9d881fd87
     1 from rrdweb import rrd
       
     2 
       
     3 rrd_path = "rrd/armo.switches.pvl_atk-luokka.rrd"
       
     4 out_path = "img/armo.switches.pvl_atk-luokka.png"
       
     5 
       
     6 detail_size = (600, 200)
       
     7 
       
     8 # common options for all output
       
     9 detail_opts = dict(
       
    10     # output
       
    11     imgformat           = "PNG",
       
    12     lazy                = True,
       
    13 
       
    14     # dimensions
       
    15     width               = detail_size[0],
       
    16     height              = detail_size[1],
       
    17 
       
    18     color               = [
       
    19         # disable border
       
    20         # border            = 0,
       
    21         "SHADEA#ffffff00",
       
    22         "SHADEB#ffffff00",
       
    23 
       
    24         # keep background transparent
       
    25         "BACK#ffffff00",
       
    26         "SHADEB#ffffff00",
       
    27     ],
       
    28      
       
    29     # labels
       
    30     vertical_label      = "bits/s",
       
    31     units               = "si",
       
    32 
       
    33     # use logarithmic scaling
       
    34     logarithmic         = True,
       
    35     
       
    36     # smooth out lines
       
    37     slope_mode          = True,
       
    38 )
       
    39 
       
    40 graph_opts = dict(
       
    41     daily       = dict(
       
    42         # labels
       
    43         x_grid              = "MINUTE:15:HOUR:1:HOUR:4:0:%H:%M",
       
    44     
       
    45         # general info
       
    46         title               = "Daily Traffic @ armo.switches.pvl -> atk-luokka",
       
    47     
       
    48         # interval
       
    49         start               = "-24h",
       
    50     ),
       
    51 )
       
    52 
       
    53 
       
    54 
       
    55 rrd.graph(out_path,
       
    56     # data sources, bytes/s
       
    57     r'DEF:in0=%s:ds0:AVERAGE' % rrd_path,
       
    58     r'DEF:out0=%s:ds1:AVERAGE' % rrd_path,
       
    59 
       
    60     # data, bits/s
       
    61     'CDEF:in=in0,8,*',
       
    62     'CDEF:out=out0,8,*',
       
    63 
       
    64     # values
       
    65     'VDEF:in_max=in,MAXIMUM',
       
    66     'VDEF:in_avg=in,AVERAGE',
       
    67     'VDEF:in_min=in,MINIMUM',
       
    68     'VDEF:out_max=out,MAXIMUM',
       
    69     'VDEF:out_avg=out,AVERAGE',
       
    70     'VDEF:out_min=out,MINIMUM',
       
    71 
       
    72     # legend/graph
       
    73     "COMMENT:%4s" % "",
       
    74     "COMMENT:%11s" % "Maximum",
       
    75     "COMMENT:%11s" % "Average",
       
    76     "COMMENT:%11s\\l" % "Minimum",
       
    77 
       
    78     "LINE1:in#0000FF:%4s" % "In",
       
    79     'GPRINT:in_max:%6.2lf %Sbps',
       
    80     'GPRINT:in_avg:%6.2lf %Sbps',
       
    81     'GPRINT:in_min:%6.2lf %Sbps\\l',
       
    82 
       
    83     "LINE1:out#00CC00:%4s" % "Out",
       
    84     'GPRINT:out_max:%6.2lf %Sbps',
       
    85     'GPRINT:out_avg:%6.2lf %Sbps',
       
    86     'GPRINT:out_min:%6.2lf %Sbps\\l',
       
    87     
       
    88 
       
    89 )