diff options
author | nico <nico@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2005-08-15 01:27:08 +0000 |
---|---|---|
committer | nico <nico@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2005-08-15 01:27:08 +0000 |
commit | 74076900909c1619e06ae12e16ffc0bc64ce958f (patch) | |
tree | a59a1eeb09139fb8ade0b381df4cb105b0933687 /package/rrdcollect/files | |
parent | 9a1277319293945a0c697cb8cdc7795e7f847246 (diff) |
add a package providing a default working (i hope) setup
git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@1676 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/rrdcollect/files')
-rw-r--r-- | package/rrdcollect/files/rrd.conf | 381 | ||||
-rw-r--r-- | package/rrdcollect/files/rrd.sh | 288 | ||||
-rw-r--r-- | package/rrdcollect/files/rrdcollect.conf | 2 | ||||
-rw-r--r-- | package/rrdcollect/files/rrdcollect.init | 11 |
4 files changed, 679 insertions, 3 deletions
diff --git a/package/rrdcollect/files/rrd.conf b/package/rrdcollect/files/rrd.conf new file mode 100644 index 0000000000..d47b71a2a8 --- /dev/null +++ b/package/rrdcollect/files/rrd.conf @@ -0,0 +1,381 @@ +# +# Author: Christian Rost (chr@baltic-online.de) +# Purpose: Shell-Interface to rrdtool +# +# Configuration-File for rrd.sh +# +DATADIR=/var/lib/rrdcollect +# Location of *.rrd-data-files +RRDDIR=$DATADIR/rrd +# Location of *.png-files +IMGDIR=$DATADIR/img +# Hostname used in title of png-images +HOSTNAME="WRT54GS" +# Location of rrdtool +RRDTOOL=/usr/bin/rrdtool +# Location of rrdcgi +RRDCGI=/usr/bin/rrdcgi +# Location of generated cgi-script +RRDCGISCRIPT=$DATA/rrd.cgi +# Image-Path relative to webserver-root +RRDCGIIMGPATH="/img" +# Location of netcat (used for fetching data from rrdcollect-daemon) +NETCAT=/usr/bin/nc + +# Alternative settings for use on external machines +#RRDDIR=/home/webm/htdocs/stats/rrd/rrd +#IMGDIR=/home/webm/htdocs/stats/rrd/web +#RRDTOOL=/opt/rrd/bin/rrdtool +#RRDCGI=/opt/rrd/bin/rrdcgi +#RRDCGISCRIPT=/home/webm/cgi-bin/rrd.cgi +#RRDCGIIMGPATH="/stats/rrd/web" +#NETCAT=/opt/bin/nc + + +#################################################################################### +# Configuration of statistic sources: +# +# Column 1: Time-periods +# I'm interrested in last-24hour-, last-week- and last-month-plots. +# Column 2: Define precision/resolution of above three intervalls +# These values have an impact on the size of your rrd-files, +# and on the sharpness of your plots +# RES=1 means maximum precision (every pixel in the plot is individual) +# RES=4 -> 4 pixel represents one interval + +# Optimized values for storing rather small rrd-files on the openwrt-box +HOURS=24;H_RES=2;DAYS=7;D_RES=4;WEEKS=4;W_RES=4; +# Measure-Step (Same value should be in the rrdcollect.conf) Optimal: STEP=$HOURS / $PIXWIDTH * 3600 * $H_RES +STEP=360; MAXSTEP=`expr $STEP \* 2` + +# Values for storing rrd-files externally outside the router allowing better resolution +#HOURS=24;H_RES=1;DAYS=32;D_RES=2;WEEKS=50;W_RES=2; +#STEP=180; MAXSTEP=`expr $STEP \* 2` +# Even better resolution +#HOURS=8;H_RES=1;DAYS=32;D_RES=2;WEEKS=50;W_RES=2; +#STEP=60; MAXSTEP=`expr $STEP \* 2` + +# Format and size of the plots PIXWIDTH will be used in +# calculating rrd-data-file dimensions during init of rrd-files +# If you change the size you must change NCGIPIXWIDTH too +PIXWIDTH=480 +PIXHEIGHT=120 +PIXFORMAT=PNG + +# Image-Size of the thumbnail for rrdcgi +SCGIPIXWIDTH=400 +# Normal Image-Size for rrdcgi (480px plotsize in rrd) +NCGIPIXWIDTH=571 + +# Predefined colors +RED0=#ff0000; RED1=#ff5555; +GRN0=#009828; GRN1=#81ffa2; +ORG0=#ff9900; ORG1=#ffc571; +BLU0=#0030ff; BLU1=#8ba1ff; +CYA0=#ff00FF; CYA1=#ffbcfe; +YEL0=#ffff00; YEL1=#e0df76; +BLK0=#000000; BLK1=#7d7d7d; +WHI0=#FFFFFF; WHI1=#c1c1c1; + +# Date-String used when creating images with rrd.sh +DATE=`/bin/date "+%d.%m.%Y %H:%M:%S"` + +# Max-Values bytes/second and packets/second for WAN/Wifi/LAN Interfaces +MAXWANB=130000 +MAXWANP=500 +MAXWIFB=600000 +MAXWIFP=800 +MAXLANB=1200000 +MAXLANP=1000 + +# RRD-Types: +# GAUGE=save the value itself, no calculations at all +# COUNTER=continuously increasing value. difference between last 2 values must be positive ! (Traffic-Counter) +# DERIVE=like counter but can store negative values (rate of change in free disk-space) +# +# General syntax: PREFIX_POSTFIX=[-]<rrdcollect-variable>|Legend|RRD-Type|Maximum|Color|RRD-Plot-Type|Printf-Precision|Optional rrdgraph def-arguments + +################ +# Sys-Statistics +################ +SYS_L01=" l1|System Load (1 min)|GAUGE|U|$YEL0|AREA|%6.2lf" +SYS_L05=" l2|System Load (5 min)|GAUGE|U|$ORG0|STACK|%6.2lf" +SYS_L15=" l3|System Load (15 min)|GAUGE|U|$RED0|STACK|%6.2lf" + +SYS_CPN=" cn|CPU nice |COUNTER|U|$YEL0|AREA|%6.2lf%%" +SYS_CPU=" cu|CPU user |COUNTER|U|$ORG0|STACK|%6.2lf%%" +SYS_CPS=" cs|CPU system |COUNTER|U|$RED0|STACK|%6.2lf%%" +SYS_CPI=" ci|CPU idle |COUNTER|U|$GRN0|STACK|%6.2lf%%" + +SYS_MEU=" mu|Memory used |GAUGE|U|$BLU0|AREA" +SYS_MEF=" mf|Memory free |GAUGE|U|$GRN0|STACK" +#SYS_MES=" ms|Memory shared |GAUGE|U|$BLK0|LINE1" +SYS_MEB=" mb|Memory buffer |GAUGE|U|$YEL0|LINE1" +SYS_MEC=" mc|Memory cached |GAUGE|U|$RED0|LINE1" + +SYS_FUS=" us|Flash Disk Used |GAUGE|U|$BLU0|AREA|%6.2lf%s|CDEF:usC=us,1024,* CDEF:MAXusC=us,1024,*" +SYS_FAV=" av|Flash Disk Available|GAUGE|U|$GRN0|STACK|%6.2lf%s|CDEF:avC=av,1024,* CDEF:MAXavC=av,1024,*" + +SYS_IRA="ira|Interrupts total |COUNTER|U|$RED0|AREA" +SYS_IRE="ire|Interrupts eth0 |COUNTER|U|$ORG0|AREA" +SYS_IRW="irw|Interrupts wifi |COUNTER|U|$YEL0|STACK" + +SYS_PRT=" pt|Processes total |GAUGE|U|$BLU0|AREA|%6.0lf" +SYS_CTX=" ct|Context switches |COUNTER|U|$RED0|LINE2|%6.0lf" +SYS_PRR=" pr|Processes active |GAUGE|U|$ORG0|AREA|%6.0lf" +SYS_ARP="arp|Arp Entries |GAUGE|U|$YEL0|LINE2|%6.0lf" +SYS_PFK=" fk|Forks |COUNTER|U|$GRN0|LINE2|%6.0lf" +SYS_CON="con|NAT-Connections |GAUGE|U|$CYA0|LINE2|%6.0lf" + +# Plot-Titles +MISC_STATS="Misc ($HOSTNAME)" +DSK_STATS="Flash Disk Usage ($HOSTNAME)" +USG_STATS="System Load ($HOSTNAME)" +MEM_STATS="Memory Usage ($HOSTNAME)" +CPU_STATS="CPU Usage ($HOSTNAME)" +IRQ_STATS="Interrupts ($HOSTNAME)" + +# Plot-Definitions (sort-order is relevant) +SYS_CPU_STATS="CPN CPU CPS CPI" +#SYS_MEM_STATS="MEU MEF MES MEB MEC" +SYS_MEM_STATS="MEU MEF MEB MEC" +SYS_USG_STATS="L01 L05 L15" +SYS_DSK_STATS="FUS FAV" +SYS_MISC_STATS="PRT PRR ARP PFK CTX CON" +SYS_IRQ_STATS="IRA IRE IRW" + +# Data-Definition needed by init() +SYS_ALL="$SYS_CPU_STATS $SYS_MEM_STATS $SYS_USG_STATS $SYS_DSK_STATS $SYS_MISC_STATS $SYS_IRQ_STATS" + +################################################################################################# +# Wifi Traffic & Wan Traffic & Tunnel Traffic Statistics ; # LAN: vlan0 , WAN: vlan1 , eth1: WIFI +################################################################################################# +IF_WLOBY="Wibo |Outgoing Traffic Wifi |COUNTER|$MAXWIFB|$GRN1|AREA" +IF_WLIBY="-Wibi|Incoming Traffic Wifi |COUNTER|$MAXWIFB|$RED0|AREA" +IF_WLOPK="Wipo |Outgoing Packets Wifi |COUNTER|$MAXWIFP|$GRN1|AREA|%6.0lf" +IF_WLIPK="-Wipi|Incoming Packets Wifi |COUNTER|$MAXWIFP|$RED0|AREA|%6.0lf" + +IF_WAIBY="-Wabi|Incoming Traffic Wan |COUNTER|$MAXWANB|$BLU0|AREA" +IF_WAOBY="Wabo |Outgoing Traffic Wan |COUNTER|$MAXWANB|$ORG1|AREA" +IF_WAIPK="-Wapi|Incoming Packets Wan |COUNTER|$MAXWANP|$BLU0|AREA|%6.0lf" +IF_WAOPK="Wapo |Outgoing Packets Wan |COUNTER|$MAXWANP|$ORG1|AREA|%6.0lf" + +IF_LAIBY="-Labi|Incoming Traffic Lan |COUNTER|$MAXLANB|$BLU0|AREA" +IF_LAOBY="Labo |Outgoing Traffic Lan |COUNTER|$MAXLANB|$ORG1|AREA" +IF_LAIPK="-Lapi|Incoming Packets Lan |COUNTER|$MAXLANP|$BLU0|AREA|%6.0lf" +IF_LAOPK="Lapo |Outgoing Packets Lan |COUNTER|$MAXLANP|$ORG1|AREA|%6.0lf" + +#IF_TUIBY="-tbi|Incoming Traffic VPN-Tunnel|COUNTER|$MAXWANB|$CYA0|AREA" +#IF_TUOBY="tbo |Outgoing Traffic VPN-Tunnel|COUNTER|$MAXWANB|$YEL1|AREA" +#IF_TUIPK="-tpi|Incoming Packets VPN-Tunnel|COUNTER|$MAXWANP|$CYA0|AREA|%6.0lf" +#IF_TUOPK="tpo |Outgoing Packets VPN-Tunnel|COUNTER|$MAXWANP|$YEL1|AREA|%6.0lf" + +# Plot-Titles +WIFI_TRAFFIC="Wifi Interface Traffic Statistics ($HOSTNAME)" +WIFI_PACKETS="Wifi Interface Packets Statistics ($HOSTNAME)" +WAN_TRAFFIC="Wan Interface Traffic Statistics ($HOSTNAME)" +WAN_PACKETS="Wan Interface Packets Statistics ($HOSTNAME)" +LAN_TRAFFIC="Lan Interface Traffic Statistics ($HOSTNAME)" +LAN_PACKETS="Lan Interface Packets Statistics ($HOSTNAME)" + +#TUN_TRAFFIC="VPN-Tunnel Interface Traffic Statistics ($HOSTNAME)" +#TUN_PACKETS="VPN-Tunnel Interface Packets Statistics ($HOSTNAME)" + +# Plot-Definitions (sort-order is relevant) +IF_WIFI_TRAFFIC="WLOBY WLIBY" +IF_WIFI_PACKETS="WLOPK WLIPK" +IF_WAN_TRAFFIC="WAIBY WAOBY" +IF_WAN_PACKETS="WAIPK WAOPK" +IF_LAN_TRAFFIC="LAIBY LAOBY" +IF_LAN_PACKETS="LAIPK LAOPK" +#IF_TUN_TRAFFIC="TUIBY TUOBY" +#IF_TUN_PACKETS="TUIPK TUOPK" + +# Data-Definition needed by init() +#IF_ALL="$IF_WIFI_TRAFFIC $IF_WIFI_PACKETS $IF_WAN_TRAFFIC $IF_WAN_PACKETS $IF_TUN_TRAFFIC $IF_TUN_PACKETS" +IF_ALL="$IF_LAN_TRAFFIC $IF_LAN_PACKETS $IF_WAN_TRAFFIC $IF_WAN_PACKETS $IF_WIFI_TRAFFIC $IF_WIFI_PACKETS" + +############################################## +# Port Traffic Statistics for Port 1 - Port 4 +############################################## +#PT_OPK1="po1 |Port 1 Outgoing Packets |COUNTER|U|$ORG1|AREA|%6.0lf" +#PT_IPK1="-pi1|Port 1 Incoming Packets |COUNTER|U|$GRN0|AREA|%6.0lf" +#PT_COL1="cl1 |Port 1 Collisions |COUNTER|U|$BLU0|AREA|%6.0lf" +#PT_ERR1="er1 |Port 1 Errors |COUNTER|U|$CYA0|AREA|%6.0lf" +#PT_OBY1="bo1 |Port 1 Outgoing Traffic |COUNTER|U|$ORG1|AREA" +#PT_IBY1="-bi1|Port 1 Incoming Traffic |COUNTER|U|$GRN0|AREA" +#PT_OPK2="po2 |Port 2 Outgoing Packets |COUNTER|U|$RED1|AREA|%6.0lf" +#PT_IPK2="-pi2|Port 2 Incoming Packets |COUNTER|U|$BLK0|AREA|%6.0lf" +#PT_COL2="cl2 |Port 2 Collisions |COUNTER|U|$GRN0|AREA|%6.0lf" +#PT_ERR2="er2 |Port 2 Errors |COUNTER|U|$ORG0|AREA|%6.0lf" +#PT_OBY2="bo2 |Port 2 Outgoing Traffic |COUNTER|U|$RED1|AREA" +#PT_IBY2="-bi2|Port 2 Incoming Traffic |COUNTER|U|$BLK0|AREA" +#PT_OPK3="po3 |Port 3 Outgoing Packets |COUNTER|U|$BLU1|AREA|%6.0lf" +#PT_IPK3="-pi3|Port 3 Incoming Packets |COUNTER|U|$CYA0|AREA|%6.0lf" +#PT_COL3="cl3 |Port 3 Collisions |COUNTER|U|$GRN0|AREA|%6.0lf" +#PT_ERR3="er3 |Port 3 Errors |COUNTER|U|$ORG0|AREA|%6.0lf" +#PT_OBY3="bo3 |Port 3 Outgoing Traffic |COUNTER|U|$BLU1|AREA" +#PT_IBY3="-bi3|Port 3 Incoming Traffic |COUNTER|U|$CYA0|AREA" +#PT_OPK4="po4 |Port 4 Outgoing Packets |COUNTER|U|$YEL1|AREA|%6.0lf" +#PT_IPK4="-pi4|Port 4 Incoming Packets |COUNTER|U|$CYA0|AREA|%6.0lf" +#PT_COL4="cl4 |Port 4 Collisions |COUNTER|U|$BLK0|AREA|%6.0lf" +#PT_ERR4="er4 |Port 4 Errors |COUNTER|U|$RED0|AREA|%6.0lf" +#PT_OBY4="bo4 |Port 4 Outgoing Traffic |COUNTER|U|$YEL1|AREA" +#PT_IBY4="-bi4|Port 4 Incoming Traffic |COUNTER|U|$CYA0|AREA" + +# Plot-Titles +#TRAFFIC_1="Traffic Statistics Port 1 ($HOSTNAME)" +#TRAFFIC_2="Traffic Statistics Port 2 ($HOSTNAME)" +#TRAFFIC_3="Traffic Statistics Port 3 ($HOSTNAME)" +#TRAFFIC_4="Traffic Statistics Port 4 ($HOSTNAME)" +#PACKETS_1="Packet Statistics Port 1 ($HOSTNAME)" +#PACKETS_2="Packet Statistics Port 2 ($HOSTNAME)" +#PACKETS_3="Packet Statistics Port 3 ($HOSTNAME)" +#PACKETS_4="Packet Statistics Port 4 ($HOSTNAME)" + +# Plot-Definitions (sort-order is relevant) +#PT_TRAFFIC_1="OBY1 IBY1" +#PT_TRAFFIC_2="OBY2 IBY2" +#PT_TRAFFIC_3="OBY3 IBY3" +#PT_TRAFFIC_4="OBY4 IBY4" +#PT_PACKETS_1="OPK1 IPK1 COL1 ERR1" +#PT_PACKETS_2="OPK2 IPK2 COL2 ERR2" +#PT_PACKETS_3="OPK3 IPK3 COL3 ERR3" +#PT_PACKETS_4="OPK4 IPK4 COL4 ERR4" +#PT_PACKETS_1="OPK1 IPK1" +#PT_PACKETS_2="OPK2 IPK2" +#PT_PACKETS_3="OPK3 IPK3" +#PT_PACKETS_4="OPK4 IPK4" + +# Data Definition needed by init() +#PT_ALL="$PT_TRAFFIC_1 $PT_TRAFFIC_2 $PT_TRAFFIC_3 $PT_TRAFFIC_4 $PT_PACKETS_1 $PT_PACKETS_2 $PT_PACKETS_3 $PT_PACKETS_4" + +################################# +# Traffic Priorisation Statistics +################################# +#TC_APRIB="bwa|Ack Priority Queue Bandwidth |COUNTER|$MAXWANB|$YEL0|AREA" +#TC_DPRIB="bwd|Default Priority Queue Bandwidth |COUNTER|$MAXWANB|$ORG0|STACK" +#TC_HPRIB="bwh|High Priority Queue Bandwidth |COUNTER|$MAXWANB|$RED0|STACK" +#TC_LPRIB="bwl|Low Priority Queue Bandwidth |COUNTER|$MAXWANB|$GRN0|STACK" +#TC_APRID="dra|Ack Priority Queue Packet Dropped |COUNTER|100|$YEL0|AREA" +#TC_DPRID="drd|Default Priority Queue Packet Dropped|COUNTER|100|$ORG0|STACK" +#TC_HPRID="drh|High Priority Queue Packet Dropped |COUNTER|100|$RED0|STACK" +#TC_LPRID="drl|Low Priority Queue Packet Dropped |COUNTER|100|$GRN0|STACK" + +# Plot-Titles +#TRAFFIC="Traffic Priorisation Stats" +#PACKETS="Packet Priorisation Stats" + +# Plot-Definitions (sort-order is relevant) +#TC_TRAFFIC="APRIB DPRIB HPRIB LPRIB" +#TC_PACKETS="APRID DPRID HPRID LPRID" + +# Data Definition needed by init() +#TC_ALL="$TC_TRAFFIC $TC_PACKETS" + +################################# +# Firewall Packet Drop Statistics +################################# +#PC_WIN="win|Windows Traffic |COUNTER|U|$YEL0|AREA" +#PC_INV="inv|Invalid State Traffic |COUNTER|U|$ORG0|STACK" +#PC_TCP="tcp|TCP Packets |COUNTER|U|$RED0|STACK" +#PC_OTH="oth|Other Packets |COUNTER|U|$BLU0|STACK" + +# Plot-Titles +#DROPPED="Firewall Packet Drop Statistics" + +# Plot-Definitions (sort-order is relevant) +#PC_DROPPED="WIN INV TCP OTH" + +# Data Definition needed by init() +#PC_ALL="$PC_DROPPED" + +########################## +# Traffic Accounting Stats +########################## +#ACI="Incoming for "; ACO="Outgoing for " +#IP14="notebook"; COL14=$ORG0; COL_14=$ORG1 +#IP15="saugi "; COL15=$RED0; COL_15=$RED1 +#IP20="aplink "; COL20=$GRN0; COL_20=$GRN1 +#IP50="sunny "; COL50=$BLU0; COL_50=$BLU1 + +#TYPE=AREA +#for i in 15 50 20 14 +#do +# # Packet-Statistics +# eval AC_TIP$i='-TIP$i\|$ACI'"\$IP$i\|COUNTER\|$MAXWANP\|\$COL$i\|$TYPE" +# eval AC_TOP$i='TOP$i\|$ACO'"\$IP$i\|COUNTER\|$MAXWANP\|\$COL_$i\|$TYPE" +# eval AC_UIP$i='-UIP$i\|$ACI'"\$IP$i\|COUNTER\|$MAXWANP\|\$COL$i\|$TYPE" +# eval AC_UOP$i='UOP$i\|$ACO'"\$IP$i\|COUNTER\|$MAXWANP\|\$COL_$i\|$TYPE" +# eval AC_IIP$i='-IIP$i\|$ACI'"\$IP$i\|COUNTER\|$MAXWANP\|\$COL$i\|$TYPE" +# eval AC_IOP$i='IOP$i\|$ACO'"\$IP$i\|COUNTER\|$MAXWANP\|\$COL_$i\|$TYPE" +# # Traffic Statistics +# eval AC_TIB$i='-TIB$i\|$ACI'"\$IP$i\|COUNTER\|$MAXWANB\|\$COL$i\|$TYPE" +# eval AC_TOB$i='TOB$i\|$ACO'"\$IP$i\|COUNTER\|$MAXWANB\|\$COL_$i\|$TYPE" +# eval AC_UIB$i='-UIB$i\|$ACI'"\$IP$i\|COUNTER\|$MAXWANB\|\$COL$i\|$TYPE" +# eval AC_UOB$i='UOB$i\|$ACO'"\$IP$i\|COUNTER\|$MAXWANB\|\$COL_$i\|$TYPE" +# eval AC_IIB$i='-IIB$i\|$ACI'"\$IP$i\|COUNTER\|$MAXWANB\|\$COL$i\|$TYPE" +# eval AC_IOB$i='IOB$i\|$ACO'"\$IP$i\|COUNTER\|$MAXWANB\|\$COL_$i\|$TYPE" +# # Plot-Definitions (sort-order is relevant) +# AC_TB_O="$AC_TB_O TOB$i"; AC_TB_I="$AC_TB_I TIB$i" +# AC_TP_O="$AC_TP_O TOP$i"; AC_TP_I="$AC_TP_I TIP$i" +# AC_UB_O="$AC_UB_O UOB$i"; AC_UB_I="$AC_UB_I UIB$i" +# AC_UP_O="$AC_UP_O UOP$i"; AC_UP_I="$AC_UP_I UIP$i" +# AC_IB_O="$AC_IB_O IOB$i"; AC_IB_I="$AC_IB_I IIB$i" +# AC_IP_O="$AC_IP_O IOP$i"; AC_IP_I="$AC_IP_I IIP$i" +# TYPE=STACK +#done +#AC_TB="$AC_TB_O $AC_TB_I"; AC_TP="$AC_TP_O $AC_TP_I" +#AC_UB="$AC_UB_O $AC_UB_I"; AC_UP="$AC_UP_O $AC_UP_I" +#AC_IB="$AC_IB_O $AC_IB_I"; AC_IP="$AC_IP_O $AC_IP_I"; + +# Plot-Titles +#TB="TCP Traffic Accounting Stats ($HOSTNAME)"; TP="TCP Packet Accounting Stats ($HOSTNAME)" +#UB="UDP Traffic Accounting Stats ($HOSTNAME)"; UP="UDP Packet Accounting Stats ($HOSTNAME)" +#IB="ICMP Traffic Accounting Stats ($HOSTNAME)";IP="ICMP Packet Accounting Stats ($HOSTNAME)" + +# Data Definition needed by init() +#AC_ALL="$AC_TB $AC_TP $AC_UB $AC_UP $AC_IB $AC_IP" + + +# System Statistics +GRAPH_1="SYS|USG_STATS|$USG_STATS|Load" +GRAPH_2="SYS|CPU_STATS|$CPU_STATS|CPU-Time_in_%|1000|--upper-limit 100 --rigid --logarithmic --lower-limit 0.1" +GRAPH_3="SYS|MEM_STATS|$MEM_STATS|Bytes|1024" +GRAPH_4="SYS|DSK_STATS|$DSK_STATS|Bytes|1024" +GRAPH_5="SYS|MISC_STATS|$MISC_STATS|_|1000|--logarithmic" +GRAPH_6="SYS|IRQ_STATS|$IRQ_STATS|IRQ_per_second|1000" +# Interface Traffic Statistics +GRAPH_7="IF|LAN_TRAFFIC|$LAN_TRAFFIC|Bytes_per_second" +GRAPH_8="IF|LAN_PACKETS|$LAN_PACKETS|Packets_per_second" +GRAPH_9="IF|WAN_TRAFFIC|$WAN_TRAFFIC|Bytes_per_second" +GRAPH_10="IF|WAN_PACKETS|$WAN_PACKETS|Packets_per_second" +GRAPH_11="IF|WIFI_TRAFFIC|$WIFI_TRAFFIC|Bytes_per_second" +GRAPH_12="IF|WIFI_PACKETS|$WIFI_PACKETS|Packets_per_second" +#GRAPH_11="IF|TUN_TRAFFIC|$TUN_TRAFFIC|Bytes_per_second" +#GRAPH_12="IF|TUN_PACKETS|$TUN_PACKETS|Packets_per_second" +# Port Traffic Statistics +#GRAPH_13="PT|TRAFFIC_1|$TRAFFIC_1|Bytes_per_second" +#GRAPH_14="PT|PACKETS_1|$PACKETS_1|Packets_per_second" +#GRAPH_15="PT|TRAFFIC_2|$TRAFFIC_2|Bytes_per_second" +#GRAPH_16="PT|PACKETS_2|$PACKETS_2|Packets_per_second" +#GRAPH_17="PT|TRAFFIC_3|$TRAFFIC_3|Bytes_per_second" +#GRAPH_18="PT|PACKETS_3|$PACKETS_3|Packets_per_second" +#GRAPH_19="PT|TRAFFIC_4|$TRAFFIC_4|Bytes_per_second" +#GRAPH_20="PT|PACKETS_4|$PACKETS_4|Packets_per_second" +# Traffic Priorisation Statistics +# GRAPH_21="TC|TRAFFIC|$TRAFFIC|Bytes_per_second|1000|--logarithmic" +# GRAPH_22="TC|PACKETS|$PACKETS|Packets_per_second" +# Accounting Statistics +#GRAPH_23="AC|TB|$TB|Bytes_per_second" +#GRAPH_24="AC|TP|$TP|Packets_per_second" +#GRAPH_25="AC|UB|$UB|Bytes_per_second" +#GRAPH_26="AC|UP|$UP|Packets_per_second" +#GRAPH_27="AC|IB|$IB|Bytes_per_second" +#GRAPH_28="AC|IP|$IP|Packets_per_second" +# Firewall Drop Statistics +#GRAPH_29="PC|DROPPED|$DROPPED|Packets_per_second" + +#ALL_PRAEFIXES="SYS IF PT TC AC PC" +ALL_PRAEFIXES="SYS IF" +GRAPH_MAX=12 diff --git a/package/rrdcollect/files/rrd.sh b/package/rrdcollect/files/rrd.sh new file mode 100644 index 0000000000..3faa4fb8d7 --- /dev/null +++ b/package/rrdcollect/files/rrd.sh @@ -0,0 +1,288 @@ +#!/bin/sh +# +# Author: Christian Rost (chr@baltic-online.de) +# Purpose: Shell-Interface to rrdtool +# +RRDCNF=/etc/rrd.conf +. $RRDCNF + +###################################### +# init() function to create .rrd-file +# $1=VAR-PRAEFIX $2=VAR-POSTFIX +###################################### +init() +{ + # Calculate optimal step by assuming highest precision on the last-xhour plot + OPTSTEP=`expr $HOURS \* 3600 \/ $PIXWIDTH \* $H_RES` + [ $OPTSTEP != $STEP ] && echo "WARNING: Your optimal step is: $OPTSTEP. But you are using: $STEP" + + ARH_AVG=`expr $HOURS \* 3600 \/ $PIXWIDTH \* $H_RES \/ $STEP`; ARH_CNT=`expr $HOURS \* 3600 \/ $ARH_AVG \/ $STEP` + ARD_AVG=`expr $DAYS \* 86400 \/ $PIXWIDTH \* $D_RES \/ $STEP`; ARD_CNT=`expr $DAYS \* 86400 \/ $ARD_AVG \/ $STEP` + ARW_AVG=`expr $WEEKS \* 604800 \/ $PIXWIDTH \* $W_RES \/ $STEP`; ARW_CNT=`expr $WEEKS \* 604800 \/ $ARW_AVG \/ $STEP` + + PRAEFIX=$1; POSTFIX=$2 + DSOURCE="" + + echo "Init storage for $HOURS hours on averages: $ARH_AVG x $STEP seconds ($ARH_CNT total values)" + echo "Init storage for $DAYS days on averages: $ARD_AVG x $STEP seconds ($ARD_CNT total values)" + echo "Init storage for $WEEKS weeks on averages: $ARW_AVG x $STEP seconds ($ARW_CNT total values)" + + eval SOURCE=\$${PRAEFIX}_${POSTFIX} + for i in $SOURCE + do + eval var=\$${PRAEFIX}_${i} + ifs="$IFS"; IFS="|"; set -- $var + if [ "`echo ${1} | cut -b1`" = "-" ] + then + VAR="`echo ${1} | cut -b2-`" + else + VAR=`echo $1 | sed "s/ //g"` + fi + DSOURCE="$DSOURCE DS:${VAR}:${3}:$MAXSTEP:0:${4}" + IFS="$ifs" + done + $DEBUG $RRDTOOL create $RRDDIR/$PRAEFIX.rrd \ + --step ${STEP} \ + $DSOURCE \ + RRA:AVERAGE:0.5:$ARH_AVG:$ARH_CNT \ + RRA:AVERAGE:0.5:$ARD_AVG:$ARD_CNT \ + RRA:AVERAGE:0.5:$ARW_AVG:$ARW_CNT \ + RRA:MAX:0.5:$ARH_AVG:$ARH_CNT \ + RRA:MAX:0.5:$ARD_AVG:$ARD_CNT \ + RRA:MAX:0.5:$ARW_AVG:$ARW_CNT + return $? +} + +################################################################################################################# +# graph() function to create png-graphics +# $1=IMG-DIR $2=VAR-PRAEFIX, $3=VAR-POSTFIX, $4=Headline, $5=end, $6=start, $7=base, +# $8=DEFS/ENTRIES $9=other rrdgraph options (Vertlabel,...) +################################################################################################################# +# COMMENT:"$DATE\c" +do_rrdgraph() +{ + $DEBUG $NICE $RRDTOOL graph "$1/$2_$3.png" \ + --title "$4" \ + --imgformat $PIXFORMAT \ + --width $PIXWIDTH \ + --height $PIXHEIGHT \ + --end "$5" \ + --start "$6" \ + --base "$7" \ + $8 $9 +} + +################################################################################################################# +# graph() function to create png-graphics +# $1=IMG-DIR $2=VAR-PRAEFIX, $3=VAR-POSTFIX, $4=Headline, $5=end, $6=start, $7=base, +# $8=DEFS/ENTRIES $9=other rrdgraph options (Vertlabel,...) +################################################################################################################# +# COMMENT:"<RRD::TIME::NOW %c>\c" +do_rrdcgi() +{ + cat << EOF > $1/$2_$3.def + +<RRD::GRAPH $1/<RRD::CV START>$2_$3.png \ +--title "$4" \ +--imgformat $PIXFORMAT \ +--width $PIXWIDTH \ +--height $PIXHEIGHT \ +--end "$5" \ +--start <RRD::CV START> \ +--base $7 \ +--imginfo "<IMG NAME=$2_$3 SRC=$RRDCGIIMGPATH/%s OnClick=zoomToggle('${SCGIPIXWIDTH}px','${NCGIPIXWIDTH}px',this); WIDTH=${SCGIPIXWIDTH}px>" \ +--lazy \ +$8 $9 > +EOF + + cat << EOF >> $RRDCGISCRIPT +$NEWLINE <TD valign=top>$4<br> + <RRD::INCLUDE $1/$2_$3.def> +</TD> +EOF +} + + + +gen_cgi_header() +{ + cat << EOF > $RRDCGISCRIPT +#!$RRDCGI +<HEAD><TITLE>RRDCGI Router Statistics</TITLE></HEAD> +<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript"> +function update_radio_check(robj,value) { for (var i=0; i<robj.length; i++) if (robj[i].value==value) robj[i].checked=1; } +var nW,oW; +function zoomToggle(iWideSmall,iWideLarge,whichImage){ +oW=whichImage.style.width; +if(oW==iWideLarge){ +nW=iWideSmall;}else{ +nW=iWideLarge;} +whichImage.style.width=nW; +} +</SCRIPT> +<BODY onload="update_radio_check(document.RangeForm.START,'<RRD::CV START>')"> +<H1>RRDCGI Router Statistics <font size-=2><em>(<RRD::TIME::NOW %c>)</em></font></H1> +<FORM NAME=RangeForm> + <INPUT NAME=START TYPE=RADIO VALUE=end-${HOURS}h checked>${HOURS} hours ago + <INPUT NAME=START TYPE=RADIO VALUE=end-${DAYS}d>${DAYS} days ago + <INPUT NAME=START TYPE=RADIO VALUE=end-${WEEKS}w>${WEEKS} weeks ago + <INPUT TYPE=SUBMIT> +</FORM> +<P> +<TABLE> +EOF +} + +gen_cgi_footer() +{ + cat << EOF >> $RRDCGISCRIPT +</TABLE> +</P> +</BODY> +</HTML> +EOF + chmod +x $RRDCGISCRIPT +} + +################################################################################################################# +# $1=mode $2=VAR-PRAEFIX, $3=VAR-POSTFIX, $4=Headline, $5=Vertlabel, $6=start, $7=end, $8=base, $9=other rrdgraph options +################################################################################################################# +do_graph() +{ + MODE=$1; PRAEFIX=$2; POSTFIX=$3; HEADLINE=$4; VERTLABEL=$5; START=$6; END=$7; BASE=$8; SRC=${RRDDIR}/${PRAEFIX}.rrd + if [ ! -r "$SRC" ] + then + echo "$SRC not found. Aborting all operations now..." + exit 1 + fi + + # For Graphing Memory BASE should be set to 1024, default is 1000 + [ -n "$8" ] && BASE=$8 || BASE=1000 + [ -n "$9" ] && OPTS=$9 || OPTS="--lower-limit 0" + DEFS=""; ENTRIES="" + eval SOURCE=\$${PRAEFIX}_${POSTFIX} + for i in $SOURCE + do + eval var=\$${PRAEFIX}_${i} + ifs="$IFS"; IFS="|"; set -- $var + if [ "`echo ${1} | cut -b1`" = "-" ] + then + VAR="`echo ${1} | cut -b2-`" + NEG=1 + else + VAR=`echo $1 | sed "s/ //g"` + NEG=0 + fi + + if [ "$NEG" = 1 ] + then + [ -n "${8}" ] && DEFS="$DEFS DEF:${VAR}=$SRC:${VAR}:AVERAGE DEF:MAX${VAR}=$SRC:${VAR}:MAX ${8} CDEF:N${VAR}C=${VAR}C,-1,* " \ + || DEFS="$DEFS DEF:${VAR}=$SRC:${VAR}:AVERAGE DEF:MAX${VAR}=$SRC:${VAR}:MAX CDEF:N${VAR}=${VAR},-1,*" + else + [ -n "${8}" ] && DEFS="$DEFS DEF:${VAR}=$SRC:${VAR}:AVERAGE DEF:MAX${VAR}=$SRC:${VAR}:MAX ${8}" \ + || DEFS="$DEFS DEF:${VAR}=$SRC:${VAR}:AVERAGE DEF:MAX${VAR}=$SRC:${VAR}:MAX" + fi + # Now this is a bit ugly, but i don't know how to escape the blanks in a proper way. + # If you know any better way to keep the blanks in the legend of the graphics please inform me. + #L=`echo ${2} | tr -s "[= =]" '\014'` + #L=`echo ${2} | tr -s "[= =]" '_'` + L=`echo ${2} | sed "s/ /_/g"` + if [ -n "${7}" ] + then + if [ -n "${8}" ] + then + [ "$NEG" = 1 ] && ENTRIES="$ENTRIES ${6}:N${VAR}C${5}:${L}: GPRINT:${VAR}C:AVERAGE:Average\:${7} GPRINT:MAX${VAR}C:MAX:Max\:${7} GPRINT:${VAR}C:LAST:Last\:${7}\\j" \ + || ENTRIES="$ENTRIES ${6}:${VAR}C${5}:${L}: GPRINT:${VAR}C:AVERAGE:Average\:${7} GPRINT:MAX${VAR}C:MAX:Max\:${7} GPRINT:${VAR}C:LAST:Last\:${7}\\j" + else + [ "$NEG" = 1 ] && ENTRIES="$ENTRIES ${6}:N${VAR}${5}:${L}: GPRINT:${VAR}:AVERAGE:Average\:${7} GPRINT:MAX${VAR}:MAX:Max\:${7} GPRINT:${VAR}:LAST:Last\:${7}\\j" \ + || ENTRIES="$ENTRIES ${6}:${VAR}${5}:${L}: GPRINT:${VAR}:AVERAGE:Average\:${7} GPRINT:MAX${VAR}:MAX:Max\:${7} GPRINT:${VAR}:LAST:Last\:${7}\\j" + fi + else + [ "$NEG" = 1 ] && ENTRIES="$ENTRIES ${6}:N${VAR}${5}:${L}: GPRINT:${VAR}:AVERAGE:Average\:%6.2lf%s GPRINT:MAX${VAR}:MAX:Max\:%6.0lf%s GPRINT:${VAR}:LAST:Last\:%6.2lf%s\\j" \ + || ENTRIES="$ENTRIES ${6}:${VAR}${5}:${L}: GPRINT:${VAR}:AVERAGE:Average\:%6.2lf%s GPRINT:MAX${VAR}:MAX:Max\:%6.0lf%s GPRINT:${VAR}:LAST:Last\:%6.2lf%s\\j" + fi + IFS="$ifs" + done + + #[ "$POSTFIX" = "CPU_STATS" ] && (echo $OPTS; echo $DEFS ; echo $ENTRIES; echo $OPTS) + + $MODE "$IMGDIR" "$PRAEFIX" "$POSTFIX" "$HEADLINE" "$END" "$START" "$BASE" "$DEFS $ENTRIES" "--vertical-label $VERTLABEL $OPTS" +} + +# Check if all rrd-files are present +# and create them if not +init_loop() +{ + for j in $ALL_PRAEFIXES + do + if [ ! -f $RRDDIR/$j.rrd ] + then + echo "Creating $RRDDIR/$j.rrd ..." + init $j ALL + [ ! -f $RRDDIR/$j.rrd ] && EXIT=1 + fi + done + [ "$EXIT" = 1 ] && return 1 || return 0 +} + + +graph_loop() +{ + mode=$1; start=$2; end=$3; c=1 + while [ $c -le $GRAPH_MAX ] + do + eval var=\$GRAPH_${c} + # $1=VAR-PRAEFIX $2=VAR-POSTFIX $3=Headline $4=Vertlabel $5=base $6=other rrdgraph options + ifs="$IFS"; IFS="|"; set -- $var + IFS="$ifs" + [ "$1" != "$OLD" -o "`expr \( $c - 1 \) % 2`" = 0 ] && NEWLINE="</TR><TR>" || NEWLINE="" + do_graph $mode $1 $2 "$3" "$4" $start $end $5 "$6" + c=`expr $c + 1`; OLD=$1 + done +} + + +case "$1" in + init) + if init_loop + then + exit 0 + else + echo "Initialisation of rrd-database-files failed" + exit 1 + fi + ;; + cgi) + echo "Updating $RRDCGISCRIPT and $IMGDIR/*.def" + gen_cgi_header + # The start-time will be not used + graph_loop do_rrdcgi end now + gen_cgi_footer + ;; + images) + # Create the graphs + [ -n "$2" ] && STH=$2 || STH=24h + echo "Updating Graphs ($STH ago -> now) for $RRDDIR/*.rrd" + graph_loop do_rrdgraph "end-${STH}" now + ;; + fetch) + # Fetch data from rrdcollect daemon + if [ ! -n "$3" ] + then + echo "Usage: $0 fetch <host> <port>" + exit 1 + else + echo "Fetching ascii-logs from rrdcollect daemon" + (cd $RRDDIR && $NETCAT $2 $3 | sed -n "s:^\(update .*\):$RRDTOOL \1:p" | sh -x ) 2>&1 | wc -l #>/dev/null + exit 0 + fi + ;; + *) echo "Usage: $0 <init|cgi|fetch|images>" + echo " init: Initialize rrd-datafiles if neeeded" + echo " cgi: Creates cgi-script for use with rrdcgi" + echo " fetch: Fetching data from rrdcollect via netcat" + echo " images: Generates images" + exit 1 + ;; +esac +exit 0 diff --git a/package/rrdcollect/files/rrdcollect.conf b/package/rrdcollect/files/rrdcollect.conf index dfeb7b3bf4..232eccb6c4 100644 --- a/package/rrdcollect/files/rrdcollect.conf +++ b/package/rrdcollect/files/rrdcollect.conf @@ -1,5 +1,5 @@ step = 360 -directory = /var/lib/rra +directory = /var/lib/rrdcollect/rrd file:///proc/stat "cpu0 %d %d %d %d" SYS.rrd:cu,cn,cs,ci diff --git a/package/rrdcollect/files/rrdcollect.init b/package/rrdcollect/files/rrdcollect.init index dafb4624eb..a6089ba16d 100644 --- a/package/rrdcollect/files/rrdcollect.init +++ b/package/rrdcollect/files/rrdcollect.init @@ -3,14 +3,21 @@ BIN=rrdcollect DEFAULT=/etc/default/$BIN RUN_D=/var/run -RRA_D=/var/lib/rra PID_F=$RUN_D/$BIN.pid +LIB_D=/var/lib/rrdcollect +CGI_S=$LIB_D/rrd.cgi +IMG_D=$LIB_D/img +RRD_D=$LIB_D/rrd +RRD_F=$(find $RRD_D -name "*.rrd" 2>/dev/null) [ -f $DEFAULT ] && . $DEFAULT case $1 in start) mkdir -p $RUN_D - mkdir -p $RRA_D + mkdir -p $IMG_D + mkdir -p $RRD_D + [ -x $CGI_S ] || /usr/bin/rrd.sh cgi + [ -n "$RRD_D" ] || /usr/bin/rrd.sh init $BIN $OPTIONS ;; stop) |