rrdweb/graph.py
author Tero Marttila <terom@fixme.fi>
Tue, 08 Dec 2009 20:54:13 +0200
changeset 7 804243b0bcb9
parent 5 e716718482c3
child 17 a1608b66be45
permissions -rw-r--r--
add sum max/avg/min to overview graphs
5
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
import rrd
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
import time
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
"""
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
    RRDTool graph output
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
"""
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
def timestamp () :
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
    return time.strftime("%Y/%m/%d %H:%M:%S %Z")
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
def common_opts () :
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
    """
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
        Common options for all views
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
    """
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
    return dict(
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    17
        # output
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
        imgformat           = "PNG",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
        #        lazy                = True,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
        color               = [
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
            # disable border
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    23
            # border            = 0,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    24
            "SHADEA#ffffff00",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    25
            "SHADEB#ffffff00",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    26
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    27
            # keep background transparent
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
            "BACK#ffffff00",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    29
            "SHADEB#ffffff00",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    30
        ],
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
         
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    32
        # labels
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    33
        vertical_label      = "bits/s",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    34
        units               = "si",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
        # use logarithmic scaling
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
        logarithmic         = True,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
        
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
        # smooth out lines
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
        slope_mode          = True,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41
    )
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    42
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    43
def overview_opts () :
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    44
    """
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    45
        Common options for the overview graph
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    46
    """
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    47
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    48
    return dict(
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    49
        width               = 600,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    50
        height              = 50,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    51
    ), [
7
804243b0bcb9 add sum max/avg/min to overview graphs
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
    52
        "CDEF:all=in,out,+",
804243b0bcb9 add sum max/avg/min to overview graphs
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
    53
804243b0bcb9 add sum max/avg/min to overview graphs
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
    54
        "VDEF:max=all,MAXIMUM",
804243b0bcb9 add sum max/avg/min to overview graphs
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
    55
        "VDEF:avg=all,AVERAGE",
804243b0bcb9 add sum max/avg/min to overview graphs
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
    56
        "VDEF:min=all,MINIMUM",
804243b0bcb9 add sum max/avg/min to overview graphs
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
    57
804243b0bcb9 add sum max/avg/min to overview graphs
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
    58
        "LINE1:in#0000FF:In",
804243b0bcb9 add sum max/avg/min to overview graphs
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
    59
        "LINE1:out#00CC00:Out",
804243b0bcb9 add sum max/avg/min to overview graphs
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
    60
804243b0bcb9 add sum max/avg/min to overview graphs
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
    61
        "GPRINT:max:%6.2lf %Sbps max",
804243b0bcb9 add sum max/avg/min to overview graphs
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
    62
        "GPRINT:avg:%6.2lf %Sbps avg",
804243b0bcb9 add sum max/avg/min to overview graphs
Tero Marttila <terom@fixme.fi>
parents: 5
diff changeset
    63
        "GPRINT:min:%6.2lf %Sbps min\\l",
5
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    64
    ]
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    65
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    66
def detail_opts () :
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    67
    """
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    68
        Common options for the detail graph
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    69
    """
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    70
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    71
    return dict(
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    72
        # dimensions
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    73
        width               = 600,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    74
        height              = 200,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    75
    ), [
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    76
        # values
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    77
        'VDEF:in_max=in,MAXIMUM',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    78
        'VDEF:in_avg=in,AVERAGE',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    79
        'VDEF:in_min=in,MINIMUM',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    80
        'VDEF:out_max=out,MAXIMUM',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    81
        'VDEF:out_avg=out,AVERAGE',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    82
        'VDEF:out_min=out,MINIMUM',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    83
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    84
        # legend/graph
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    85
        "COMMENT:%4s" % "",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    86
        "COMMENT:%11s" % "Maximum",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    87
        "COMMENT:%11s" % "Average",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    88
        "COMMENT:%11s\\l" % "Minimum",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    89
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    90
        "LINE1:in#0000FF:%4s" % "In",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    91
        'GPRINT:in_max:%6.2lf %Sbps',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    92
        'GPRINT:in_avg:%6.2lf %Sbps',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    93
        'GPRINT:in_min:%6.2lf %Sbps\\l',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    94
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    95
        "LINE1:out#00CC00:%4s" % "Out",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    96
        'GPRINT:out_max:%6.2lf %Sbps',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    97
        'GPRINT:out_avg:%6.2lf %Sbps',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    98
        'GPRINT:out_min:%6.2lf %Sbps\\l',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    99
        
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   100
        # mark
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   101
        "COMMENT:Generated %s\\r" % timestamp().replace(':', '\\:'),
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   102
    ]
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   103
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   104
STYLE_DEFS = {
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   105
    'overview': overview_opts,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   106
    'detail':   detail_opts,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   107
}
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   108
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   109
def daily_opts (title) :
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   110
    """
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   111
        Common options for the 'daily' view
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   112
    """
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   113
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   114
    return dict(
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   115
        # labels
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   116
        x_grid              = "MINUTE:15:HOUR:1:HOUR:4:0:%H:%M",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   117
    
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   118
        # general info
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   119
        title               = "Daily %s" % (title, ),
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   120
    
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   121
        # interval
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   122
        start               = "-24h",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   123
    )
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   124
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   125
def weekly_opts (title) :
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   126
    return dict(
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   127
        # labels
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   128
        #        x_grid              = "MINUTE:15:HOUR:1:HOUR:4:0:%H:%M",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   129
    
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   130
        # general info
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   131
        title               = "Weekly %s" % (title, ),
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   132
    
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   133
        # interval
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   134
        start               = "-7d",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   135
    )
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   136
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   137
def yearly_opts (title) :
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   138
    return dict(
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   139
        # labels
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   140
        #        x_grid              = "MINUTE:15:HOUR:1:HOUR:4:0:%H:%M",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   141
    
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   142
        # general info
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   143
        title               = "Yearly %s" % (title, ),
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   144
    
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   145
        # interval
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   146
        start               = "-1y",
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   147
    )
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   148
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   149
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   150
INTERVAL_DEFS = {
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   151
    'daily':    daily_opts,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   152
    'weekly':   weekly_opts,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   153
    'yearly':   yearly_opts,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   154
}
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   155
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   156
def mrtg_data (rrd_path) :
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   157
    """
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   158
        Data sources for network in/out from an MRTG rrd
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   159
    """
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   160
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   161
    return [
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   162
        # data sources, bytes/s
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   163
        r'DEF:in0=%s:ds0:AVERAGE' % rrd_path,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   164
        r'DEF:out0=%s:ds1:AVERAGE' % rrd_path,
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   165
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   166
        # data, bits/s
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   167
        'CDEF:in=in0,8,*',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   168
        'CDEF:out=out0,8,*',
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   169
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   170
    ]        
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   171
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   172
def mrtg (style, interval, title, rrd_path, out_path) :
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   173
    style_opts, style_vars = STYLE_DEFS[style]()
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   174
    interval_opts = INTERVAL_DEFS[interval](title)
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   175
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   176
    opts = rrd.merge_opts(common_opts(), style_opts, interval_opts)
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   177
    data = mrtg_data(rrd_path) + style_vars
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   178
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   179
    return rrd.graph(out_path, *data, **opts)
e716718482c3 hack hack hack some HTML output
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
   180