[rrd-users] Calculation that is a bit over my head.
Simon Hobson
simon at thehobsons.co.uk
Tue Nov 26 14:23:24 CET 2013
Jan Johansson wrote:
>I do not suppose there is any "magic" subsitution for replacing (in this case) 86400 with "The number of seconds between -s and -e params?
As I said, I script generate my graphs (actually, they are CGI scripts written in Bash). So I have something along the lines of :
case <something> in
<something> Scale=86400
Step=300
<other stuff> ;;
<something> Scale=604800
Step=1800
<other stuff> ;;
Now=$( date +%s )
End=$(( ${Now} / ${Step} * ${Step} ))
Start=$(( ${End} - ${Scale} ))
echo "<stuff> --start=${Start} --end=${End}
<more stuff>" | rrdtoolcgi >/dev/null 2>&1
So basically, I have a url ending with <something>.cgi?scale=day&<other options>. The Case statement picks up the options and sets various things like the overall timescale, step size, textual representation of the timescale to go in the graph title and so on. Some of the options alter the graph, I at some point I might have :
if [ "${Max}" = "On" ]
then
echo "<some more stuff to draw a max line on the graph>"
I have other graphs with a variable number of elements, so I have something like :
for IP in ${IPList}
do
echo <stuff to stack per-IP traffic>
So I have to hand craft and hard code the bulk of the graph, but all the options like start and end times graph title etc are shell variables and inserted by variable expansion.
More information about the rrd-users
mailing list