Skip to content

Instantly share code, notes, and snippets.

@remyj38
Last active April 14, 2018 14:33
Show Gist options
  • Save remyj38/98e0d7ff9c0dc1feea596cf1dd5f3f8f to your computer and use it in GitHub Desktop.
Save remyj38/98e0d7ff9c0dc1feea596cf1dd5f3f8f to your computer and use it in GitHub Desktop.
[ABANDONNED] [WIP] Icinga installation from sources on raspberry pi zero
# Build Requirements
apt install -y libsystemd-dev cmake make build-essential pkg-config libssl-dev libboost-all-dev bison flex default-libmysqlclient-dev libyajl-dev libedit-dev nagios-plugins
# User and groups
groupadd icinga
groupadd icingacmd
useradd -c "icinga" -s /sbin/nologin -G icingacmd -g icinga icinga
usermod -a -G icingacmd www-data
# Download sources
cd /usr/src
wget -O- https://github.com/Icinga/icinga2/archive/v2.8.2.tar.gz | tar -xz
cd icinga2-2.8.2
# Create swap (500M of RAM is not suffisent for compiling Icinga)
dd if=/dev/zero of=/var/swap_file bs=1M count=4096
mkswap /var/swap_file
swapon /var/swap_file
# Build
cmake .. -DUSE_SYSTEMD=ON -DINSTALL_SYSTEMD_SERVICE_AND_INITSCRIPT=ON -DICINGA2_WITH_TESTS=OFF -DICINGA2_WITH_MYSQL=ON -DICINGA2_WITH_PGSQL=OFF
# Install
make install
chown icinga:icinga -R /usr/local/var/{cache,log,run}/icinga2/
# Installing MySQL server
apt install -y mariadb-server
mysql_secure_installation
MYSQL_PASSWORD=`openssl rand -hex 10`
echo "CREATE DATABASE icinga; GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD';" | mysql -uroot -p
echo "MySQL Icinga Login: icinga / $MYSQL_PASSWORD"
mysql -u root -p icinga < /usr/local/share/icinga2-ido-mysql/schema/mysql.sql
# Configuring icinga for MySQL
cat << EOF > /usr/local/etc/icinga2/features-available/ido-mysql.conf
library "db_ido_mysql"
object IdoMysqlConnection "ido-mysql" {
user = "icinga"
password = "$MYSQL_PASSWORD"
host = "localhost"
database = "icinga"
}
EOF
icinga2 feature enable ido-mysql
icinga2 api setup
API_PASSWORD=`openssl rand -hex 10`
cat << EOF >> /usr/local/etc/icinga2/conf.d/api-users.conf
object ApiUser "icingaweb2" {
password = "$API_PASSWORD"
permissions = [ "status/query", "actions/*", "objects/modify/*", "objects/query/*" ]
}
EOF
systemctl restart icinga2
# Installing Icinga Web 2
apt install -y apache2 libapache2-mod-php7.0 php7.0-curl php-gettext php7.0-intl php7.0-mbstring php7.0-xml php7.0-mysql php7.0-gd php-imagick
cd /usr/share
wget https://github.com/Icinga/icingaweb2/archive/v2.5.1.zip
unzip v2.5.1.zip
mv icingaweb2-2.5.1 icingaweb2
rm v2.5.1.zip
cd icingaweb2
./bin/icingacli setup config webserver apache --document-root /usr/share/icingaweb2/public --file=/etc/apache2/conf-available/icinga.conf
a2enconf icinga.conf
a2enmod rewrite
groupadd -r icingaweb2
usermod -a -G icingaweb2 www-data
service apache2 restart
WEB_MYSQL_PASSWORD=`openssl rand -hex 10`
echo "CREATE DATABASE icingaweb2;GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icingaweb2.* TO 'icingaweb2'@'localhost' IDENTIFIED BY '$WEB_MYSQL_PASSWORD';" | mysql -uroot -p
./bin/icingacli setup config directory
./bin/icingacli setup token create
echo "MySQL Icinga: icinga2 / $MYSQL_PASSWORD"
echo "MySQL Icinga Web: icingaweb2 / $WEB_MYSQL_PASSWORD"
echo "API : icingaweb2 / $API_PASSWORD"
echo "Go to http://`hostname`/icingaweb2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment