You are here

OpsView automated installation script

2 posts / 0 new
Last post
sschwiedel
sschwiedel's picture
OpsView automated installation script

Hi,

OS= CentOS/RedHat 6

just in case someone is interested in. Here is a working install script for opsview enterprise server with default packages and default mysql/http packages.

It`s not using subroutines and it`s easy to read for everyone. Feel free to use it.

1.You need to configure the repo and all passwords in this script.

2.The nagios user has to created already.

3. The default Modem is here Cinterion (compatible MC35i and CT63), change it to your needs

#!/bin/bash

#Password must not contain RegEx Characters otherwise it must be excluded like \. dbRootPw='<db root password here>' dbOdwPw='<db ODW password here>' dbRuntimePw='<db runtime password here>' dbDashboardPw='<db dashboard password here>' dbJasperPw='<db jasper password here>' dbSmsGatewayPw='<db SMSgateway password here>' countryCode='<your country code here e.g. 49 for germany>' smsPinCode='<GSM modem pin here>' slaveserver='<Slave server fqdn here>'   installReporting=yes installSmsGateway=yes installSlaveServer=yes #not yet working fully automated because of manual key exchange   # usercreation is done by puppet but you can do it manually or add it to the script   cat > /etc/yum.repos.d/opsview.repo << EOF [OpsView] name=OpsView CentOS baseurl=http://localrepo.nodomain.com/repo/OpsView-\$basearch/RPMS.centos-\$releasever enabled=1 gpgcheck=0 EOF   yum -y install opsview-perl opsview opsview-base opsview-web mod_auth_tkt_opsview opsview-core &   #wait until yum installed all packages wait   /etc/init.d/mysqld start; echo '' | mysqladmin -u root -p password ${dbRootPw} chkconfig --level 345 mysqld on   su - nagios -c 'echo "test -f /usr/local/nagios/bin/profile && . /usr/local/nagios/bin/profile" >> ~/.bash_profile'   #Set dbpassword su - nagios -c "sed -i '0,/changeme/s/changeme/${dbRootPw}/'  /usr/local/nagios/etc/opsview.conf" & wait #Set odw db password su - nagios -c "sed -i '0,/changeme/s/changeme/${dbOdwPw}/g'  /usr/local/nagios/etc/opsview.conf" & wait #Set runtime_db_password su - nagios -c "sed -i '0,/changeme/s/changeme/${dbRuntimePw}/g'  /usr/local/nagios/etc/opsview.conf" & wait #Set dashboard db password su - nagios -c "sed -i '0,/changeme/s/changeme/${dbDashboardPw}/g'  /usr/local/nagios/etc/opsview.conf" & wait   su - nagios -c "/usr/local/nagios/bin/db_mysql -u root -p ${dbRootPw}" & wait su - nagios -c '/usr/local/nagios/bin/db_opsview db_install' & wait su - nagios -c '/usr/local/nagios/bin/db_runtime db_install' & wait su - nagios -c '/usr/local/nagios/bin/db_odw db_install' & wait su - nagios -c '/usr/local/nagios/bin/db_dashboard db_install' & wait   su - nagios -c '/usr/local/nagios/bin/rc.opsview gen_config' & wait su - nagios -c '/etc/init.d/opsview-web start' & wait   #Configure ReverseProxy for Jasper cat > /etc/httpd/conf.d/OpsView.conf << EOF Include /usr/local/opsview-web/etc/apache_proxy.conf EOF   sed -i 's/^DocumentRoot/#DocumentRoot/' /etc/httpd/conf/httpd.conf usermod -G nagcmd apache service httpd restart chkconfig --level 345 httpd on   if [ $installReporting == 'yes' ];then ############################# # OpsView Reporting Module configuration #############################   yum -y install opsview-reporting-module opsview-jasper dejavu-lgc* liberation-fonts xorg-x11-fonts* & wait   cp /opt/opsview/jasper/etc/jasper.defaults /opt/opsview/jasper/etc/jasper.conf   #Set dbpassword sed -i "0,/password/s/password/${dbJasperPw}/g"  /opt/opsview/jasper/etc/jasper.conf   #Setup mysql permissions /opt/opsview/jasper/bin/db_mysql -u root -p ${dbRootPw} & wait   #Install JasperDB /opt/opsview/jasper/bin/db_jasper db_install & wait   fi   if [ $installSmsGateway == 'yes' ];then ########################################## # Install sms gateway ##########################################   yum -y install opsview-smsgateway & wait #Set dbpassword sed -i "0,/changeme/s/changeme/${dbSmsGatewayPw}/g"  /etc/opt/opsview/smsgateway/smsqueued.conf sed -i "0,/\+44/s/\+44/\+${countryCode}/g"  /etc/opt/opsview/smsgateway/smsqueued.conf sed -i 's/process_sms_frequency = 2/process_sms_frequency = 30/g'  /etc/opt/opsview/smsgateway/smsqueued.conf   #change settings before installing database to support cinterion GSM Modem sed -i '0,/init_string varchar(16)/s/varchar(16)/varchar(20)/g' /opt/opsview/smsgateway/bin/rc.smsgateway sed -i '/Wavecom/a INSERT INTO profiles (id, name, init_string, baudrate) VALUES (4, "Cinterion", "AT+CNMI=2,0,0,2,1", "115200");' /opt/opsview/smsgateway/bin/rc.smsgateway sed -i '0,/Profile/s/Maestro 100/Cinterion/g' /opt/opsview/smsgateway/bin/altinity.pl   # copy the check_smsgateway to libexec and create a service check for it cp /opt/opsview/smsgateway/bin/check_smsgateway /usr/local/nagios/libexec/ chown nagios:nagios /opt/opsview/smsgateway/bin/check_smsgateway   # install DB /opt/opsview/smsgateway/bin/rc.smsgateway -p ${dbRootPw} db_install echo ${smsPinCode} | /opt/opsview/smsgateway/bin/altinity.pl   #test configuration /opt/opsview/smsgateway/bin/device_admin test Primary fi   ### Here we have to do some manual steps if [ $installSlaveServer == 'yes' ];then ###################################### # OpsView Slave Setup -> Slave must already be ready ###################################### echo "create keys first and deploy to targetserver" echo -e "Is it done? [y|N]" read answer if [ "$answer" == y ];then  echo "execute the following commands manually:"  echo "ssh-copy-id -i ~/.ssh/id_dsa.pub ${slaveserver}"  echo 'follow the instructions from the slave setup wiki' fi su - nagios -c "mkdir ~/.ssh/" su - nagios -c "chmod 600 ~/.ssh/" su - nagios -c "chown nagios:nagcmd ~/.ssh/" su - nagios -c "echo 'LogLevel=Error' > ~/.ssh/config" su - nagios -c "chmod 640 ~/.ssh/config"   fi   ###########i############### #Restart all services ###########i############### chkconfig --level 345 opsview-reporting-module on service opsview-reporting-module restart service opsview restart service opsview-web restart service httpd restart service opsview-smsqueued restart  
smarsh
smarsh's picture
Re: OpsView automated installation script

Hi,

This is great - thanks!

Sam