#! /bin/sh
HOSTNAME=TEST
NOW=`date +%s`
ONE_5_min_AGO=$(($NOW-600))
ONE_DAY_AGO=$(($NOW-86400))
ONE_WEEK_AGO=$(($NOW-604800))
ONE_MONTH_AGO=$(($NOW-2419200))
ONE_YEAR_AGO=$(($NOW-29030400))
TIMESTAMP="Generated on `date`"function draw_graphic()
{
/usr/local/rrdtool-1.2.11/bin/rrdtool graph /`pwd`/$1 -s $2 -e $3 -R normal -E -a PNG -t "$5" -v "Bytes Per Second" -F \
DEF:output=$RRDB:ds1:AVERAGE \
DEF:input=$RRDB:ds0:AVERAGE \
CDEF:kbpsout=output,8,* \
CDEF:kbpsin=input,8,* \
-w 500 -h 100 \
AREA:kbpsout#00CC00:OUT \
GPRINT:kbpsout:LAST:"Cur%8.2lf%s" \
GPRINT:kbpsout:AVERAGE:"Ave%8.2lf%s" \
GPRINT:kbpsout:MAX:"Max%8.2lf%s" \
GPRINT:kbpsout:MIN:"Min%8.2lf%s" \
COMMENT:" " \
LINE0.9:kbpsin#0000FF:INB \
GPRINT:kbpsin:LAST:" Cur%8.2lf%s" \
GPRINT:kbpsin:AVERAGE:" Ave%8.2lf%s" \
GPRINT:kbpsin:MAX:" Max%8.2lf%s" \
GPRINT:kbpsin:MIN:" Min%8.2lf%s"
}
cd /home/httpd/html/mrtg/cisco1;
rm data
for file in *.rrd
do echo "$file">>data
done
declare -a array1
array1=( `cat data | tr '\n' ' '` )
element_count=${#array1[*]}
i=$element_count
a=0
LIMIT=$i
while [ $a -le "$LIMIT" ]
do
graph_pref=`ls ${array1[$a]} | sed 's/.rrd//g'`
day_grap=$graph_pref-day.png
week_grap=$graph_pref-week.png
month_grap=$graph_pref-month.png
year_grap=$graph_pref-year.png
RRDB=`pwd`/${array1[$a]}
draw_graphic $day_grap $ONE_DAY_AGO $NOW "$HOSTNAME (last 24 hours TEST)" "$TIMESTAMP"
draw_graphic $week_grap $ONE_WEEK_AGO $NOW "$HOSTNAME (last week)" "$TIMESTAMP"
draw_graphic $month_grap $ONE_MONTH_AGO $NOW "$HOSTNAME (last month)" "$TIMESTAMP"
draw_graphic $year_grap $ONE_YEAR_AGO $NOW "$HOSTNAME (last year)" "$TIMESTAMP"
a=$(($a+1))
if [ $a -eq "$LIMIT" ]
then
break
fi
Меняем cd /home/httpd/html/mrtg/cisco1; на путь к файлам .rrd. Рисует графики в тойже самой дире что указана в cd.
Часть взята из какойто статейки. Часть за пару минут придумана. Пашет у меня уже год.