The images in the Gallery would be a lot more useful if they were complemented by the source code. Man pages are nice, but a couple of simple to complex examples (in cut & paste style) are even nicer.

Here is one example:

RRDs::graph($pic_name,
    # Title of the graph, it is displayed on top of the image
    "--title", "$server CPU Load",
    # Defining colors for the basic graph objects
    "--color", "BACK#000000",
    "--color", "SHADEA#000000",
    "--color", "SHADEB#000000",
    "--color", "FONT#DDDDDD",
    "--color", "CANVAS#202020",
    "--color", "GRID#666666",
    "--color", "MGRID#AAAAAA",
    "--color", "FRAME#202020",
    "--color", "ARROW#FFFFFF",
    # limiting the graph to only 17 load
    "-u 17", "-r",
    # defining data segments for today's and yesterday's load
    "DEF:today=$rrd_name:cpuLoad:AVERAGE:start=end-86400:end=now",
    "DEF:yesterday=$rrd_name:cpuLoad:AVERAGE:start=end-86400:end=now-86400",
    # combining both data segments on one GRAPH
    # if we don't shift yesterday, it will not appear on the graph 
    # since it's time frame is not the one that is currently viewed
    "SHIFT:yesterday:86400",
    # Generate averages for both days
    "CDEF:avg=PREV,UN,today,UN,UNKN,today,IF,PREV,IF,today,UN,1,today,IF,-,0.97,*,today,UN,1,today,IF,+",
    "CDEF:avg1=PREV,UN,yesterday,UN,UNKN,yesterday,IF,PREV,IF,yesterday,UN,1,yesterday,IF,-,0.97,*,yesterday,UN,1,yesterday,IF,+",
    # Write the average of today as a line
    "LINE1:avg#0000FF:Today avg\\t\\t",
    # the colors are #FFFFFF00 where 00 is the percantage of transperance of the color(from 00 to FF, where FF is solid)
    "LINE1:today#F90000",
    "CDEF:shading2=today,0.98,*", "AREA:shading2#F9000022:Today\\t",
    "CDEF:shading10=today,0.90,*", "AREA:shading10#E1000011",
    "CDEF:shading15=today,0.85,*", "AREA:shading15#D2000011",
    "CDEF:shading20=today,0.80,*", "AREA:shading20#C3000011",
    "CDEF:shading25=today,0.75,*", "AREA:shading25#B4000011",
    "CDEF:shading30=today,0.70,*", "AREA:shading30#A5000011",
    "CDEF:shading35=today,0.65,*", "AREA:shading35#96000011",
    "CDEF:shading40=today,0.60,*", "AREA:shading40#87000011",
    "CDEF:shading45=today,0.55,*", "AREA:shading45#78000011",
    "CDEF:shading50=today,0.50,*", "AREA:shading50#69000011",
    "CDEF:shading55=today,0.45,*", "AREA:shading55#5A000011",
    "CDEF:shading60=today,0.40,*", "AREA:shading60#4B000011",
    "CDEF:shading65=today,0.35,*", "AREA:shading65#3C000011",
    "CDEF:shading70=today,0.30,*", "AREA:shading70#2D000011",
    "CDEF:shading75=today,0.25,*", "AREA:shading75#18000011",
    "CDEF:shading80=today,0.20,*", "AREA:shading80#0F000011",
    "CDEF:shading85=today,0.15,*", "AREA:shading85#00000011",
    #
    "GPRINT:today:MAX:Max load\\\: %.2lf",
    "GPRINT:today:AVERAGE:LoadAvg\\\: %.2lf\\n",
    "LINE1:avg1#00FFFF:Yesterday avg\\t",
    "LINE1:yesterday#ffa946",
    "CDEF:shadin2=yesterday,0.98,*", "AREA:shadin2#ffa94622:Yesterday\\t",
    "CDEF:shadin10=yesterday,0.90,*", "AREA:shadin10#ffa94611",
    "CDEF:shadin15=yesterday,0.85,*", "AREA:shadin15#e1953e11",
    "CDEF:shadin20=yesterday,0.80,*", "AREA:shadin20#d28b3a11",
    "CDEF:shadin25=yesterday,0.75,*", "AREA:shadin25#c3813611",
    "CDEF:shadin30=yesterday,0.70,*", "AREA:shadin30#b4773111",
    "CDEF:shadin35=yesterday,0.65,*", "AREA:shadin35#a56d2d11",
    "CDEF:shadin40=yesterday,0.60,*", "AREA:shadin40#96632911",
    "CDEF:shadin45=yesterday,0.55,*", "AREA:shadin45#87592511",
    "CDEF:shadin50=yesterday,0.50,*", "AREA:shadin50#78502111",
    "CDEF:shadin55=yesterday,0.45,*", "AREA:shadin55#69461d11",
    "CDEF:shadin60=yesterday,0.40,*", "AREA:shadin60#5a3c1911",
    "CDEF:shadin65=yesterday,0.35,*", "AREA:shadin65#4b321511",
    "CDEF:shadin70=yesterday,0.30,*", "AREA:shadin70#3c281011",
    "CDEF:shadin75=yesterday,0.25,*", "AREA:shadin75#2d1e0c11",
    "CDEF:shadin80=yesterday,0.20,*", "AREA:shadin80#1e140811",
    "CDEF:shadin85=yesterday,0.15,*", "AREA:shadin85#0f0a0411",
    "GPRINT:yesterday:MAX:Max load\\\: %.2lf",
    "GPRINT:yesterday:AVERAGE:LoadAvg\\\: %.2lf\\n"
);

Marian Marinov <mm |AT| yuhu.biz>

Last modified 11 years ago Last modified on Jan 24, 2008, 10:50:00 AM

NOTE: The content of this website is accessible with any browser. The graphical design though relies completely on CSS2 styles. If you see this text, this means that your browser does not support CSS2. Consider upgrading to a standard conformant browser like Mozilla Firefox or Opera but also Apple's Safari or KDE's Konqueror for example. It may also be that you are looking at a mirror page which did not copy the CSS for this page. Or if some pictu res are missing, then the mirror may not have picked up the contents of the inc directory.