slitaz-forge rev 372
tank/makegraphs: add free blocks & connections
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Jun 09 22:46:11 2013 +0200 (2013-06-09) |
parents | 730cd6374507 |
children | 308a7ccd90c1 |
files | pangolin/makegraphs tank/web/lib/makegraphs |
line diff
1.1 --- a/pangolin/makegraphs Fri Jun 07 13:29:49 2013 +0200 1.2 +++ b/pangolin/makegraphs Sun Jun 09 22:46:11 2013 +0200 1.3 @@ -174,9 +174,9 @@ 1.4 "CDEF:writepct=100,write,$maxdisk,/,*" \ 1.5 'AREA:readpct#0000FF:sectors read from disk' \ 1.6 'STACK:writepct#00FF00:sectors written to disk' \ 1.7 - 'LINE1:ino#FF00FF:% inodes used in /home' \ 1.8 + 'LINE1:ino#FF00FF:inodes used in /home\g' \ 1.9 'GPRINT:ino:MAX:%1.0lf%%' \ 1.10 - 'LINE1:blk#FF0000:% blocks used in /home' \ 1.11 + 'LINE1:blk#FF0000:blocks used in /home\g' \ 1.12 'GPRINT:blk:MAX:%1.0lf%%\j' 1.13 } 1.14 1.15 @@ -229,11 +229,11 @@ 1.16 DEF:incoming=$rrdlog/$interface.rrd:incoming:AVERAGE \ 1.17 DEF:outgoing=$rrdlog/$interface.rrd:outgoing:AVERAGE \ 1.18 DEF:tcp=$rrdlog/proto-$interface.rrd:tcp:AVERAGE \ 1.19 - 'AREA:incoming#00FF00:incoming traffic' \ 1.20 + 'AREA:incoming#00FF00:incoming traffic\g' \ 1.21 'GPRINT:incoming:MAX:max%8.3lf %sBps' \ 1.22 - 'LINE1:outgoing#0000FF:outgoing traffic' \ 1.23 + 'LINE1:outgoing#0000FF:outgoing traffic\g' \ 1.24 'GPRINT:outgoing:MAX:max%8.3lf %sBps' \ 1.25 - 'LINE1:tcp#000000:connections' \ 1.26 + 'LINE1:tcp#000000:connections\g' \ 1.27 'GPRINT:tcp:MAX:max %2.0lf\j' 1.28 } 1.29
2.1 --- a/tank/web/lib/makegraphs Fri Jun 07 13:29:49 2013 +0200 2.2 +++ b/tank/web/lib/makegraphs Sun Jun 09 22:46:11 2013 +0200 2.3 @@ -170,24 +170,36 @@ 2.4 # --right-axis-label "I/O state %" 2.5 rrdtool graph "$rrdgraph/disk-$period.png" --start -1$period \ 2.6 $rrdgraphargs -t "disk access per $period $info" \ 2.7 - --logarithmic --lower-limit 1 -v "Sectors/second" --units=si \ 2.8 + -v "Sectors/second" --units=si \ 2.9 DEF:read=$rrdlog/disk.rrd:readsect:AVERAGE \ 2.10 DEF:write=$rrdlog/disk.rrd:writesect:AVERAGE \ 2.11 + DEF:blkh=$rrdlog/usagedisk.rrd:bhome:AVERAGE \ 2.12 + DEF:blkr=$rrdlog/usagedisk.rrd:broot:AVERAGE \ 2.13 "CDEF:readpct=100,read,$maxdisk,/,*" \ 2.14 "CDEF:writepct=100,write,$maxdisk,/,*" \ 2.15 - 'AREA:readpct#0000FF:sectors written from disk' \ 2.16 - "COMMENT:I/O error rate $rate" \ 2.17 - 'STACK:writepct#00FF00:sectors read to disk\j' 2.18 + 'AREA:readpct#0000FF:sectors written' \ 2.19 + 'STACK:writepct#00FF00:sectors read' \ 2.20 + "COMMENT:I/O error $rate" \ 2.21 + 'LINE1:blkr#FF00FF:blocks used in /root\g' \ 2.22 + 'GPRINT:blkr:LAST:%1.0lf%%' \ 2.23 + 'LINE1:blkh#FF0000:blocks used in /home\g' \ 2.24 + 'GPRINT:blkh:LAST:%1.0lf%%\j' 2.25 else 2.26 rrdtool graph "$rrdgraph/disk-$period.png" --start -1$period \ 2.27 $rrdgraphargs -t "disk access per $period $info" \ 2.28 --logarithmic --lower-limit 1 -v "Sectors/second" --units=si \ 2.29 DEF:read=$rrdlog/disk.rrd:readsect:AVERAGE \ 2.30 DEF:write=$rrdlog/disk.rrd:writesect:AVERAGE \ 2.31 + DEF:blk=$rrdlog/usagedisk.rrd:bhome:AVERAGE \ 2.32 + DEF:ino=$rrdlog/usagedisk.rrd:ihome:AVERAGE \ 2.33 "CDEF:readpct=100,read,$maxdisk,/,*" \ 2.34 "CDEF:writepct=100,write,$maxdisk,/,*" \ 2.35 'AREA:readpct#0000FF:sectors read from disk' \ 2.36 - 'STACK:writepct#00FF00:sectors written to disk' 2.37 + 'STACK:writepct#00FF00:sectors written to disk' \ 2.38 + 'LINE1:ino#FF00FF:inodes used in /home\g' \ 2.39 + 'GPRINT:ino:MAX:%1.0lf%%' \ 2.40 + 'LINE1:blk#FF0000:blocks used in /home\g' \ 2.41 + 'GPRINT:blk:MAX:%1.0lf%%\j' 2.42 fi 2.43 } 2.44 2.45 @@ -205,6 +217,12 @@ 2.46 DS:req:GAUGE:600:0:U \ 2.47 RRA:AVERAGE:0.5:1:576 RRA:AVERAGE:0.5:6:672 \ 2.48 RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460 2.49 + [ -e "$rrdlog/usagedisk.rrd" ] || 2.50 + rrdtool create "$rrdlog/usagedisk.rrd" --step=300 \ 2.51 + DS:broot:GAUGE:600:0:U DS:iroot:GAUGE:600:0:U \ 2.52 + DS:bhome:GAUGE:600:0:U DS:ihome:GAUGE:600:0:U \ 2.53 + RRA:AVERAGE:0.5:1:576 RRA:AVERAGE:0.5:6:672 \ 2.54 + RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460 2.55 2.56 while read major minor name readreq readsect writereq writesect misc; do 2.57 [ $major = $(( 0x$(stat -c %t $dev) )) ] || continue 2.58 @@ -218,6 +236,11 @@ 2.59 err=$(printf "%d\n" $(cat $dir/ioerr_cnt 2> /dev/null) ) 2.60 req=$(printf "%d\n" $(cat $dir/iorequest_cnt 2> /dev/null) ) 2.61 rrdtool update "$rrdlog/iodisk.rrd" -t done:err:req N:$done:$err:$req 2.62 + iroot=$(df -i / | sed '$!d;s/.* \([0-9]*\)% \/.*/\1/') 2.63 + broot=$(df / | sed '$!d;s/.* \([0-9]*\)% \/.*/\1/') 2.64 + ihome=$(df -i /home | sed '$!d;s/.* \([0-9]*\)% \/.*/\1/') 2.65 + bhome=$(df /home | sed '$!d;s/.* \([0-9]*\)% \/.*/\1/') 2.66 + rrdtool update "$rrdlog/usagedisk.rrd" -t broot:iroot:bhome:ihome N:$broot:$iroot:$bhome:$ihome 2.67 } 2.68 2.69 updateifgraph() { 2.70 @@ -228,10 +251,13 @@ 2.71 --logarithmic -A -v "Bytes/second" --units=si \ 2.72 DEF:incoming=$rrdlog/$interface.rrd:incoming:AVERAGE \ 2.73 DEF:outgoing=$rrdlog/$interface.rrd:outgoing:AVERAGE \ 2.74 - 'AREA:incoming#00FF00:incoming traffic' \ 2.75 - 'GPRINT:incoming:MAX:max input%8.3lf %sBps' \ 2.76 - 'GPRINT:outgoing:MAX:max output%8.3lf %sBps' \ 2.77 - 'LINE1:outgoing#0000FF:outgoing traffic\j' 2.78 + DEF:tcp=$rrdlog/proto-$interface.rrd:tcp:AVERAGE \ 2.79 + 'AREA:incoming#00FF00:incoming traffic\g' \ 2.80 + 'GPRINT:incoming:MAX:max%8.3lf %sBps' \ 2.81 + 'LINE1:outgoing#0000FF:outgoing traffic\g' \ 2.82 + 'GPRINT:outgoing:MAX:max%8.3lf %sBps' \ 2.83 + 'LINE1:tcp#000000:connections\g' \ 2.84 + 'GPRINT:tcp:MAX:max %2.0lf\j' 2.85 } 2.86 2.87 netframes() { 2.88 @@ -242,6 +268,16 @@ 2.89 ifconfig $1 | grep bytes | sed -re "s/.*$2 bytes:([0-9]+).*/\1/g" 2.90 } 2.91 2.92 +netproto() 2.93 +{ 2.94 + proto=${1:-tcp} 2.95 + if [ -n "$2" ]; then 2.96 + netstat -an 2> /dev/null | grep -v '0.0.0.0:*' | grep "^$proto"| grep ":$2 " | wc -l 2.97 + else 2.98 + netstat -an 2> /dev/null | grep -v '0.0.0.0:*' | grep "^$proto"| wc -l 2.99 + fi 2.100 +} 2.101 + 2.102 updateifdata() { 2.103 interface=$1 2.104 [ -e "$rrdlog/$interface.rrd" ] || 2.105 @@ -259,6 +295,13 @@ 2.106 DS:frame:COUNTER:600:0:U DS:carrier:COUNTER:600:0:U \ 2.107 RRA:AVERAGE:0.5:1:576 RRA:AVERAGE:0.5:6:672 \ 2.108 RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460 2.109 + [ -e "$rrdlog/proto-$interface.rrd" ] || 2.110 + rrdtool create "$rrdlog/proto-$interface.rrd" --step=300 \ 2.111 + DS:tcp:GAUGE:600:0:U DS:udp:GAUGE:600:0:U \ 2.112 + DS:rsync:GAUGE:600:0:U DS:www:GAUGE:600:0:U \ 2.113 + DS:ssh:GAUGE:600:0:U \ 2.114 + RRA:AVERAGE:0.5:1:576 RRA:AVERAGE:0.5:6:672 \ 2.115 + RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460 2.116 rx=$(netstats $interface RX) 2.117 tx=$(netstats $interface TX) 2.118 rrdtool update "$rrdlog/$interface.rrd" -t incoming:outgoing \ 2.119 @@ -276,6 +319,14 @@ 2.120 rrdtool update "$rrdlog/packets-$interface.rrd" \ 2.121 -t in:out:inerr:outerr:indrop:outdrop:inov:outov:frame:carrier \ 2.122 N:${rx:-U}:${tx:-U}:${rxerr:-U}:${txerr:-U}:${rxdrop:-U}:${txdrop:-U}:${rxov:-U}:${txov:-U}:${frame:-U}:${carrier:-U} 2.123 + rsync=$(netproto tcp 873) 2.124 + www=$(netproto tcp 80) 2.125 + ssh=$(netproto tcp 22) 2.126 + tcp=$(netproto tcp) 2.127 + udp=$(netproto udp) 2.128 + rrdtool update "$rrdlog/proto-$interface.rrd" \ 2.129 + -t tcp:udp:rsync:www:ssh \ 2.130 + N:${tcp:-U}:${udp:-U}:${rsync:-U}:${www:-U}:${ssh:-U} 2.131 } 2.132 2.133 getdisk()