slitaz-forge rev 241

tank: use include and create rrd dirs
author Christophe Lincoln <pankso@slitaz.org>
date Sat Apr 07 22:31:56 2012 +0200 (2012-04-07)
parents 49aa1db4bf6e
children ea25c1734c9b
files tank/Makefile tank/files/var/spool/cron/crontabs/root tank/web/bin/makegraphs tank/web/graphs.php tank/web/index.php tank/web/lib/html/footer.html tank/web/lib/html/header.html tank/web/lib/makegraphs
line diff
     1.1 --- a/tank/Makefile	Sat Apr 07 22:17:45 2012 +0200
     1.2 +++ b/tank/Makefile	Sat Apr 07 22:31:56 2012 +0200
     1.3 @@ -3,12 +3,15 @@
     1.4  #
     1.5  PREFIX?=/usr
     1.6  DESTDIR?=
     1.7 -	
     1.8 +WEB?=/home/slitaz/www
     1.9 +
    1.10  all:
    1.11  
    1.12  install:
    1.13  	mkdir -p $(DESTDIR)$(PREFIX)/bin \
    1.14 -		$(DESTDIR)$(PREFIX)/share
    1.15 +		$(DESTDIR)$(PREFIX)/share \
    1.16 +		$(WEB)/tank/log/rrd \
    1.17 +		$(WEB)/tank/images/rrd
    1.18  	cp -f tank $(DESTDIR)$(PREFIX)/bin
    1.19  	cp -a files/var $(DESTDIR)/
    1.20  	chmod 0600 $(DESTDIR)/var/spool/cron/crontabs/root
     2.1 --- a/tank/files/var/spool/cron/crontabs/root	Sat Apr 07 22:17:45 2012 +0200
     2.2 +++ b/tank/files/var/spool/cron/crontabs/root	Sat Apr 07 22:31:56 2012 +0200
     2.3 @@ -2,7 +2,7 @@
     2.4  #
     2.5  
     2.6  # Update http://tank.slitaz.org/graphs.php pictures
     2.7 -*/5 * * * * /home/slitaz/www/tank/bin/makegraphs >/dev/null
     2.8 +*/5 * * * * /home/slitaz/www/tank/lib/makegraphs >/dev/null
     2.9  
    2.10  # Check Internet access
    2.11  #*/5 * * * * /usr/bin/chkwan
     3.1 --- a/tank/web/bin/makegraphs	Sat Apr 07 22:17:45 2012 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,327 +0,0 @@
     3.4 -#!/bin/sh
     3.5 -#*/5  * * * * /home/slitaz/www/tank/bin/makegraphs >/dev/null
     3.6 -
     3.7 -# RRD database directory
     3.8 -rrdlog="/home/slitaz/www/tank/rrd"
     3.9 -
    3.10 -# Images directory
    3.11 -rrdgraph="/home/slitaz/www/tank/pics/rrd"
    3.12 -
    3.13 -# Colors
    3.14 -rrdcolors="--color SHADEA#FFFFFF --color SHADEB#FFFFFF --color BACK#FFFFFF" 
    3.15 -rrdgraphargs="-aPNG -i -z --alt-y-grid -w 600 -h 100 -r $rrdcolors"
    3.16 -
    3.17 -[ -d $rrdlog ] || mkdir -p $rrdlog
    3.18 -[ -d $rrdgraph ] || mkdir -p $rrdgraph
    3.19 -
    3.20 -updatecpudata() {
    3.21 -	[ -e "$rrdlog/cpu.rrd" ] || rrdtool create $rrdlog/cpu.rrd --step=300 \
    3.22 -			DS:user:COUNTER:600:0:500000000 \
    3.23 -			DS:nice:COUNTER:600:0:500000000 \
    3.24 -			DS:system:COUNTER:600:0:500000000 \
    3.25 -			DS:idle:COUNTER:600:0:500000000 \
    3.26 -			DS:iowait:COUNTER:600:0:500000000 \
    3.27 -			DS:irq:COUNTER:600:0:500000000 \
    3.28 -			DS:softirq:COUNTER:600:0:500000000 \
    3.29 -			DS:celsius:GAUGE:600:0:50000 \
    3.30 -			RRA:AVERAGE:0.5:1:576  RRA:AVERAGE:0.5:6:672 \
    3.31 -			RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
    3.32 -	grep '^cpu' /proc/stat | while read cpu user nice system idle iowait irq softirq misc; do
    3.33 -		celsius=$(find /sys | grep /temp._input | xargs cat | \
    3.34 -			awk '{ if ($0 > max) max=$0 } END { print max/1 }')
    3.35 -		rrdtool update $rrdlog/cpu.rrd \
    3.36 -			-t celsius:nice:user:system:idle:iowait:irq:softirq \
    3.37 -			N:$celsius:$nice:$user:$system:$idle:$iowait:$irq:$softirq
    3.38 -		break
    3.39 -	done
    3.40 -}
    3.41 -
    3.42 -updatecpugraph() {
    3.43 -	period=$1
    3.44 -	info="$(grep '^model name' /proc/cpuinfo | cut -d: -f2 \
    3.45 -		| sed 's/ * / /g' | awk '
    3.46 -{ s=$0 ; n++ }                    
    3.47 -END { if (n > 1) printf " %dx",n; print s }')"
    3.48 -	rrdtool graph "$rrdgraph/cpu-$period.png" --start -1$period \
    3.49 -		$rrdgraphargs -l 0 -u 100 -t "cpu usage per $period [$info ]" \
    3.50 -		DEF:user=$rrdlog/cpu.rrd:user:AVERAGE \
    3.51 -		DEF:system=$rrdlog/cpu.rrd:system:AVERAGE \
    3.52 -		DEF:idle=$rrdlog/cpu.rrd:idle:AVERAGE \
    3.53 -		DEF:nice=$rrdlog/cpu.rrd:nice:AVERAGE \
    3.54 -		DEF:celsius=$rrdlog/cpu.rrd:celsius:AVERAGE \
    3.55 -		'CDEF:total=user,system,idle,nice,+,+,+' \
    3.56 -		'CDEF:userpct=100,user,total,/,*' \
    3.57 -		'CDEF:systempct=100,system,total,/,*' \
    3.58 -		'CDEF:idlepct=100,idle,total,/,*' \
    3.59 -		'CDEF:nicepct=100,nice,total,/,*' \
    3.60 -		'CDEF:temp=celsius,1000,/' \
    3.61 -		'AREA:userpct#0000FF:user cpu usage' \
    3.62 -		'STACK:nicepct#C0C0FF:nice cpu usage' \
    3.63 -		'STACK:systempct#FF0000:system cpu usage' \
    3.64 -		'STACK:idlepct#00FF00:idle cpu usage' \
    3.65 -		'LINE1:temp#000000:temperature\g' \
    3.66 -		'GPRINT:temp:MAX:max %2.0lfC\j'
    3.67 -}
    3.68 -
    3.69 -updatememgraph() {
    3.70 -	period=$1
    3.71 -	info="$(free | awk '\
    3.72 -{ \
    3.73 -  if (/Mem:/) { \
    3.74 -	if ($2 < 10000) printf "%d KB",$2; \
    3.75 -	else if ($2 < 10000000) printf "%d MB",$2/1024; \
    3.76 -	else printf "%d GB",$2/1024/1024; \
    3.77 -  } \
    3.78 -}')"
    3.79 -	info2="$(free | awk '\
    3.80 -{ \
    3.81 -  if (/Swap:/) { \
    3.82 -	if ($2 < 10000) printf "%d KB",$2; \
    3.83 -	else if ($2 < 10000000) printf "%d MB",$2/1024; \
    3.84 -	else printf "%d GB",$2/1024/1024; \
    3.85 -  } \
    3.86 -}')"
    3.87 -	rrdtool graph "$rrdgraph/memory-$period.png" --start -1$period \
    3.88 -		$rrdgraphargs -l 0 -u 100 \
    3.89 -		-t "memory usage per $period [ $info + $info2 swap ]" \
    3.90 -		DEF:used=$rrdlog/mem.rrd:memused:AVERAGE \
    3.91 -		DEF:free=$rrdlog/mem.rrd:memfree:AVERAGE \
    3.92 -		DEF:shared=$rrdlog/mem.rrd:memshared:AVERAGE \
    3.93 -		DEF:buffer=$rrdlog/mem.rrd:membuffers:AVERAGE \
    3.94 -		DEF:cache=$rrdlog/mem.rrd:memcache:AVERAGE \
    3.95 -		DEF:swused=$rrdlog/mem.rrd:swapused:AVERAGE \
    3.96 -		DEF:swfree=$rrdlog/mem.rrd:swapfree:AVERAGE \
    3.97 -		'CDEF:total=used,free,+' \
    3.98 -		'CDEF:used2=used,buffer,cache,shared,+,+,-' \
    3.99 -		'CDEF:usedpct=100,used2,total,/,*' \
   3.100 -		'CDEF:sharedpct=100,shared,total,/,*' \
   3.101 -		'CDEF:bufferpct=100,buffer,total,/,*' \
   3.102 -		'CDEF:cachepct=100,cache,total,/,*' \
   3.103 -		'CDEF:freepct=100,free,total,/,*' \
   3.104 -		'CDEF:swtotal=swused,swfree,+' \
   3.105 -		'CDEF:swusedpct=100,swused,swtotal,/,*' \
   3.106 -		'AREA:usedpct#0000FF:used memory' \
   3.107 -		'STACK:sharedpct#FF7F00:shared memory' \
   3.108 -		'STACK:bufferpct#FF00FF:buffered memory' \
   3.109 -		'STACK:cachepct#FFFF00:cached memory' \
   3.110 -		'STACK:freepct#00FF00:free memory' \
   3.111 -		'LINE2:swusedpct#FF0000:used swap\j'
   3.112 -}
   3.113 -
   3.114 -updatememdata () {
   3.115 -	[ -e "$rrdlog/mem.rrd" ] ||
   3.116 -		rrdtool create "$rrdlog/mem.rrd" --step=300 \
   3.117 -			DS:memused:ABSOLUTE:600:0:5000000000 \
   3.118 -			DS:memfree:ABSOLUTE:600:0:5000000000 \
   3.119 -			DS:memshared:ABSOLUTE:600:0:5000000000 \
   3.120 -			DS:membuffers:ABSOLUTE:600:0:5000000000 \
   3.121 -			DS:memcache:ABSOLUTE:600:0:5000000000 \
   3.122 -			DS:swapused:ABSOLUTE:600:0:5000000000 \
   3.123 -			DS:swapfree:ABSOLUTE:600:0:5000000000 \
   3.124 -			RRA:AVERAGE:0.5:1:576  RRA:AVERAGE:0.5:6:672 \
   3.125 -			RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
   3.126 -
   3.127 -	while read tag count unit; do
   3.128 -		case "$tag" in
   3.129 -		MemTotal:)  memtotal=$count;;
   3.130 -		MemFree:)   memfree=$count
   3.131 -			    memused=$(($memtotal - $memfree))
   3.132 -			    memshared=0;;
   3.133 -		MemShared:) memshared=$count;;
   3.134 -		Buffers:)   membuffers=$count;;
   3.135 -		Cached:)    memcache=$count;;
   3.136 -		SwapTotal:) swaptotal=$count;;
   3.137 -		SwapFree:)  swapfree=$count
   3.138 -			    swapused=$(( $swaptotal - $swapfree));;
   3.139 -		esac
   3.140 -	done < /proc/meminfo
   3.141 -
   3.142 -	rrdtool update "$rrdlog/mem.rrd" \
   3.143 -		-t memused:memfree:memshared:membuffers:memcache:swapused:swapfree \
   3.144 -		"N:$memused:$memfree:$memshared:$membuffers:$memcache:$swapused:$swapfree"
   3.145 -}
   3.146 -
   3.147 -getmax() {
   3.148 -	rrdtool fetch $rrdlog/$1.rrd AVERAGE | awk '\
   3.149 -BEGIN {max=0} \
   3.150 -/^[0-9]/ { \
   3.151 -   if ($2 != "nan" && $2 > max) max=$2; \
   3.152 -   if ($3 != "nan" && $3 > max) max=$3; \
   3.153 -} \
   3.154 -END { print max }' | sed 's/,/./'
   3.155 -}
   3.156 -
   3.157 -updatediskgraph() {
   3.158 -	period=$1
   3.159 -	[ "$period" == "day" ] && maxdisk="$(getmax disk)"
   3.160 -	info=""
   3.161 -	[ -r $2 ] &&
   3.162 -	info="[ $(fdisk -l 2> /dev/null | grep "^Disk $2:" | \
   3.163 -		  sed "s|Disk $2: \(.*\), .*|\1|") ]"
   3.164 -	if [ -e /sys/block/${2#/dev/}/device/iodone_cnt ]; then
   3.165 -	err=$(printf "%d\n" $(cat /sys/block/${2#/dev/}/device/ioerr_cnt) )
   3.166 -	done=$(printf "%d\n" $(cat /sys/block/${2#/dev/}/device/iodone_cnt) )
   3.167 -	rate=$(echo | awk "BEGIN { printf \"%.0e\\n\",$err/$done }")
   3.168 -	[ $err -eq 0 ] &&  rate="0"
   3.169 -#		--right-axis-label "I/O state %"
   3.170 -	rrdtool graph "$rrdgraph/disk-$period.png" --start -1$period \
   3.171 -		$rrdgraphargs -t "disk access per $period $info" \
   3.172 -		--logarithmic --lower-limit 1 -v "Sectors/second" --units=si \
   3.173 -		DEF:read=$rrdlog/disk.rrd:readsect:AVERAGE \
   3.174 -		DEF:write=$rrdlog/disk.rrd:writesect:AVERAGE \
   3.175 -		DEF:req=$rrdlog/iodisk.rrd:req:AVERAGE \
   3.176 -		DEF:done=$rrdlog/iodisk.rrd:done:AVERAGE \
   3.177 -		DEF:err=$rrdlog/iodisk.rrd:err:AVERAGE \
   3.178 -		"CDEF:readpct=100,read,$maxdisk,/,*" \
   3.179 -		"CDEF:writepct=100,write,$maxdisk,/,*" \
   3.180 -		"CDEF:errpct=100,err,req,/,*" \
   3.181 -		"CDEF:donepct=100,done,req,/,*" \
   3.182 -		"CDEF:errrate=err,done,/" \
   3.183 -		'AREA:readpct#0000FF:sectors read from disk' \
   3.184 -		"COMMENT:I/O error rate $rate" \
   3.185 -		'STACK:writepct#00FF00:sectors written to disk' \
   3.186 -		'LINE2:donepct#FFFF00:% I/O complete' \
   3.187 -		'LINE2:errpct#FF0000:% I/O error\j'
   3.188 -	else
   3.189 -	rrdtool graph "$rrdgraph/disk-$period.png" --start -1$period \
   3.190 -		$rrdgraphargs -t "disk access per $period $info" \
   3.191 -		--logarithmic --lower-limit 1 -v "Sectors/second" --units=si \
   3.192 -		DEF:read=$rrdlog/disk.rrd:readsect:AVERAGE \
   3.193 -		DEF:write=$rrdlog/disk.rrd:writesect:AVERAGE \
   3.194 -		"CDEF:readpct=100,read,$maxdisk,/,*" \
   3.195 -		"CDEF:writepct=100,write,$maxdisk,/,*" \
   3.196 -		'AREA:readpct#0000FF:sectors read from disk' \
   3.197 -		'STACK:writepct#00FF00:sectors written to disk'
   3.198 -	fi
   3.199 -}
   3.200 -
   3.201 -updatediskdata() {
   3.202 -	dev=$1
   3.203 -	[ -e "$rrdlog/disk.rrd" ] ||
   3.204 -		rrdtool create "$rrdlog/disk.rrd" --step=300 \
   3.205 -			DS:readsect:COUNTER:600:0:5000000000 \
   3.206 -			DS:writesect:COUNTER:600:0:5000000000 \
   3.207 -			RRA:AVERAGE:0.5:1:576  RRA:AVERAGE:0.5:6:672 \
   3.208 -			RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
   3.209 -	[ -e "$rrdlog/iodisk.rrd" ] ||
   3.210 -		rrdtool create "$rrdlog/iodisk.rrd" --step=300 \
   3.211 -			DS:done:GAUGE:600:0:U  DS:err:GAUGE:600:0:U \
   3.212 -			DS:req:GAUGE:600:0:U \
   3.213 -			RRA:AVERAGE:0.5:1:576  RRA:AVERAGE:0.5:6:672 \
   3.214 -			RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
   3.215 -
   3.216 -	while read major minor name readreq readsect writereq writesect misc; do
   3.217 -		[ $major = $(( 0x$(stat -c %t $dev) )) ] || continue
   3.218 -		[ $minor = $(( 0x$(stat -c %T $dev) )) ] || continue
   3.219 -		rrdtool update "$rrdlog/disk.rrd" -t readsect:writesect \
   3.220 -			N:$readsect:$writesect
   3.221 -	done < /proc/diskstats
   3.222 -	disk=${dev:0:8}
   3.223 -	dir=/sys/block/${disk#/dev/}/device
   3.224 -	done=$(printf "%d\n" $(cat $dir/iodone_cnt 2> /dev/null) )
   3.225 -	err=$(printf "%d\n" $(cat $dir/ioerr_cnt 2> /dev/null) )
   3.226 -	req=$(printf "%d\n" $(cat $dir/iorequest_cnt 2> /dev/null) )
   3.227 -	rrdtool update "$rrdlog/iodisk.rrd" -t done:err:req N:$done:$err:$req
   3.228 -}
   3.229 -
   3.230 -updateifgraph() {
   3.231 -	interface=$1
   3.232 -	period=$2
   3.233 -	rrdtool graph "$rrdgraph/$interface-$period.png" --start -1$period \
   3.234 -		$rrdgraphargs -t "traffic on $interface graph per $period" \
   3.235 -		--logarithmic -A -v "Bytes/second" --units=si \
   3.236 -		DEF:incoming=$rrdlog/$interface.rrd:incoming:AVERAGE \
   3.237 -		DEF:outgoing=$rrdlog/$interface.rrd:outgoing:AVERAGE \
   3.238 -		'AREA:incoming#00FF00:incoming traffic' \
   3.239 -		'GPRINT:incoming:MAX:max input%8.3lf %sBps' \
   3.240 -		'GPRINT:outgoing:MAX:max output%8.3lf %sBps' \
   3.241 -		'LINE1:outgoing#0000FF:outgoing traffic\j'
   3.242 -}
   3.243 -
   3.244 -netframes() {
   3.245 -ifconfig $1 | grep "$2 packets" | sed -re "s/.*$3:([0-9]+).*/\1/g"
   3.246 -}
   3.247 -
   3.248 -netstats() {
   3.249 -ifconfig $1 | grep bytes | sed -re "s/.*$2 bytes:([0-9]+).*/\1/g"
   3.250 -}
   3.251 -
   3.252 -updateifdata() {
   3.253 -	interface=$1
   3.254 -	[ -e "$rrdlog/$interface.rrd" ] ||
   3.255 -		rrdtool create "$rrdlog/$interface.rrd" --step=300 \
   3.256 -			DS:incoming:COUNTER:600:0:U \
   3.257 -			DS:outgoing:COUNTER:600:0:U \
   3.258 -			RRA:AVERAGE:0.5:1:576  RRA:AVERAGE:0.5:6:672 \
   3.259 -			RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
   3.260 -	[ -e "$rrdlog/packets-$interface.rrd" ] ||
   3.261 -		rrdtool create "$rrdlog/packets-$interface.rrd" --step=300 \
   3.262 -			DS:in:COUNTER:600:0:U      DS:out:COUNTER:600:0:U \
   3.263 -			DS:inerr:COUNTER:600:0:U   DS:outerr:COUNTER:600:0:U \
   3.264 -			DS:indrop:COUNTER:600:0:U  DS:outdrop:COUNTER:600:0:U \
   3.265 -			DS:inov:COUNTER:600:0:U    DS:outov:COUNTER:600:0:U \
   3.266 -			DS:frame:COUNTER:600:0:U   DS:carrier:COUNTER:600:0:U \
   3.267 -			RRA:AVERAGE:0.5:1:576  RRA:AVERAGE:0.5:6:672 \
   3.268 -			RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
   3.269 -	rx=$(netstats $interface RX)
   3.270 -	tx=$(netstats $interface TX)
   3.271 -	rrdtool update "$rrdlog/$interface.rrd" -t incoming:outgoing \
   3.272 -		N:${rx:-U}:${tx:-U}
   3.273 -	rx=$(netframes $interface RX packets)
   3.274 -	tx=$(netframes $interface TX packets)
   3.275 -	rxerr=$(netframes $interface RX errors)
   3.276 -	txerr=$(netframes $interface TX errors)
   3.277 -	rxdrop=$(netframes $interface RX dropped)
   3.278 -	txdrop=$(netframes $interface TX dropped)
   3.279 -	rxov=$(netframes $interface RX overruns)
   3.280 -	txov=$(netframes $interface TX overruns)
   3.281 -	frame=$(netframes $interface RX frame)
   3.282 -	carrier=$(netframes $interface TX carrier)
   3.283 -	rrdtool update "$rrdlog/packets-$interface.rrd" \
   3.284 -		-t in:out:inerr:outerr:indrop:outdrop:inov:outov:frame:carrier \
   3.285 -		N:${rx:-U}:${tx:-U}:${rxerr:-U}:${txerr:-U}:${rxdrop:-U}:${txdrop:-U}:${rxov:-U}:${txov:-U}:${frame:-U}:${carrier:-U}
   3.286 -}
   3.287 -
   3.288 -getdisk()
   3.289 -{
   3.290 -	local d
   3.291 -	local i
   3.292 -	d=$(stat -c %04D $1)
   3.293 -	for i in /dev/* ; do 
   3.294 -		[ $(stat -c "%02t%02T" $i) == $d ] || continue
   3.295 -		echo $i
   3.296 -		break
   3.297 -	done
   3.298 -}
   3.299 -
   3.300 -###
   3.301 -### System graphs
   3.302 -###
   3.303 -
   3.304 -updatecpudata
   3.305 -updatecpugraph day
   3.306 -updatecpugraph week
   3.307 -updatecpugraph month
   3.308 -updatecpugraph year
   3.309 -
   3.310 -updatememdata
   3.311 -updatememgraph day
   3.312 -updatememgraph week
   3.313 -updatememgraph month
   3.314 -updatememgraph year
   3.315 -
   3.316 -if [ -e /proc/diskstats ]; then
   3.317 -	disk=$(getdisk $0)
   3.318 -	updatediskdata $disk
   3.319 -	updatediskgraph day ${disk:0:8}
   3.320 -	updatediskgraph week ${disk:0:8}
   3.321 -	updatediskgraph month ${disk:0:8}
   3.322 -	updatediskgraph year ${disk:0:8}
   3.323 -fi
   3.324 -
   3.325 -iface=$(/sbin/route -n | awk '{ if (/^0.0.0.0/) print $8 }')
   3.326 -updateifdata $iface
   3.327 -updateifgraph $iface day
   3.328 -updateifgraph $iface week
   3.329 -updateifgraph $iface month
   3.330 -updateifgraph $iface year
     4.1 --- a/tank/web/graphs.php	Sat Apr 07 22:17:45 2012 +0200
     4.2 +++ b/tank/web/graphs.php	Sat Apr 07 22:31:56 2012 +0200
     4.3 @@ -12,23 +12,7 @@
     4.4  </head>
     4.5  <body>
     4.6  
     4.7 -<!-- Header -->
     4.8 -<div id="header">
     4.9 -	<div id="logo"></div>
    4.10 -	<div id="network">
    4.11 -		<a href="http://www.slitaz.org/">
    4.12 -			<img src="images/home.png" alt="[ Home ]" /></a>
    4.13 -		<a href="http://scn.slitaz.org/">Community</a>
    4.14 -		<a href="http://doc.slitaz.org/">Doc</a>
    4.15 -		<a href="http://forum.slitaz.org/">Forum</a>
    4.16 -		<a href="http://slitaz.pro/">Pro</a>
    4.17 -		<a href="http://slitaz.spreadshirt.net/">Shop</a>
    4.18 -		<a href="http://bugs.slitaz.org">Bugs</a>
    4.19 -		<a href="http://hg.slitaz.org/">Hg</a>
    4.20 -		<a href="http://cook.slitaz.org/">Cook</a>
    4.21 -	</div>
    4.22 -	<h1><a href="http://tank.slitaz.org/">SliTaz Tank</a></h1>
    4.23 -</div>
    4.24 +<?php include("lib/html/header.html"); ?>
    4.25  
    4.26  <!-- Block -->
    4.27  <div id="block">
    4.28 @@ -107,25 +91,7 @@
    4.29  <!-- End of content -->
    4.30  </div>
    4.31  
    4.32 -<!-- Footer -->
    4.33 -<div id="footer">
    4.34 -	Copyright &copy; <span class="year"></span>
    4.35 -	<a href="http://www.slitaz.org/">SliTaz</a> - Network:
    4.36 -	<a href="http://scn.slitaz.org/">Community</a>
    4.37 -	<a href="http://doc.slitaz.org/">Doc</a>
    4.38 -	<a href="http://forum.slitaz.org/">Forum</a>
    4.39 -	<a href="http://pkgs.slitaz.org/">Packages</a>
    4.40 -	<a href="http://bugs.slitaz.org">Bugs</a>
    4.41 -	<a href="http://hg.slitaz.org/">Hg</a>
    4.42 -	<p>
    4.43 -		SliTaz @
    4.44 -		<a href="http://twitter.com/slitaz">Twitter</a>
    4.45 -		<a href="http://www.facebook.com/slitaz">Facebook</a>
    4.46 -		<a href="http://distrowatch.com/slitaz">Distrowatch</a>
    4.47 -		<a href="http://en.wikipedia.org/wiki/SliTaz">Wikipedia</a>
    4.48 -		<a href="http://flattr.com/profile/slitaz">Flattr</a>
    4.49 -	</p>
    4.50 -</div>
    4.51 +<?php include("lib/html/footer.html"); ?>
    4.52  
    4.53  </body>
    4.54  </html>
     5.1 --- a/tank/web/index.php	Sat Apr 07 22:17:45 2012 +0200
     5.2 +++ b/tank/web/index.php	Sat Apr 07 22:31:56 2012 +0200
     5.3 @@ -12,23 +12,7 @@
     5.4  </head>
     5.5  <body>
     5.6  
     5.7 -<!-- Header -->
     5.8 -<div id="header">
     5.9 -	<div id="logo"></div>
    5.10 -	<div id="network">
    5.11 -		<a href="http://www.slitaz.org/">
    5.12 -			<img src="images/home.png" alt="[ Home ]" /></a>
    5.13 -		<a href="http://scn.slitaz.org/">Community</a>
    5.14 -		<a href="http://doc.slitaz.org/">Doc</a>
    5.15 -		<a href="http://forum.slitaz.org/">Forum</a>
    5.16 -		<a href="http://slitaz.pro/">Pro</a>
    5.17 -		<a href="http://slitaz.spreadshirt.net/">Shop</a>
    5.18 -		<a href="http://bugs.slitaz.org">Bugs</a>
    5.19 -		<a href="http://hg.slitaz.org/">Hg</a>
    5.20 -		<a href="http://cook.slitaz.org/">Cook</a>
    5.21 -	</div>
    5.22 -	<h1><a href="http://tank.slitaz.org/">SliTaz Tank</a></h1>
    5.23 -</div>
    5.24 +<?php include("lib/html/header.html"); ?>
    5.25  
    5.26  <!-- Block -->
    5.27  <div id="block">
    5.28 @@ -124,26 +108,7 @@
    5.29  <!-- End of content -->
    5.30  </div>
    5.31  
    5.32 -<!-- Footer -->
    5.33 -<div id="footer">
    5.34 -	Copyright &copy; <span class="year"></span>
    5.35 -	<a href="http://www.slitaz.org/">SliTaz</a> - Network:
    5.36 -	<a href="http://scn.slitaz.org/">Community</a>
    5.37 -	<a href="http://doc.slitaz.org/">Doc</a>
    5.38 -	<a href="http://forum.slitaz.org/">Forum</a>
    5.39 -	<a href="http://pkgs.slitaz.org/">Packages</a>
    5.40 -	<a href="http://boot.slitaz.org/">Boot</a>
    5.41 -	<a href="http://bugs.slitaz.org">Bugs</a>
    5.42 -	<a href="http://hg.slitaz.org/">Hg</a>
    5.43 -	<p>
    5.44 -		SliTaz @
    5.45 -		<a href="http://twitter.com/slitaz">Twitter</a>
    5.46 -		<a href="http://www.facebook.com/slitaz">Facebook</a>
    5.47 -		<a href="http://distrowatch.com/slitaz">Distrowatch</a>
    5.48 -		<a href="http://en.wikipedia.org/wiki/SliTaz">Wikipedia</a>
    5.49 -		<a href="http://flattr.com/profile/slitaz">Flattr</a>
    5.50 -	</p>
    5.51 -</div>
    5.52 +<?php include("lib/html/footer.html"); ?>
    5.53  
    5.54  </body>
    5.55  </html>
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/tank/web/lib/html/footer.html	Sat Apr 07 22:31:56 2012 +0200
     6.3 @@ -0,0 +1,19 @@
     6.4 +<!-- Footer -->
     6.5 +<div id="footer">
     6.6 +	Copyright &copy; <span class="year"></span>
     6.7 +	<a href="http://www.slitaz.org/">SliTaz</a> - Network:
     6.8 +	<a href="http://scn.slitaz.org/">Community</a>
     6.9 +	<a href="http://doc.slitaz.org/">Doc</a>
    6.10 +	<a href="http://forum.slitaz.org/">Forum</a>
    6.11 +	<a href="http://pkgs.slitaz.org/">Packages</a>
    6.12 +	<a href="http://bugs.slitaz.org">Bugs</a>
    6.13 +	<a href="http://hg.slitaz.org/">Hg</a>
    6.14 +	<p>
    6.15 +		SliTaz @
    6.16 +		<a href="http://twitter.com/slitaz">Twitter</a>
    6.17 +		<a href="http://www.facebook.com/slitaz">Facebook</a>
    6.18 +		<a href="http://distrowatch.com/slitaz">Distrowatch</a>
    6.19 +		<a href="http://en.wikipedia.org/wiki/SliTaz">Wikipedia</a>
    6.20 +		<a href="http://flattr.com/profile/slitaz">Flattr</a>
    6.21 +	</p>
    6.22 +</div>
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/tank/web/lib/html/header.html	Sat Apr 07 22:31:56 2012 +0200
     7.3 @@ -0,0 +1,17 @@
     7.4 +<!-- Header -->
     7.5 +<div id="header">
     7.6 +	<div id="logo"></div>
     7.7 +	<div id="network">
     7.8 +		<a href="http://www.slitaz.org/">
     7.9 +			<img src="images/home.png" alt="[ Home ]" /></a>
    7.10 +		<a href="http://scn.slitaz.org/">Community</a>
    7.11 +		<a href="http://doc.slitaz.org/">Doc</a>
    7.12 +		<a href="http://forum.slitaz.org/">Forum</a>
    7.13 +		<a href="http://slitaz.pro/">Pro</a>
    7.14 +		<a href="http://slitaz.spreadshirt.net/">Shop</a>
    7.15 +		<a href="http://bugs.slitaz.org">Bugs</a>
    7.16 +		<a href="http://hg.slitaz.org/">Hg</a>
    7.17 +		<a href="http://cook.slitaz.org/">Cook</a>
    7.18 +	</div>
    7.19 +	<h1><a href="http://tank.slitaz.org/">SliTaz Tank</a></h1>
    7.20 +</div>
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/tank/web/lib/makegraphs	Sat Apr 07 22:31:56 2012 +0200
     8.3 @@ -0,0 +1,327 @@
     8.4 +#!/bin/sh
     8.5 +#*/5  * * * * /home/slitaz/www/tank/lib/makegraphs >/dev/null
     8.6 +
     8.7 +# RRD database directory
     8.8 +rrdlog="/home/slitaz/www/tank/log/rrd"
     8.9 +
    8.10 +# Images directory
    8.11 +rrdgraph="/home/slitaz/www/tank/imgages/rrd"
    8.12 +
    8.13 +# Colors
    8.14 +rrdcolors="--color SHADEA#FFFFFF --color SHADEB#FFFFFF --color BACK#FFFFFF" 
    8.15 +rrdgraphargs="-aPNG -i -z --alt-y-grid -w 600 -h 100 -r $rrdcolors"
    8.16 +
    8.17 +[ -d $rrdlog ] || mkdir -p $rrdlog
    8.18 +[ -d $rrdgraph ] || mkdir -p $rrdgraph
    8.19 +
    8.20 +updatecpudata() {
    8.21 +	[ -e "$rrdlog/cpu.rrd" ] || rrdtool create $rrdlog/cpu.rrd --step=300 \
    8.22 +			DS:user:COUNTER:600:0:500000000 \
    8.23 +			DS:nice:COUNTER:600:0:500000000 \
    8.24 +			DS:system:COUNTER:600:0:500000000 \
    8.25 +			DS:idle:COUNTER:600:0:500000000 \
    8.26 +			DS:iowait:COUNTER:600:0:500000000 \
    8.27 +			DS:irq:COUNTER:600:0:500000000 \
    8.28 +			DS:softirq:COUNTER:600:0:500000000 \
    8.29 +			DS:celsius:GAUGE:600:0:50000 \
    8.30 +			RRA:AVERAGE:0.5:1:576  RRA:AVERAGE:0.5:6:672 \
    8.31 +			RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
    8.32 +	grep '^cpu' /proc/stat | while read cpu user nice system idle iowait irq softirq misc; do
    8.33 +		celsius=$(find /sys | grep /temp._input | xargs cat | \
    8.34 +			awk '{ if ($0 > max) max=$0 } END { print max/1 }')
    8.35 +		rrdtool update $rrdlog/cpu.rrd \
    8.36 +			-t celsius:nice:user:system:idle:iowait:irq:softirq \
    8.37 +			N:$celsius:$nice:$user:$system:$idle:$iowait:$irq:$softirq
    8.38 +		break
    8.39 +	done
    8.40 +}
    8.41 +
    8.42 +updatecpugraph() {
    8.43 +	period=$1
    8.44 +	info="$(grep '^model name' /proc/cpuinfo | cut -d: -f2 \
    8.45 +		| sed 's/ * / /g' | awk '
    8.46 +{ s=$0 ; n++ }                    
    8.47 +END { if (n > 1) printf " %dx",n; print s }')"
    8.48 +	rrdtool graph "$rrdgraph/cpu-$period.png" --start -1$period \
    8.49 +		$rrdgraphargs -l 0 -u 100 -t "cpu usage per $period [$info ]" \
    8.50 +		DEF:user=$rrdlog/cpu.rrd:user:AVERAGE \
    8.51 +		DEF:system=$rrdlog/cpu.rrd:system:AVERAGE \
    8.52 +		DEF:idle=$rrdlog/cpu.rrd:idle:AVERAGE \
    8.53 +		DEF:nice=$rrdlog/cpu.rrd:nice:AVERAGE \
    8.54 +		DEF:celsius=$rrdlog/cpu.rrd:celsius:AVERAGE \
    8.55 +		'CDEF:total=user,system,idle,nice,+,+,+' \
    8.56 +		'CDEF:userpct=100,user,total,/,*' \
    8.57 +		'CDEF:systempct=100,system,total,/,*' \
    8.58 +		'CDEF:idlepct=100,idle,total,/,*' \
    8.59 +		'CDEF:nicepct=100,nice,total,/,*' \
    8.60 +		'CDEF:temp=celsius,1000,/' \
    8.61 +		'AREA:userpct#0000FF:user cpu usage' \
    8.62 +		'STACK:nicepct#C0C0FF:nice cpu usage' \
    8.63 +		'STACK:systempct#FF0000:system cpu usage' \
    8.64 +		'STACK:idlepct#00FF00:idle cpu usage' \
    8.65 +		'LINE1:temp#000000:temperature\g' \
    8.66 +		'GPRINT:temp:MAX:max %2.0lfC\j'
    8.67 +}
    8.68 +
    8.69 +updatememgraph() {
    8.70 +	period=$1
    8.71 +	info="$(free | awk '\
    8.72 +{ \
    8.73 +  if (/Mem:/) { \
    8.74 +	if ($2 < 10000) printf "%d KB",$2; \
    8.75 +	else if ($2 < 10000000) printf "%d MB",$2/1024; \
    8.76 +	else printf "%d GB",$2/1024/1024; \
    8.77 +  } \
    8.78 +}')"
    8.79 +	info2="$(free | awk '\
    8.80 +{ \
    8.81 +  if (/Swap:/) { \
    8.82 +	if ($2 < 10000) printf "%d KB",$2; \
    8.83 +	else if ($2 < 10000000) printf "%d MB",$2/1024; \
    8.84 +	else printf "%d GB",$2/1024/1024; \
    8.85 +  } \
    8.86 +}')"
    8.87 +	rrdtool graph "$rrdgraph/memory-$period.png" --start -1$period \
    8.88 +		$rrdgraphargs -l 0 -u 100 \
    8.89 +		-t "memory usage per $period [ $info + $info2 swap ]" \
    8.90 +		DEF:used=$rrdlog/mem.rrd:memused:AVERAGE \
    8.91 +		DEF:free=$rrdlog/mem.rrd:memfree:AVERAGE \
    8.92 +		DEF:shared=$rrdlog/mem.rrd:memshared:AVERAGE \
    8.93 +		DEF:buffer=$rrdlog/mem.rrd:membuffers:AVERAGE \
    8.94 +		DEF:cache=$rrdlog/mem.rrd:memcache:AVERAGE \
    8.95 +		DEF:swused=$rrdlog/mem.rrd:swapused:AVERAGE \
    8.96 +		DEF:swfree=$rrdlog/mem.rrd:swapfree:AVERAGE \
    8.97 +		'CDEF:total=used,free,+' \
    8.98 +		'CDEF:used2=used,buffer,cache,shared,+,+,-' \
    8.99 +		'CDEF:usedpct=100,used2,total,/,*' \
   8.100 +		'CDEF:sharedpct=100,shared,total,/,*' \
   8.101 +		'CDEF:bufferpct=100,buffer,total,/,*' \
   8.102 +		'CDEF:cachepct=100,cache,total,/,*' \
   8.103 +		'CDEF:freepct=100,free,total,/,*' \
   8.104 +		'CDEF:swtotal=swused,swfree,+' \
   8.105 +		'CDEF:swusedpct=100,swused,swtotal,/,*' \
   8.106 +		'AREA:usedpct#0000FF:used memory' \
   8.107 +		'STACK:sharedpct#FF7F00:shared memory' \
   8.108 +		'STACK:bufferpct#FF00FF:buffered memory' \
   8.109 +		'STACK:cachepct#FFFF00:cached memory' \
   8.110 +		'STACK:freepct#00FF00:free memory' \
   8.111 +		'LINE2:swusedpct#FF0000:used swap\j'
   8.112 +}
   8.113 +
   8.114 +updatememdata () {
   8.115 +	[ -e "$rrdlog/mem.rrd" ] ||
   8.116 +		rrdtool create "$rrdlog/mem.rrd" --step=300 \
   8.117 +			DS:memused:ABSOLUTE:600:0:5000000000 \
   8.118 +			DS:memfree:ABSOLUTE:600:0:5000000000 \
   8.119 +			DS:memshared:ABSOLUTE:600:0:5000000000 \
   8.120 +			DS:membuffers:ABSOLUTE:600:0:5000000000 \
   8.121 +			DS:memcache:ABSOLUTE:600:0:5000000000 \
   8.122 +			DS:swapused:ABSOLUTE:600:0:5000000000 \
   8.123 +			DS:swapfree:ABSOLUTE:600:0:5000000000 \
   8.124 +			RRA:AVERAGE:0.5:1:576  RRA:AVERAGE:0.5:6:672 \
   8.125 +			RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
   8.126 +
   8.127 +	while read tag count unit; do
   8.128 +		case "$tag" in
   8.129 +		MemTotal:)  memtotal=$count;;
   8.130 +		MemFree:)   memfree=$count
   8.131 +			    memused=$(($memtotal - $memfree))
   8.132 +			    memshared=0;;
   8.133 +		MemShared:) memshared=$count;;
   8.134 +		Buffers:)   membuffers=$count;;
   8.135 +		Cached:)    memcache=$count;;
   8.136 +		SwapTotal:) swaptotal=$count;;
   8.137 +		SwapFree:)  swapfree=$count
   8.138 +			    swapused=$(( $swaptotal - $swapfree));;
   8.139 +		esac
   8.140 +	done < /proc/meminfo
   8.141 +
   8.142 +	rrdtool update "$rrdlog/mem.rrd" \
   8.143 +		-t memused:memfree:memshared:membuffers:memcache:swapused:swapfree \
   8.144 +		"N:$memused:$memfree:$memshared:$membuffers:$memcache:$swapused:$swapfree"
   8.145 +}
   8.146 +
   8.147 +getmax() {
   8.148 +	rrdtool fetch $rrdlog/$1.rrd AVERAGE | awk '\
   8.149 +BEGIN {max=0} \
   8.150 +/^[0-9]/ { \
   8.151 +   if ($2 != "nan" && $2 > max) max=$2; \
   8.152 +   if ($3 != "nan" && $3 > max) max=$3; \
   8.153 +} \
   8.154 +END { print max }' | sed 's/,/./'
   8.155 +}
   8.156 +
   8.157 +updatediskgraph() {
   8.158 +	period=$1
   8.159 +	[ "$period" == "day" ] && maxdisk="$(getmax disk)"
   8.160 +	info=""
   8.161 +	[ -r $2 ] &&
   8.162 +	info="[ $(fdisk -l 2> /dev/null | grep "^Disk $2:" | \
   8.163 +		  sed "s|Disk $2: \(.*\), .*|\1|") ]"
   8.164 +	if [ -e /sys/block/${2#/dev/}/device/iodone_cnt ]; then
   8.165 +	err=$(printf "%d\n" $(cat /sys/block/${2#/dev/}/device/ioerr_cnt) )
   8.166 +	done=$(printf "%d\n" $(cat /sys/block/${2#/dev/}/device/iodone_cnt) )
   8.167 +	rate=$(echo | awk "BEGIN { printf \"%.0e\\n\",$err/$done }")
   8.168 +	[ $err -eq 0 ] &&  rate="0"
   8.169 +#		--right-axis-label "I/O state %"
   8.170 +	rrdtool graph "$rrdgraph/disk-$period.png" --start -1$period \
   8.171 +		$rrdgraphargs -t "disk access per $period $info" \
   8.172 +		--logarithmic --lower-limit 1 -v "Sectors/second" --units=si \
   8.173 +		DEF:read=$rrdlog/disk.rrd:readsect:AVERAGE \
   8.174 +		DEF:write=$rrdlog/disk.rrd:writesect:AVERAGE \
   8.175 +		DEF:req=$rrdlog/iodisk.rrd:req:AVERAGE \
   8.176 +		DEF:done=$rrdlog/iodisk.rrd:done:AVERAGE \
   8.177 +		DEF:err=$rrdlog/iodisk.rrd:err:AVERAGE \
   8.178 +		"CDEF:readpct=100,read,$maxdisk,/,*" \
   8.179 +		"CDEF:writepct=100,write,$maxdisk,/,*" \
   8.180 +		"CDEF:errpct=100,err,req,/,*" \
   8.181 +		"CDEF:donepct=100,done,req,/,*" \
   8.182 +		"CDEF:errrate=err,done,/" \
   8.183 +		'AREA:readpct#0000FF:sectors read from disk' \
   8.184 +		"COMMENT:I/O error rate $rate" \
   8.185 +		'STACK:writepct#00FF00:sectors written to disk' \
   8.186 +		'LINE2:donepct#FFFF00:% I/O complete' \
   8.187 +		'LINE2:errpct#FF0000:% I/O error\j'
   8.188 +	else
   8.189 +	rrdtool graph "$rrdgraph/disk-$period.png" --start -1$period \
   8.190 +		$rrdgraphargs -t "disk access per $period $info" \
   8.191 +		--logarithmic --lower-limit 1 -v "Sectors/second" --units=si \
   8.192 +		DEF:read=$rrdlog/disk.rrd:readsect:AVERAGE \
   8.193 +		DEF:write=$rrdlog/disk.rrd:writesect:AVERAGE \
   8.194 +		"CDEF:readpct=100,read,$maxdisk,/,*" \
   8.195 +		"CDEF:writepct=100,write,$maxdisk,/,*" \
   8.196 +		'AREA:readpct#0000FF:sectors read from disk' \
   8.197 +		'STACK:writepct#00FF00:sectors written to disk'
   8.198 +	fi
   8.199 +}
   8.200 +
   8.201 +updatediskdata() {
   8.202 +	dev=$1
   8.203 +	[ -e "$rrdlog/disk.rrd" ] ||
   8.204 +		rrdtool create "$rrdlog/disk.rrd" --step=300 \
   8.205 +			DS:readsect:COUNTER:600:0:5000000000 \
   8.206 +			DS:writesect:COUNTER:600:0:5000000000 \
   8.207 +			RRA:AVERAGE:0.5:1:576  RRA:AVERAGE:0.5:6:672 \
   8.208 +			RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
   8.209 +	[ -e "$rrdlog/iodisk.rrd" ] ||
   8.210 +		rrdtool create "$rrdlog/iodisk.rrd" --step=300 \
   8.211 +			DS:done:GAUGE:600:0:U  DS:err:GAUGE:600:0:U \
   8.212 +			DS:req:GAUGE:600:0:U \
   8.213 +			RRA:AVERAGE:0.5:1:576  RRA:AVERAGE:0.5:6:672 \
   8.214 +			RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
   8.215 +
   8.216 +	while read major minor name readreq readsect writereq writesect misc; do
   8.217 +		[ $major = $(( 0x$(stat -c %t $dev) )) ] || continue
   8.218 +		[ $minor = $(( 0x$(stat -c %T $dev) )) ] || continue
   8.219 +		rrdtool update "$rrdlog/disk.rrd" -t readsect:writesect \
   8.220 +			N:$readsect:$writesect
   8.221 +	done < /proc/diskstats
   8.222 +	disk=${dev:0:8}
   8.223 +	dir=/sys/block/${disk#/dev/}/device
   8.224 +	done=$(printf "%d\n" $(cat $dir/iodone_cnt 2> /dev/null) )
   8.225 +	err=$(printf "%d\n" $(cat $dir/ioerr_cnt 2> /dev/null) )
   8.226 +	req=$(printf "%d\n" $(cat $dir/iorequest_cnt 2> /dev/null) )
   8.227 +	rrdtool update "$rrdlog/iodisk.rrd" -t done:err:req N:$done:$err:$req
   8.228 +}
   8.229 +
   8.230 +updateifgraph() {
   8.231 +	interface=$1
   8.232 +	period=$2
   8.233 +	rrdtool graph "$rrdgraph/$interface-$period.png" --start -1$period \
   8.234 +		$rrdgraphargs -t "traffic on $interface graph per $period" \
   8.235 +		--logarithmic -A -v "Bytes/second" --units=si \
   8.236 +		DEF:incoming=$rrdlog/$interface.rrd:incoming:AVERAGE \
   8.237 +		DEF:outgoing=$rrdlog/$interface.rrd:outgoing:AVERAGE \
   8.238 +		'AREA:incoming#00FF00:incoming traffic' \
   8.239 +		'GPRINT:incoming:MAX:max input%8.3lf %sBps' \
   8.240 +		'GPRINT:outgoing:MAX:max output%8.3lf %sBps' \
   8.241 +		'LINE1:outgoing#0000FF:outgoing traffic\j'
   8.242 +}
   8.243 +
   8.244 +netframes() {
   8.245 +ifconfig $1 | grep "$2 packets" | sed -re "s/.*$3:([0-9]+).*/\1/g"
   8.246 +}
   8.247 +
   8.248 +netstats() {
   8.249 +ifconfig $1 | grep bytes | sed -re "s/.*$2 bytes:([0-9]+).*/\1/g"
   8.250 +}
   8.251 +
   8.252 +updateifdata() {
   8.253 +	interface=$1
   8.254 +	[ -e "$rrdlog/$interface.rrd" ] ||
   8.255 +		rrdtool create "$rrdlog/$interface.rrd" --step=300 \
   8.256 +			DS:incoming:COUNTER:600:0:U \
   8.257 +			DS:outgoing:COUNTER:600:0:U \
   8.258 +			RRA:AVERAGE:0.5:1:576  RRA:AVERAGE:0.5:6:672 \
   8.259 +			RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
   8.260 +	[ -e "$rrdlog/packets-$interface.rrd" ] ||
   8.261 +		rrdtool create "$rrdlog/packets-$interface.rrd" --step=300 \
   8.262 +			DS:in:COUNTER:600:0:U      DS:out:COUNTER:600:0:U \
   8.263 +			DS:inerr:COUNTER:600:0:U   DS:outerr:COUNTER:600:0:U \
   8.264 +			DS:indrop:COUNTER:600:0:U  DS:outdrop:COUNTER:600:0:U \
   8.265 +			DS:inov:COUNTER:600:0:U    DS:outov:COUNTER:600:0:U \
   8.266 +			DS:frame:COUNTER:600:0:U   DS:carrier:COUNTER:600:0:U \
   8.267 +			RRA:AVERAGE:0.5:1:576  RRA:AVERAGE:0.5:6:672 \
   8.268 +			RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
   8.269 +	rx=$(netstats $interface RX)
   8.270 +	tx=$(netstats $interface TX)
   8.271 +	rrdtool update "$rrdlog/$interface.rrd" -t incoming:outgoing \
   8.272 +		N:${rx:-U}:${tx:-U}
   8.273 +	rx=$(netframes $interface RX packets)
   8.274 +	tx=$(netframes $interface TX packets)
   8.275 +	rxerr=$(netframes $interface RX errors)
   8.276 +	txerr=$(netframes $interface TX errors)
   8.277 +	rxdrop=$(netframes $interface RX dropped)
   8.278 +	txdrop=$(netframes $interface TX dropped)
   8.279 +	rxov=$(netframes $interface RX overruns)
   8.280 +	txov=$(netframes $interface TX overruns)
   8.281 +	frame=$(netframes $interface RX frame)
   8.282 +	carrier=$(netframes $interface TX carrier)
   8.283 +	rrdtool update "$rrdlog/packets-$interface.rrd" \
   8.284 +		-t in:out:inerr:outerr:indrop:outdrop:inov:outov:frame:carrier \
   8.285 +		N:${rx:-U}:${tx:-U}:${rxerr:-U}:${txerr:-U}:${rxdrop:-U}:${txdrop:-U}:${rxov:-U}:${txov:-U}:${frame:-U}:${carrier:-U}
   8.286 +}
   8.287 +
   8.288 +getdisk()
   8.289 +{
   8.290 +	local d
   8.291 +	local i
   8.292 +	d=$(stat -c %04D $1)
   8.293 +	for i in /dev/* ; do 
   8.294 +		[ $(stat -c "%02t%02T" $i) == $d ] || continue
   8.295 +		echo $i
   8.296 +		break
   8.297 +	done
   8.298 +}
   8.299 +
   8.300 +###
   8.301 +### System graphs
   8.302 +###
   8.303 +
   8.304 +updatecpudata
   8.305 +updatecpugraph day
   8.306 +updatecpugraph week
   8.307 +updatecpugraph month
   8.308 +updatecpugraph year
   8.309 +
   8.310 +updatememdata
   8.311 +updatememgraph day
   8.312 +updatememgraph week
   8.313 +updatememgraph month
   8.314 +updatememgraph year
   8.315 +
   8.316 +if [ -e /proc/diskstats ]; then
   8.317 +	disk=$(getdisk $0)
   8.318 +	updatediskdata $disk
   8.319 +	updatediskgraph day ${disk:0:8}
   8.320 +	updatediskgraph week ${disk:0:8}
   8.321 +	updatediskgraph month ${disk:0:8}
   8.322 +	updatediskgraph year ${disk:0:8}
   8.323 +fi
   8.324 +
   8.325 +iface=$(/sbin/route -n | awk '{ if (/^0.0.0.0/) print $8 }')
   8.326 +updateifdata $iface
   8.327 +updateifgraph $iface day
   8.328 +updateifgraph $iface week
   8.329 +updateifgraph $iface month
   8.330 +updateifgraph $iface year