Skip to content

Instantly share code, notes, and snippets.

@drolfe
Created December 23, 2015 11:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save drolfe/04b65121573e740c1c09 to your computer and use it in GitHub Desktop.
Save drolfe/04b65121573e740c1c09 to your computer and use it in GitHub Desktop.
Obserivum Client Setup Script
#!/bin/bash
## Obserivum Client Setup Script
## v.0.5 - 12/15/13 - nunim@sonicboxes.com
## Tested on Debian 6/7 & Ubuntu 12.04+ - CentOS 5.8/6.4
## Useage: ./observium-client.sh <Community> <Contact Email>
## check if root
if [ $(whoami) != "root" ]; then
echo "You need to run this script as root."
echo "Use 'sudo ./observium-client.sh' then enter your password when prompted."
exit 1
fi
## set community
COMMUNITY=$1
## set contact email
CONTACT=$2
## set hostname
#HOSTNAME=$(hostname -f)
## set distro
DISTRO=`cat /etc/*-release | grep -m 1 CentOS | awk {'print $1}'`
## check if community set
if [ -z "$COMMUNITY" ] ; then
echo "Community is not set"
echo "Please run the script again with ./observium-client.sh <Community> <Contact Email>"
exit
fi
## check if contact email is set
if [ -z "$CONTACT" ] ; then
echo "Contact Email is not set"
echo "Please run the script again with ./observium-client.sh <Community> <Contact Email>"
exit
fi
## set server location
read -p "Please enter where the server is physically located: " LOCATION
## check distro
if [ "$DISTRO" = "CentOS" ] ; then
# clear yum cache
yum clean all
# install snmp daemon
yum -y install net-snmp
# set SNMP Daemon options
sed -i.bak '/OPTIONS=/c\OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd.pid"' /etc/sysconfig/snmpd
else
# update package list
apt-get update
# install snmp daemon
apt-get -y install snmpd
# setup daemon options
sed -i.bak "/SNMPDOPTS=/c\SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -p /var/run/snmpd.pid'" /etc/default/snmpd
fi
#setup /etc/snmp/snmpd.conf
cat > /etc/snmp/snmpd.conf <<END
com2sec readonly default $COMMUNITY
group MyROGroup v1 readonly
group MyROGroup v2c readonly
group MyROGroup usm readonly
view all included .1 80
access MyROGroup "" any noauth exact all none none
syslocation $LOCATION
syscontact $CONTACT
#This line allows Observium to detect the host OS if the distro script is installed
extend .1.3.6.1.4.1.2021.7890.1 distro /usr/bin/distro
END
#get distro checking script
wget -O distro http://www.sonicboxes.com/scripts/resources/observium_distro
mv distro /usr/bin/distro
chmod 755 /usr/bin/distro
#restart snmpd
/etc/init.d/snmpd restart
/bin/systemctl restart snmpd.service
#finished
clear
echo "#########################################################"
echo "## !! !! Installation Complete !! !! ##"
echo "#########################################################"
echo "#You may add this server to your Observium installation #"
echo "# using $COMMUNITY as the Community #"
echo "#########################################################"
echo "## Install Script by www.SonicBoxes.com ##"
echo "#########################################################"
@abdqds
Copy link

abdqds commented Oct 17, 2017

Has it been tested on CentOS v7 by anyone ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment