slitaz-forge diff tank/web/bin/makegraphs @ rev 138
Update chub web interface with graphs and use include files
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Thu Mar 15 21:09:50 2012 +0100 (2012-03-15) |
parents | 33479b294b31 |
children |
line diff
1.1 --- a/tank/web/bin/makegraphs Wed Feb 23 22:16:38 2011 +0000 1.2 +++ b/tank/web/bin/makegraphs Thu Mar 15 21:09:50 2012 +0100 1.3 @@ -17,20 +17,21 @@ 1.4 updatecpudata() { 1.5 [ -e "$rrdlog/cpu.rrd" ] || rrdtool create $rrdlog/cpu.rrd --step=300 \ 1.6 DS:user:COUNTER:600:0:500000000 \ 1.7 + DS:nice:COUNTER:600:0:500000000 \ 1.8 DS:system:COUNTER:600:0:500000000 \ 1.9 DS:idle:COUNTER:600:0:500000000 \ 1.10 + DS:iowait:COUNTER:600:0:500000000 \ 1.11 + DS:irq:COUNTER:600:0:500000000 \ 1.12 + DS:softirq:COUNTER:600:0:500000000 \ 1.13 + DS:celsius:GAUGE:600:0:50000 \ 1.14 RRA:AVERAGE:0.5:1:576 RRA:AVERAGE:0.5:6:672 \ 1.15 RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460 1.16 - grep '^cpu' /proc/stat | while read cpu user nice system idle misc; do 1.17 - rrdtool update $rrdlog/cpu.rrd -t user:system:idle \ 1.18 - N:$(( $user + $nice )):$system:$idle 1.19 - break 1.20 - done 1.21 - 1.22 - [ -e "$rrdlog/cpu2.rrd" ] && 1.23 - grep '^cpu' /proc/stat | while read cpu user nice system idle misc; do 1.24 - rrdtool update $rrdlog/cpu2.rrd -t nice:user:system:idle \ 1.25 - N:$nice:$user:$system:$idle 1.26 + grep '^cpu' /proc/stat | while read cpu user nice system idle iowait irq softirq misc; do 1.27 + celsius=$(find /sys | grep /temp._input | xargs cat | \ 1.28 + awk '{ if ($0 > max) max=$0 } END { print max/1 }') 1.29 + rrdtool update $rrdlog/cpu.rrd \ 1.30 + -t celsius:nice:user:system:idle:iowait:irq:softirq \ 1.31 + N:$celsius:$nice:$user:$system:$idle:$iowait:$irq:$softirq 1.32 break 1.33 done 1.34 } 1.35 @@ -46,13 +47,20 @@ 1.36 DEF:user=$rrdlog/cpu.rrd:user:AVERAGE \ 1.37 DEF:system=$rrdlog/cpu.rrd:system:AVERAGE \ 1.38 DEF:idle=$rrdlog/cpu.rrd:idle:AVERAGE \ 1.39 - 'CDEF:total=user,system,idle,+,+' \ 1.40 + DEF:nice=$rrdlog/cpu.rrd:nice:AVERAGE \ 1.41 + DEF:celsius=$rrdlog/cpu.rrd:celsius:AVERAGE \ 1.42 + 'CDEF:total=user,system,idle,nice,+,+,+' \ 1.43 'CDEF:userpct=100,user,total,/,*' \ 1.44 'CDEF:systempct=100,system,total,/,*' \ 1.45 'CDEF:idlepct=100,idle,total,/,*' \ 1.46 + 'CDEF:nicepct=100,nice,total,/,*' \ 1.47 + 'CDEF:temp=celsius,1000,/' \ 1.48 'AREA:userpct#0000FF:user cpu usage' \ 1.49 + 'STACK:nicepct#C0C0FF:nice cpu usage' \ 1.50 'STACK:systempct#FF0000:system cpu usage' \ 1.51 - 'STACK:idlepct#00FF00:idle cpu usage\j' 1.52 + 'STACK:idlepct#00FF00:idle cpu usage' \ 1.53 + 'LINE1:temp#000000:temperature\g' \ 1.54 + 'GPRINT:temp:MAX:max %2.0lfC\j' 1.55 } 1.56 1.57 updatememgraph() { 1.58 @@ -115,15 +123,15 @@ 1.59 1.60 while read tag count unit; do 1.61 case "$tag" in 1.62 - MemTotal:) memtotal=$(($count * 1024));; 1.63 - MemFree:) memfree=$(($count * 1024)) 1.64 + MemTotal:) memtotal=$count;; 1.65 + MemFree:) memfree=$count 1.66 memused=$(($memtotal - $memfree)) 1.67 memshared=0;; 1.68 - MemShared:) memshared=$(($count * 1024));; 1.69 - Buffers:) membuffers=$(($count * 1024));; 1.70 - Cached:) memcache=$(($count * 1024));; 1.71 - SwapTotal:) swaptotal=$(($count * 1024));; 1.72 - SwapFree:) swapfree=$(($count * 1024)) 1.73 + MemShared:) memshared=$count;; 1.74 + Buffers:) membuffers=$count;; 1.75 + Cached:) memcache=$count;; 1.76 + SwapTotal:) swaptotal=$count;; 1.77 + SwapFree:) swapfree=$count 1.78 swapused=$(( $swaptotal - $swapfree));; 1.79 esac 1.80 done < /proc/meminfo 1.81 @@ -225,6 +233,7 @@ 1.82 DEF:incoming=$rrdlog/$interface.rrd:incoming:AVERAGE \ 1.83 DEF:outgoing=$rrdlog/$interface.rrd:outgoing:AVERAGE \ 1.84 'AREA:incoming#00FF00:incoming traffic' \ 1.85 + 'GPRINT:incoming:MAX:max input%8.3lf %sBps' \ 1.86 'GPRINT:outgoing:MAX:max output%8.3lf %sBps' \ 1.87 'LINE1:outgoing#0000FF:outgoing traffic\j' 1.88 }