![]() ![]() |
hotsanic |
Subversion Repositories: |
Compare with Previous - Blame - Download
#!/usr/bin/env shif ! [ -e settings ]; then OUTFILE="settings"; else OUTFILE="settings.new"; ficat > $OUTFILE << EOF# Which kind of legend shall be used# set STYLE="bytes" to display all values in bytes/s# set STYLE="bits" to display all values in bits/s#EOFvar=`cat settings|grep "^STYLE="`if [ "$var" = "" ]; then var="STYLE=\"bytes\""; fiecho "$var" >> $OUTFILEcat >> $OUTFILE << EOF# Shall input and output traffic be swaped ?# (possible values for "yes" are: "yes" "true" "1")#EOFvar=`cat settings|grep "^SWAPIO="`if [ "$var" = "" ]; then var="SWAPIO=\"no\""; fiecho "$var" >> $OUTFILEcat >> $OUTFILE << EOF# Use fixed-scale or dynamically scaled graphs. This affects ALL diagrams!# set SCALE="-1000" to use dynamically scaing with a minimum scale of# 1000 bytes/s (default)# set SCALE="12345" to set the fixed scale of the graphs to 12345 bytes/s## If nothing is defined here, the defaults (dynamic scaling with a minimum# scale of 1000 bytes/s) will be used#EOFvar=`cat settings|grep "^SCALE="`if [ "$var" = "" ]; then var="SCALE=\"-1000\""; fiecho "$var" >> $OUTFILEcat >> $OUTFILE <<EOF# Configure one line for each device that shall be sampled:## DEV=<device>,<max bytes/s input>,<max bytes/s output>,<description>## <device> is the network-device you like to sample## for SNMP queries the <device> entry has the following format:## SNMP:<host>:<community>:<interface>## <host> is the name or the IP of the host you want to query## <community> self explaining (for newbies: the community acts almost# like a "password" for SNMP)## <interface> the name of the interface on the remote-host## Examples:## DEV="eth0,12500000,12500000,100 MBit ethernet"# DEV="SNMP:192.168.1.1:public:eth0,12500000,12500000,100 MBit ethernet via SNMP"#EOF## configure interfaces#if [ "$OUTFILE" = "settings" ]; thencase `uname` in*BSD)INTERFACES=`ifconfig -l -u`;;*)INTERFACES=`netstat -ni|grep [0-9] |awk '{print $1}'|sed s/\*//|uniq`;;esacechoecho "Configuring local interfaces. Please answer these:"for nn in $INTERFACES; dowhere="x"while [ "$where" != "y" ] && [ "$where" != "n" ]; doecho -n "found: $nn - (y)es or (n)o ? "read wherecase $where inn) ;;y) echo "DEV=\"$nn,12500000,12500000,100 MBit Ethernet\"" >> $OUTFILE ;;*) echo "please answer with \"y\" or \"n\"" ;;esacechodonedoneecho >> $OUTFILEelsecat settings|grep "^DEV=" >> $OUTFILEfiechoecho "Please check the settings file and adapt it to satisfy your needs."echo "If you have any interfaces slower than 100 MBit, please change the"echo "corrosponding default values."echo "Maybe there are some additional interfaces or SNMP hosts you want"echo "to query."if [ "$OUTFILE" = "settings.new" ]; thenmkdir -p backupNOW=`date +%Y%m%d-%H%M%S`mv -f settings backup/settings-$NOWmv -f settings.new settingsecho "a backup of the previous settings has been saved."fiecho