[rrd-users] Emulating MRTG Look with rrdcgi (long)
Zakaria
zak_mail at softhome.net
Thu Jul 10 08:26:22 MEST 2003
Hi there,
I've been using rrdtools to graph an internet cafe network loads.
The problem is I'm trying to make rrdcgi produce a page thats look like
mrtg output. After studying mrtg-rrd.cgi scripts, I came out with
following rrdcgi script.
The output is similar with mrtg default output with one differences.
It doesn't graph VRULE, because VRULE need an absolute epoch time,
and I don't know how to calculate it with rrdcgi. Maybe thats a TODO
for Tobi. Make VRULE accept AT TIME REFERENCE.
Oh, one more thing. If you use UN in CDEF please noted that LAST need
UNKNOWN value or you always get 0 as your Current rates.
I hope it usefull, and sorry for the long post :)
------------------------------------------------------------------------
#!/usr/bin/rrdcgi
<html>
<head>
<title>Utilization Report for CBN</title>
</head>
<body bgcolor="#ffffff">
<h2>Utilization Report for CBN</h2>
<hr>
The statistics were last updated
<b><RRD::TIME::LAST /home/admin/rrd/network.rrd "%A, %e %B, %T %Z"></b>
<hr>
<b>Daily Graph (5 Minute Average)</b><br>
<RRD::GRAPH
/var/www/rrd-image/eth1-day.gif
--lazy
--imginfo '<img src="/rrd-image/%s" width=%lu height=%lu alt="Daily Graph" vspace=10 align=top>'
-c FONT#000000 -c MGRID#000000 -c FRAME#000000 -c BACK#f5f5f5 -c ARROW#000000
-g -l 0 -b 1000
-w 400 -h 100
-v "Byte per second"
-x HOUR:1:HOUR:6:HOUR:2:0:%-H
-s -108000
DEF:in=/home/admin/rrd/network.rrd:eth1_in:AVERAGE
DEF:out=/home/admin/rrd/network.rrd:eth1_out:AVERAGE
DEF:maxin=/home/admin/rrd/network.rrd:eth1_in:MAX
DEF:maxout=/home/admin/rrd/network.rrd:eth1_out:MAX
CDEF:out_pct=out,100,*,64000,/
CDEF:in_pct=in,100,*,64000,/
AREA:in#00cc00:In
LINE2:out#0000ff:Out
HRULE:64000#cc0000
PRINT:in:MAX:"%.1lf %s"
PRINT:in_pct:MAX:%.1lf
PRINT:in:AVERAGE:"%.1lf %s"
PRINT:in_pct:AVERAGE:%.1lf
PRINT:in:LAST:"%.1lf %s"
PRINT:in_pct:LAST:%.1lf
PRINT:out:MAX:"%.1lf %s"
PRINT:out_pct:MAX:%.1lf
PRINT:out:AVERAGE:"%.1lf %s"
PRINT:out_pct:AVERAGE:%.1lf
PRINT:out:LAST:"%.1lf %s"
PRINT:out_pct:LAST:%.1lf
>
<table cellpadding=0 cellspacing=0>
<tr>
<td align=right><small>Max <font color="#00cc00">In:</font><small></td>
<td align=right><small> <RRD::PRINT 0>B/s (<RRD::PRINT 1>%)</small></td>
<td width=5></td>
<td align=right><small>Average <font color="#00cc00">In:</font><small></td>
<td align=right><small> <RRD::PRINT 2>B/s (<RRD::PRINT 3>%)</small></td>
<td width=5></td>
<td align=right><small>Current <font color="#00cc00">In:</font><small></td>
<td align=right><small> <RRD::PRINT 4>B/s (<RRD::PRINT 5>%)</small></td>
</tr>
<tr>
<td align=right><small>Max <font color="#0000ff">Out:</font><small></td>
<td align=right><small> <RRD::PRINT 6>B/s (<RRD::PRINT 7>%)</small></td>
<td width=5></td>
<td align=right><small>Average <font color="#0000ff">Out:</font><small></td>
<td align=right><small> <RRD::PRINT 8>B/s (<RRD::PRINT 9>%)</small></td>
<td width=5></td>
<td align=right><small>Current <font color="#0000ff">Out:</font><small></td>
<td align=right><small> <RRD::PRINT 10>B/s (<RRD::PRINT 11>%)</small></td>
</tr>
</table>
<hr>
<b>Weekly Graph (30 Minute Average)</b><br>
<RRD::GRAPH
/var/www/rrd-image/eth1-week.gif
--lazy
--imginfo '<img src="/rrd-image/%s" width=%lu height=%lu alt="Weekly Graph" vspace=10 align=top>'
-c FONT#000000 -c MGRID#000000 -c FRAME#000000 -c BACK#f5f5f5 -c ARROW#000000
-g -l 0 -b 1000
-w 400 -h 100
-v "Byte per second"
-x DAY:1:DAY:1:DAY:1:86400:%a
-s -691200
DEF:in=/home/admin/rrd/network.rrd:eth1_in:AVERAGE
DEF:out=/home/admin/rrd/network.rrd:eth1_out:AVERAGE
DEF:maxin=/home/admin/rrd/network.rrd:eth1_in:MAX
DEF:maxout=/home/admin/rrd/network.rrd:eth1_out:MAX
CDEF:out_pct=out,100,*,64000,/
CDEF:in_pct=in,100,*,64000,/
AREA:in#00cc00:In
LINE2:out#0000ff:Out
LINE1:maxin#006600:MaxIn
LINE1:maxout#ff00ff:MaxOut
HRULE:64000#cc0000
PRINT:in:MAX:"%.1lf %s"
PRINT:in_pct:MAX:%.1lf
PRINT:in:AVERAGE:"%.1lf %s"
PRINT:in_pct:AVERAGE:%.1lf
PRINT:in:LAST:"%.1lf %s"
PRINT:in_pct:LAST:%.1lf
PRINT:out:MAX:"%.1lf %s"
PRINT:out_pct:MAX:%.1lf
PRINT:out:AVERAGE:"%.1lf %s"
PRINT:out_pct:AVERAGE:%.1lf
PRINT:out:LAST:"%.1lf %s"
PRINT:out_pct:LAST:%.1lf
>
<table cellpadding=0 cellspacing=0>
<tr>
<td align=right><small>Max <font color="#00cc00">In:</font><small></td>
<td align=right><small> <RRD::PRINT 0>B/s (<RRD::PRINT 1>%)</small></td>
<td width=5></td>
<td align=right><small>Average <font color="#00cc00">In:</font><small></td>
<td align=right><small> <RRD::PRINT 2>B/s (<RRD::PRINT 3>%)</small></td>
<td width=5></td>
<td align=right><small>Current <font color="#00cc00">In:</font><small></td>
<td align=right><small> <RRD::PRINT 4>B/s (<RRD::PRINT 5>%)</small></td>
</tr>
<tr>
<td align=right><small>Max <font color="#0000ff">Out:</font><small></td>
<td align=right><small> <RRD::PRINT 6>B/s (<RRD::PRINT 7>%)</small></td>
<td width=5></td>
<td align=right><small>Average <font color="#0000ff">Out:</font><small></td>
<td align=right><small> <RRD::PRINT 8>B/s (<RRD::PRINT 9>%)</small></td>
<td width=5></td>
<td align=right><small>Current <font color="#0000ff">Out:</font><small></td>
<td align=right><small> <RRD::PRINT 10>B/s (<RRD::PRINT 11>%)</small></td>
</tr>
</table>
<hr>
<b>Monthly Graph (2 Hour Average)</b><br>
<RRD::GRAPH
/var/www/rrd-image/eth1-month.gif
--lazy
--imginfo '<img src="/rrd-image/%s" width=%lu height=%lu alt="Monthly Graph" vspace=10 align=top>'
-c FONT#000000 -c MGRID#000000 -c FRAME#000000 -c BACK#f5f5f5 -c ARROW#000000
-g -l 0 -b 1000
-w 400 -h 100
-v "Bytes per second"
-x WEEK:1:WEEK:1:WEEK:1:604800:"Week %W"
-s -3110400
DEF:in=/home/admin/rrd/network.rrd:eth1_in:AVERAGE
DEF:out=/home/admin/rrd/network.rrd:eth1_out:AVERAGE
DEF:maxin=/home/admin/rrd/network.rrd:eth1_in:MAX
DEF:maxout=/home/admin/rrd/network.rrd:eth1_out:MAX
CDEF:out_pct=out,100,*,64000,/
CDEF:in_pct=in,100,*,64000,/
AREA:in#00cc00:In
LINE2:out#0000ff:Out
LINE1:maxin#006600:MaxIn
LINE1:maxout#ff00ff:MaxOut
HRULE:64000#cc0000
PRINT:in:MAX:"%.1lf %s"
PRINT:in_pct:MAX:%.1lf
PRINT:in:AVERAGE:"%.1lf %s"
PRINT:in_pct:AVERAGE:%.1lf
PRINT:in:LAST:"%.1lf %s"
PRINT:in_pct:LAST:%.1lf
PRINT:out:MAX:"%.1lf %s"
PRINT:out_pct:MAX:%.1lf
PRINT:out:AVERAGE:"%.1lf %s"
PRINT:out_pct:AVERAGE:%.1lf
PRINT:out:LAST:"%.1lf %s"
PRINT:out_pct:LAST:%.1lf
>
<table cellpadding=0 cellspacing=0>
<tr>
<td align=right><small>Max <font color="#00cc00">In:</font><small></td>
<td align=right><small> <RRD::PRINT 0>B/s (<RRD::PRINT 1>%)</small></td>
<td width=5></td>
<td align=right><small>Average <font color="#00cc00">In:</font><small></td>
<td align=right><small> <RRD::PRINT 2>B/s (<RRD::PRINT 3>%)</small></td>
<td width=5></td>
<td align=right><small>Current <font color="#00cc00">In:</font><small></td>
<td align=right><small> <RRD::PRINT 4>B/s (<RRD::PRINT 5>%)</small></td>
</tr>
<tr>
<td align=right><small>Max <font color="#0000ff">Out:</font><small></td>
<td align=right><small> <RRD::PRINT 6>B/s (<RRD::PRINT 7>%)</small></td>
<td width=5></td>
<td align=right><small>Average <font color="#0000ff">Out:</font><small></td>
<td align=right><small> <RRD::PRINT 8>B/s (<RRD::PRINT 9>%)</small></td>
<td width=5></td>
<td align=right><small>Current <font color="#0000ff">Out:</font><small></td>
<td align=right><small> <RRD::PRINT 10>B/s (<RRD::PRINT 11>%)</small></td>
</tr>
</table>
<hr>
<b>Yearly Graph (1 Day Average)</b><br>
<RRD::GRAPH
/var/www/rrd-image/eth1-year.gif
--lazy
--imginfo '<img src="/rrd-image/%s" width=%lu height=%lu alt="Monthly Graph" vspace=10 align=top>'
-c FONT#000000 -c MGRID#000000 -c FRAME#000000 -c BACK#f5f5f5 -c ARROW#000000
-g -l 0 -b 1000
-w 400 -h 100
-v "Bytes per second"
-s -34214400
DEF:in=/home/admin/rrd/network.rrd:eth1_in:AVERAGE
DEF:out=/home/admin/rrd/network.rrd:eth1_out:AVERAGE
DEF:maxin=/home/admin/rrd/network.rrd:eth1_in:MAX
DEF:maxout=/home/admin/rrd/network.rrd:eth1_out:MAX
CDEF:out_pct=out,100,*,64000,/
CDEF:in_pct=in,100,*,64000,/
AREA:in#00cc00:In
LINE2:out#0000ff:Out
LINE1:maxin#006600:MaxIn
LINE1:maxout#ff00ff:MaxOut
HRULE:64000#cc0000
PRINT:in:MAX:"%.1lf %s"
PRINT:in_pct:MAX:%.1lf
PRINT:in:AVERAGE:"%.1lf %s"
PRINT:in_pct:AVERAGE:%.1lf
PRINT:in:LAST:"%.1lf %s"
PRINT:in_pct:LAST:%.1lf
PRINT:out:MAX:"%.1lf %s"
PRINT:out_pct:MAX:%.1lf
PRINT:out:AVERAGE:"%.1lf %s"
PRINT:out_pct:AVERAGE:%.1lf
PRINT:out:LAST:"%.1lf %s"
PRINT:out_pct:LAST:%.1lf
>
<table cellpadding=0 cellspacing=0>
<tr>
<td align=right><small>Max <font color="#00cc00">In:</font><small></td>
<td align=right><small> <RRD::PRINT 0>B/s (<RRD::PRINT 1>%)</small></td>
<td width=5></td>
<td align=right><small>Average <font color="#00cc00">In:</font><small></td>
<td align=right><small> <RRD::PRINT 2>B/s (<RRD::PRINT 3>%)</small></td>
<td width=5></td>
<td align=right><small>Current <font color="#00cc00">In:</font><small></td>
<td align=right><small> <RRD::PRINT 4>B/s (<RRD::PRINT 5>%)</small></td>
</tr>
<tr>
<td align=right><small>Max <font color="#0000ff">Out:</font><small></td>
<td align=right><small> <RRD::PRINT 6>B/s (<RRD::PRINT 7>%)</small></td>
<td width=5></td>
<td align=right><small>Average <font color="#0000ff">Out:</font><small></td>
<td align=right><small> <RRD::PRINT 8>B/s (<RRD::PRINT 9>%)</small></td>
<td width=5></td>
<td align=right><small>Current <font color="#0000ff">Out:</font><small></td>
<td align=right><small> <RRD::PRINT 10>B/s (<RRD::PRINT 11>%)</small></td>
</tr>
</table>
<hr>
<table width=500 border=0 cellpadding=4 cellspacing=0>
<tr>
<td align=right><font size="-1" color="#00cc00"><b>GREEN ###</b></font></td>
<td><font size="-1">Incoming Traffic in Bytes per Second</font></td>
</tr>
<tr>
<td align=right><font size="-1" color="#0000ff"><b>BLUE ###</b></font></td>
<td><font size="-1">Outgoing Traffic in Bytes per Second</font></td>
</tr>
<tr>
<td align=right><font size="-1" color="#006600"><b>DARK GREEN ###</b></font></td>
<td><font size="-1">Peak Incoming Traffic in Bytes per Second</font></td>
</tr>
<tr>
<td align=right><font size="-1" color="#ff00ff"><b>MAGENTA ###</b></font></td>
<td><font size="-1">Peak Outgoing Traffic in Bytes per Second</font></td>
</tr>
</table>
</body>
</html>
------------------------------------------------------------------------
Regards,
-- Zakaria
Private: z4k4ri4 at bigfoot.com Yahoo!: z4k4ri4
http://pemula.linux.or.id
--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the rrd-users
mailing list