don't dream your life, live your dreams !
Contents
I assume that you have a Centos installation
You can copy/paste this script and use it to configure automatically your server.
#!/bin/bash ################################################## # DEFINES ################################################## # all version are available here : https://download.centreon.com/ # tab "Centreon Core" CENTREON_ENGINE_VERSION=1.5.1 CENTREON_BROKER_VERSION=2.11.5 CENTREON_CONNECTOR_VERSION=1.1.2 CENTREON_CLIB_VERSION=1.4.2 # tab "Centreon Web" CENTREON_WEB_VERSION=2.7.7 # current directory BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ################################################## # PREREQUISTES ################################################## # cmake, gcc dnf -y install cmake make gcc gcc-c++ # qt dnf -y install qt qt-devel # librrd dnf -y install rrdtool rrdtool-devel # gnutls dnf -y install gnutls-devel # perl dnf -y install perl-devel perl-ExtUtils-Embed dnf -y install mailx # php dnf -y install php php-pear php-ldap php-intl # snmp dnf -y install net-snmp echo "create users abd groups" groupadd centreon useradd -g centreon centreon useradd -g centreon centreon-engine useradd -g centreon centreon-broker ################################################## # CENTREON BROKER ################################################## echo "create required folders" mkdir -p /var/log/centreon-broker mkdir -p /etc/centreon-broker chown centreon-broker: /var/log/centreon-broker/ -R chown centreon-broker: /etc/centreon-broker/ -R chmod 775 /var/log/centreon-broker/ -R chmod 775 /etc/centreon-broker/ -R echo "download and build centreon broker" cd /tmp wget https://s3-eu-west-1.amazonaws.com/centreon-download/public/centreon-broker/centreon-broker-$CENTREON_BROKER_VERSION.tar.gz tar -xvf centreon-broker-$CENTREON_BROKER_VERSION.tar.gz rm -f centreon-broker-$CENTREON_BROKER_VERSION.tar.gz cd centreon-broker-$CENTREON_BROKER_VERSION/build cmake \ -DWITH_STARTUP_DIR=/etc/init.d \ -DWITH_PREFIX_CONF=/etc/centreon-broker \ -DWITH_PREFIX_LIB=/usr/lib64/nagios \ -DWITH_PREFIX_MODULES=/usr/share/centreon/lib/centreon-broker \ . make make install # hack under centos 7 ("make install" does not create "cdb" service) if [ ! -f /etc/init.d/cdb ]; then cp $BASEDIR/cdb /etc/init.d chmod +x /etc/init.d/cdb fi ################################################## # CENTREON CONNECTOR ################################################## echo "download and build centreon connector" cd /tmp wget https://s3-eu-west-1.amazonaws.com/centreon-download/public/centreon-connectors/centreon-connector-$CENTREON_CONNECTOR_VERSION.tar.gz tar -xvf centreon-connector-$CENTREON_CONNECTOR_VERSION.tar.gz rm -f centreon-connector-$CENTREON_CONNECTOR_VERSION.tar.gz cd centreon-connector-$CENTREON_CONNECTOR_VERSION/perl/build cmake \ -DWITH_PREFIX_BINARY=/usr/lib64/centreon-connector \ . make -j 4 make install ################################################## # CENTREON CLIB ################################################## echo "download and build centreon clib" cd /tmp wget https://s3-eu-west-1.amazonaws.com/centreon-download/public/centreon-clib/centreon-clib-$CENTREON_CLIB_VERSION.tar.gz tar -xvf centreon-clib-$CENTREON_CLIB_VERSION.tar.gz rm -f centreon-clib-$CENTREON_CLIB_VERSION.tar.gz cd centreon-clib-$CENTREON_CLIB_VERSION/build cmake . make make install ln -s /usr/local/lib/libcentreon_clib.so /lib64/libcentreon_clib.so ################################################## # CENTREON ENGINE ################################################## echo "create required folders" mkdir -p /var/log/centreon-engine mkdir -p /etc/centreon-engine chown centreon-engine: /var/log/centreon-engine/ -R chown centreon-engine: /etc/centreon-engine/ -R chmod 775 /var/log/centreon-engine/ -R chmod 775 /etc/centreon-engine/ -R echo "download and build centreon engine" cd /tmp wget https://s3-eu-west-1.amazonaws.com/centreon-download/public/centreon-engine/centreon-engine-$CENTREON_ENGINE_VERSION.tar.gz tar -xvf centreon-engine-$CENTREON_ENGINE_VERSION.tar.gz rm -f centreon-engine-$CENTREON_ENGINE_VERSION.tar.gz cd centreon-engine-$CENTREON_ENGINE_VERSION/build cmake \ -DWITH_PREFIX_BIN=/usr/sbin \ -DWITH_RW_DIR=/var/lib64/centreon-engine/rw \ -DWITH_PREFIX_LIB=/usr/lib64/centreon-engine \ . make make install ################################################## # CENTREON WEB ################################################## cd /tmp wget https://s3-eu-west-1.amazonaws.com/centreon-download/public/centreon/centreon-web-$CENTREON_WEB_VERSION.tar.gz tar -xvf centreon-web-$CENTREON_WEB_VERSION.tar.gz rm -f centreon/centreon-web-$CENTREON_WEB_VERSION.tar.gz cd centreon-web-$CENTREON_WEB_VERSION # install centreon web : dos2unix $BASEDIR/centreon-response.txt ./install.sh -f $BASEDIR/centreon-response.txt ################################################## # POST INSTALLATION CONFIGURATION ################################################## echo "configure apache for apache 2.4" cat > /etc/httpd/conf.d/centreon.conf << "EOF" Alias /centreon /usr/local/centreon/www/ <Directory "/usr/local/centreon/www"> Options Indexes AllowOverride AuthConfig Options Require all granted </Directory> EOF echo "configure default timezone in php.ini" sed -i "s/^;\(date.timezone =\).*/\1Europe\/Paris/g" /etc/php.ini echo "enable write to SmartyCache directory" chown centreon: /usr/local/centreon/GPL_LIB/SmartyCache/ -R echo "restart httpd" systemctl restart httpd echo "add option 'innodb_file_per_table=1' to /etc/my.cnf" if ! grep -q innodb_file_per_table=1 /etc/my.cnf; then sed -i 's/\(\[mysqld\]\)/\1\ninnodb_file_per_table=1/' /etc/my.cnf systemctl restart mariadb.service fi; echo "create databases and grant amm privileges to user/password centreon/centreon": mysql --user=root --password=root -e "CREATE USER 'centreon'@'localhost' IDENTIFIED BY 'centreon';" mysql --user=root --password=root -e "CREATE DATABASE IF NOT EXISTS centreon;" mysql --user=root --password=root -e "use centreon; GRANT ALL PRIVILEGES ON centreon.* TO 'centreon'@'localhost' WITH GRANT OPTION;" mysql --user=root --password=root -e "CREATE DATABASE IF NOT EXISTS centreon_status;" mysql --user=root --password=root -e "use centreon_status; GRANT ALL PRIVILEGES ON centreon_status.* TO 'centreon'@'localhost' WITH GRANT OPTION;" ## meet you myip=`hostname -I` echo "Now meet you here: http://$myip/centreon/"
######################################################################### # Please choose what you want to install ######################################################################### # Do you want to install : Centreon Web Front PROCESS_CENTREON_WWW=1 #Do you want to install : Centreon CentCore PROCESS_CENTCORE=1 #Do you want to install : Centreon Nagios Plugins PROCESS_CENTREON_PLUGINS=1 #Do you want to install : CentreonTrapd process PROCESS_CENTREON_SNMP_TRAPS=1 # CentStorage ? PROCESS_CENTSTORAGE=1 ######################################################################## # Start CentWeb Installation ######################################################################## # Where is mail binary BIN_MAIL=/usr/bin/mail ################# INSTALLATION PATHS # Where is your Centreon directory? INSTALL_DIR_CENTREON=/usr/local/centreon # Where is your Centreon log directory CENTREON_LOG=/var/log/centreon # Where is your Centreon etc directory CENTREON_ETC=/etc/centreon # Where is your Centreon binaries directory CENTREON_BINDIR=/usr/local/centreon/bin # Where is your Centreon data information directory CENTREON_DATADIR=/usr/local/centreon/data # Where is your Centreon generation_files directory CENTREON_GENDIR=/usr/local/centreon # Where is your Centreon variable library directory CENTREON_VARLIB=/var/lib/centreon # Where is your CentPlugins Traps binary CENTPLUGINSTRAPS_BINDIR=/usr/local/centreon/bin ################# RRDs.pm # Where is the RRD perl module installed [RRDs.pm] RRD_PERL=`locate RRDs.pm` # Where is PEAR [PEAR.php] PEAR_PATH=/usr/share/pear ################# User and group centreon # What is the Centreon group ? [centreon] CENTREON_GROUP=centreon # What is the Centreon user ? [centreon] CENTREON_USER=centreon ################# Montoring user # What is the Monitoring engine user ? MONITORINGENGINE_USER=centreon-engine # What is the Broker user ? (optional) BROKER_USER=centreon-broker ################# Event log dir # What is the Monitoring engine log directory ? MONITORINGENGINE_LOG=/var/log/centreon-engine ################# Plugin folders # Where is your monitoring plugins (libexec) directory ? PLUGIN_DIR=/usr/lib64/nagios/plugins ######################################################################## # Configure Sudo ######################################################################## # Where is sudo configuration file SUDO_FILE=/etc/sudoers # What is the Monitoring engine init.d script ? MONITORINGENGINE_INIT_SCRIPT=/etc/init.d/centengine # What is the Monitoring engine binary ? MONITORINGENGINE_BINARY=/usr/local/bin/centengine # What is the Monitoring engine configuration directory ? MONITORINGENGINE_ETC=/etc/centreon-engine # Where is the configuration directory for broker module ? BROKER_ETC=/etc/centreon-broker # Where is the init script for broker module daemon ? BROKER_INIT_SCRIPT=/etc/init.d/cbd # Do you want me to configure your sudo ? (WARNING) FORCE_SUDO_CONF=1 ######################################################################## # Configure Apache server ######################################################################## # Do you want to reload your Apache ? APACHE_RELOAD=1 ######################################################################## # Pear Modules ######################################################################## # Do you want me to install/upgrade your PEAR modules PEAR_AUTOINST=1 ######################################################################## # Start CentStorage Installation ######################################################################## # Where is your Centreon Run Dir directory? CENTREON_RUNDIR=/var/run/centreon # Where is your CentStorage binary directory CENTSTORAGE_BINDIR=/usr/local/centreon/bin # Where is your CentStorage RRD directory CENTSTORAGE_RRD=/var/lib/centreon ######################################################################## # Start CentCore Installation ######################################################################## # Where is your CentCore binary directory CENTCORE_BINDIR=/usr/local/centreon/bin # Do you want me to install CentCore init script ? CENTCORE_INSTALL_INIT=1 # Do you want me to install CentCore run level CENTCORE_INSTALL_RUNLVL=1 ######################################################################## # Start CentPlugins Installation ######################################################################## # Where is your CentPlugins lib directory CENTPLUGINS_TMP=/var/lib/centreon/centplugins ######################################################################## # Start CentPlugins Traps Installation ######################################################################## # Where is your SNMP configuration directory SNMP_ETC=/etc/snmp # Where is your CentreonTrapd binaries directory CENTREONTRAPD_BINDIR=/usr/local/centreon/bin # Do you want me to install CentreonTrapd init script ? CENTREONTRAPD_INSTALL_INIT=1 # Do you want me to install CentreonTrapd run level ? CENTPLUGINSTRAPS_INSTALL_RUNLVL=1
Step 3, answer like this :
title | value | comments |
---|---|---|
Centreon Engine directory | /usr/sbin | because we used in cmake -DWITH_PREFIX_BIN=/usr/sbin |
Centreon Engine Stats binary | /usr/sbin/centenginestats | |
Centreon Engine var lib directory | /var/lib64/centreon-engine | because we used in cmake -DWITH_RW_DIR=/var/lib64/centreon-engine/rw |
Centreon Engine Connector path | /usr/lib64/centreon-connector | because we used in cmake -DWITH_PREFIX_BINARY=/usr/lib64/centreon-connector |
Centreon Engine Library (*.so) directory | /usr/lib/centreon-engine | because we used in cmake -DWITH_PREFIX_LIB=/usr/lib64/centreon-engine |
Step4, answer like this :
title | value | comments |
---|---|---|
Centreon Broker etc directory | /etc/centreon-broker | because we used in cmake -DWITH_PREFIX_CONF=/etc/centreon-broker |
Centreon Broker module (cbmod.so) | /usr/lib64/nagios/cbmod.so | because we used in cmake -DWITH_PREFIX_LIB=/usr/lib64/nagios |
Centreon Broker log directory | /var/log/centreon-broker | |
Retention file directory | /var/lib64/centreon-broker | |
Centreon Broker lib (*.so) directory | /usr/share/centreon/lib/centreon-broker | because we used in cmake -DWITH_PREFIX_MODULES=/usr/share/centreon/lib/centreon-broker |
That’s all 🙂
chmod 755 /etc/sudoers echo CENTREON ALL = NOPASSWD: ALL >> /etc/sudoers chmod 0440 /etc/sudoers |
Copyright © 2024 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.
admin