c_config.sh 900 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/sh
  2. # $Id: c_config.sh,v 1.4 2003/06/20 08:41:19 dijkstra Exp $
  3. #
  4. # Create an example configuration file for symon on a host and print to stdout
  5. # exit on errors, use a sane path and install prefix
  6. #
  7. set -e
  8. PATH=/bin:/usr/bin:/sbin:/usr/sbin
  9. # verify proper execution
  10. #
  11. if [ $# -ge 3 ]; then
  12. echo "usage: $0 [host] [port]" >&2
  13. exit 1
  14. fi
  15. interfaces=`netstat -ni | sed '1,1d;s/^\([a-z]*[0-9]\).*$/\1/g' | uniq`
  16. for i in $interfaces; do
  17. case $i in
  18. bridge*|enc*|gif*|gre*|lo*|pflog*|pfsync*|ppp*|sl*|tun*|vlan*)
  19. # ignore this interface
  20. ;;
  21. *)
  22. if="if($i), $if"
  23. ;;
  24. esac
  25. done
  26. io=`mount | egrep -v ' type mfs | type nfs ' | sed '1,1d;s/^\/dev\/\([a-z]*[0-9]\).*$/io(\1), /g' | uniq | tr -d \\\n`
  27. host=${1:-127.0.0.1}
  28. port=${2:-2100}
  29. cat <<EOF
  30. #
  31. # symon configuration generated by
  32. # `basename $0` $1 $2
  33. #
  34. monitor { $if
  35. $io
  36. cpu(0), mem } stream to $host $port
  37. EOF