--start -1d gives a graph of the last day; --start -1w gives a graph of the last week; --start -1m gives a graph of the last month; --start -1y gives a graph of the last year; #! /bin/sh cd /var/log/rrd rrds=`find . -type f -name '*.rrd' | cut -c3-` for i in $rrds; do j=`echo $i | sed 's/.rrd//'` rrdtool graph /var/www/rrd/$j-day.png --start -1d DEF:pkt=$i:packet:AVERAGE LINE1:pkt#ff0000:Packets/sec rrdtool graph /var/www/rrd/$j-week.png --start -1w DEF:pkt=$i:packet:AVERAGE LINE1:pkt#ff0000:Packets/sec rrdtool graph /var/www/rrd/$j-month.png --start -1m DEF:pkt=$i:packet:AVERAGE LINE1:pkt#ff0000:Packets/sec rrdtool graph /var/www/rrd/$j-year.png --start -1y DEF:pkt=$i:packet:AVERAGE LINE1:pkt#ff0000:Packets/sec done cd -
--start "yesterday" --start "-1month" --start "-2weeks" --start "-1year" --start -86400 (24*60*60=86400)
end
rrdtool graph graph.png --title="Test Graph" --start=0 --end=start+86400 --width=800 DEF:pkt=datafile.rrd:packets:AVERAGE \ LINE1:pkt#ff0000:Packets
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。