Install package
sudo apt-get update
sudo apt-get -y install apt-transport-https wget gnupg lsb-core
Import icinga2 key
wget https://packages.icinga.com/icinga.key
sudo apt-key add icinga.key
rm -f icinga.key
Add repo
sudo tee /etc/apt/sources.list.d/$(lsb_release -sc)-icinga.list <<EOF
deb https://packages.icinga.com/ubuntu icinga-$(lsb_release -sc) main
deb-src https://packages.icinga.com/ubuntu icinga-$(lsb_release -sc) main
EOF
Install icinga2
sudo apt-get update
sudo apt-get install -y icinga2
Install Monitor package
sudo apt-get install -y monitoring-plugins
Vim syntax Highlinght(no need no install)
sudo apt-get install -y vim-icinga2 vim-addon-manager
sudo vim-addon-manager -w install icinga2
Install Mysql
sudo apt-get -y install mysql-server libmysqlclient-dev
DB_PASSWORD=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 24`
echo -e "\033[31m YOUR DB PASSWORD IS $DB_PASSWORD \033[0m"
echo "DB_PASSWORD=$DB_PASSWORD" >> ~/.bashrc
mysql -u debian-sys-maint -p$(sudo cat /etc/mysql/debian.cnf|grep password|head -1|awk '{print $3}') \
-e "alter user root@'localhost' identified with mysql_native_password by '$DB_PASSWORD';"
# Create icinga db and set password
ICINGA_PASSWORD=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 24`
echo -e "\033[31m YOUR ICINGA PASSWORD IS $ICINGA_PASSWORD \033[0m"
echo "ICINGA_PASSWORD=$ICINGA_PASSWORD" >> ~/.bashrc
mysql -uroot -p$DB_PASSWORD -e "create database icinga;"
mysql -uroot -p$DB_PASSWORD -e "grant all on icinga.* to 'icinga'@'%' identified by '$ICINGA_PASSWORD';"
mysql -uroot -p$DB_PASSWORD -e "drop user 'debian-sys-maint'@'localhost';"
mysql -uroot -p$DB_PASSWORD -e "show databases;"
mysql -uroot -p$DB_PASSWORD -e "select user,host,authentication_string from mysql.user;"
mysql -uicinga -p$ICINGA_PASSWORD -e "show databases;"
sudo systemctl enable mysql
sudo systemctl restart mysql
Install icinga2 IDO module
---choose no
sudo apt-get install -y icinga2-ido-mysql
sudo icinga2 feature enable ido-mysql
mysql -uroot -p$DB_PASSWORD icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql
# host is your ip or cn
sudo tee /etc/icinga2/features-enabled/ido-mysql.conf << EOF
/**
* The db_ido_mysql library implements IDO functionality
* for MySQL.
*/
library "db_ido_mysql"
object IdoMysqlConnection "ido-mysql" {
user = "icinga",
password = "$ICINGA_PASSWORD",
host = "localhost",
database = "icinga"
}
EOF
sudo cat /etc/icinga2/features-enabled/ido-mysql.conf
sudo systemctl restart icinga2
sudo systemctl enable icinga2
install php
sudo apt-get install -y \
php7.0 \
php7.0-curl \
libapache2-mod-php7.0 \
php7.0-gd \
php7.0-intl \
php7.0-xml \
php7.0-ldap \
php7.0-mysql \
php7.0-pgsql \
php7.0-mbstring \
php7.0-fpm \
php7.0-json \
php7.0-common \
php7.0-cli \
php7.0-zip
# set your timezone
sudo sed -i '/;date.timezone =/s#.*#date.timezone = Asia/Shanghai#g' /etc/php/7.0/apache2/php.ini
sudo sed -i '/;date.timezone =/s#.*#date.timezone = Asia/Shanghai#g' /etc/php/7.0/fpm/php.ini
# restart php
sudo systemctl restart php7.0-fpm
sudo systemctl enable php7.0-fpm
Install icingaweb2 icingacli apache2
sudo apt-get install -y icingaweb2 icingacli
sudo apt-get install -y apache2
sudo systemctl restart apache2
sudo systemctl enable apache2
sudo groupadd -r icingaweb2
sudo usermod -a -G icingaweb2 www-data
sudo icingacli setup config directory --group icingaweb2
sudo systemctl restart icinga2 mysql apache2 php7.0-fpm
Install web2
1. create token
sudo icingacli setup token create
2. open web
http://10.0.0.100/icingaweb2/setup
paster token and next
3. choose all and next
4. next
5. Database next
6.
mysql -uroot -p$DB_PASSWORD -e "CREATE DATABASE icinga2web;"
mysql -uroot -p$DB_PASSWORD -e "GRANT all ON icinga2web.* TO 'icinga2web'@'%' IDENTIFIED BY 'icinga2web';"
Database Name: icinga2web
Username : icinga2web
Password :icinga2web
next
7. Backend Name
icingaweb2
next
8. set login admin user
user: admin
pwd:admin
Repeat password:admin
9. next
10.next
11.next
12. next
13.
Database Name icinga
Username icinga
Password $ICINGA_PASSWORD
cat ~/.bashrc | grep ICINGA
# install Icinga 2 API
sudo vim /etc/hosts
10.0.0.100 test.icinga.com
sudo icinga2 api setup --cn test.icinga.com
sudo systemctl restart icinga2
sudo cat /etc/icinga2/conf.d/api-users.conf
object ApiUser "root" {
password = "7c0b49534daa460b"
API Username: root
API Password : 7c0b49534daa460b
host: localhost
or
host: test.icinga.com
next
14. next
15. finish
16. login to icinga web2 user: admin pass: admin