jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [traffic/] [setup] - Rev 15 Go to most recent revision

Compare with Previous - Blame - Download


#!/usr/bin/env sh

if ! [ -e settings ]; then OUTFILE="settings"; else OUTFILE="settings.new"; fi

cat > $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
#
EOF
var=`cat settings|grep "^STYLE="`
if [ "$var" = "" ]; then var="STYLE=\"bytes\""; fi
echo "$var" >> $OUTFILE

cat >> $OUTFILE << EOF

# Shall input and output traffic be swaped ?
# (possible values for "yes" are: "yes" "true" "1")
#
EOF
var=`cat settings|grep "^SWAPIO="`
if [ "$var" = "" ]; then var="SWAPIO=\"no\""; fi
echo "$var" >> $OUTFILE

cat >> $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 
#
EOF
var=`cat settings|grep "^SCALE="`
if [ "$var" = "" ]; then var="SCALE=\"-1000\""; fi
echo "$var" >> $OUTFILE

cat >> $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" ]; then
  case `uname` in
    *BSD)
      INTERFACES=`ifconfig -l -u`
      ;;
    *)
      INTERFACES=`netstat -ni|grep [0-9] |awk '{print $1}'|sed s/\*//|uniq`
      ;;
  esac

  echo
  echo "Configuring local interfaces. Please answer these:"
  for nn in $INTERFACES; do
    where="x"
    while [ "$where" != "y" ] && [ "$where" != "n" ]; do
      echo -n "found: $nn  -  (y)es or (n)o ? "
      read where
      case $where in
        n) ;;
        y) echo "DEV=\"$nn,12500000,12500000,100 MBit Ethernet\"" >> $OUTFILE ;;
        *) echo "please answer with \"y\" or \"n\"" ;;
        esac
      echo
      done
    done
  echo >> $OUTFILE
else
  cat settings|grep "^DEV=" >> $OUTFILE
  fi

echo
echo "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" ]; then
  mkdir -p backup
  NOW=`date +%Y%m%d-%H%M%S`
  mv -f settings backup/settings-$NOW
  mv -f settings.new settings
  echo "a backup of the previous settings has been saved."
  fi
echo


Powered by WebSVN 2.2.1