#!/usr/bin/env sh

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

cat > $OUTFILE << EOF
# entries have the format:
# APP=<process>,<description>
#
# <process>	the name of the process to count as shown in 'ps'
#		(May also be 'SNMP:host:community:name')
# 
# Note: Be sure you have no '_' in host or community, because this will 
#       result in errors during sampeling and converting data.
#
# <description>	a brief description for the webpage
#
# Example:
#   APP=httpd,Apache
#   APP=SNMP:arthur:public:sshd,sshd@arthur
#
EOF

if [ "$OUTFILE" = "settings.new" ]; then
  cat settings | grep "^APP=" >> $OUTFILE
  fi

echo
echo "Please check the settings file and adapt it to satisfy your needs."
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

