Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. #!/bin/bash
  2. ## Obserivum Client Setup Script
  3. ## v.0.5 - 12/15/13 - nunim@sonicboxes.com
  4. ## Tested on Debian 6/7 & Ubuntu 12.04+ - CentOS 5.8/6.4
  5. ## Useage: ./observium-client.sh <Community> <Contact Email>
  6. ## check if root
  7. if [ $(whoami) != "root" ]; then
  8. echo "You need to run this script as root."
  9. echo "Use 'sudo ./observium-client.sh' then enter your password when prompted."
  10. exit 1
  11. fi
  12. ## set community
  13. COMMUNITY=$1
  14. ## set contact email
  15. CONTACT=$2
  16. ## set hostname
  17. #HOSTNAME=$(hostname -f)
  18. ## set distro
  19. DISTRO=`cat /etc/*-release | grep -m 1 CentOS | awk {'print $1}'`
  20. ## check if community set
  21. if [ -z "$COMMUNITY" ] ; then
  22. echo "Community is not set"
  23. echo "Please run the script again with ./observium-client.sh <Community> <Contact Email>"
  24. exit
  25. fi
  26. ## check if contact email is set
  27. if [ -z "$CONTACT" ] ; then
  28. echo "Contact Email is not set"
  29. echo "Please run the script again with ./observium-client.sh <Community> <Contact Email>"
  30. exit
  31. fi
  32. ## set server location
  33. read -p "Please enter where the server is physically located: " LOCATION
  34. ## check distro
  35. if [ "$DISTRO" = "CentOS" ] ; then
  36. # clear yum cache
  37. yum clean all
  38. # install snmp daemon
  39. yum -y install net-snmp
  40. # set SNMP Daemon options
  41. sed -i.bak '/OPTIONS=/c\OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd.pid"' /etc/sysconfig/snmpd
  42. else
  43. # update package list
  44. apt-get update
  45. # install snmp daemon
  46. apt-get -y install snmpd
  47. # setup daemon options
  48. sed -i.bak "/SNMPDOPTS=/c\SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -p /var/run/snmpd.pid'" /etc/default/snmpd
  49. fi
  50. #setup /etc/snmp/snmpd.conf
  51. cat > /etc/snmp/snmpd.conf <<END
  52. com2sec readonly default $COMMUNITY
  53. group MyROGroup v1 readonly
  54. group MyROGroup v2c readonly
  55. group MyROGroup usm readonly
  56. view all included .1 80
  57. access MyROGroup "" any noauth exact all none none
  58. syslocation $LOCATION
  59. syscontact $CONTACT
  60. #This line allows Observium to detect the host OS if the distro script is installed
  61. extend .1.3.6.1.4.1.2021.7890.1 distro /usr/bin/distro
  62. END
  63. #get distro checking script
  64. wget https://raw.githubusercontent.com/tomzx/observium/svn-trunk/scripts/distro
  65. mv distro /usr/bin/distro
  66. chmod 755 /usr/bin/distro
  67. #restart snmpd
  68. /etc/init.d/snmpd restart
  69. /bin/systemctl restart snmpd.service
  70. #finished
  71. clear
  72. echo "#########################################################"
  73. echo "## !! !! Installation Complete !! !! ##"
  74. echo "#########################################################"
  75. echo "#You may add this server to your Observium installation #"
  76. echo "# using $COMMUNITY as the Community #"
  77. echo "#########################################################"
  78. echo "## Install Script by www.SonicBoxes.com ##"
  79. echo "#########################################################"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement