From 313af9efa65641516ae41f1c1ea0549ee445e455 Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sun, 17 Apr 2022 12:30:41 -0400 Subject: Added sections for configuring director, monitoring module, and the web server. Fixed a few mistakes. --- monitoring/icinga-master | 99 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 32 deletions(-) diff --git a/monitoring/icinga-master b/monitoring/icinga-master index ed82bc5..f8cedd1 100755 --- a/monitoring/icinga-master +++ b/monitoring/icinga-master @@ -15,57 +15,60 @@ admin_user="admin" admin_password="changeme" # Install packages -apt install -y incinga2 icingaweb2 icinga2-ido-mysql icingaweb2-module-director \ - monitoring-plugins monitoring-plugins-contrib +apt install -y icinga2 icingaweb2 icinga2-ido-mysql icingaweb2-module-director \ + monitoring-plugins monitoring-plugins-contrib default-mysql-server # Secure mysql mysql_secure_installation # Create primary monitoring database -mysql -u root -e "CREATE DATABASE icinga2; -GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE -ON icinga2.* TO '$ido_user'@'localhost' IDENTIFIED BY '$ido_password'; -FLUSH PRIVILEGES; " -mysql -u root icinga2 /etc/icinga2/features-available/ido-mysql.conf icinga2 feature enable ido-mysql # Create icingaweb2 database -mysql -u root -e "CREATE DATABASE icingaweb2; -GRANT ALL ON icingaweb2.* TO '$icingaweb2_user'@'localhost' -IDENTIFIED BY '$icingaweb2_password'; -FLUSH PRIVILEGES;" -mysql icingaweb2 /etc/icingaweb2/roles.ini +# Configure monitoring module +echo "Configuring monitoring..." +echo "[icinga] +type = \"ido\" +resource = \"icinga2\" +" > /etc/icingaweb2/modules/monitoring/backends.ini +api_pass="$(grep password /etc/icinga2/conf.d/api-users.conf | tr -d ' "' | cut -d '=' -f 2)" +echo "[icinga2] +transport = \"api\" +host = \"$(hostname)\" +port = \"5665\" +username = \"root\" +password = \"$api_pass\" +" > /etc/icingaweb2/modules/monitoring/commandtransports.ini + +echo "[security] +protected_customvars = \"*pw*,*pass*,*community*\" +" > /etc/icingaweb2/modules/monitoring/config.ini + + # Configure director +echo "Configuring director..." echo "[db] resource = \"director\" " > /etc/icingaweb2/modules/director/config.ini - -echo "NOW\nBrowse to http://$(hostname)/icingaweb2/ and login as $admin_user" +icingacli module enable director +icingacli director migration run +echo "[config] +endpoint = \"monitoring.home.local\" +username = \"root\" +password = \"$api_pass\" +" > /etc/icingaweb2/modules/director/kickstart.ini +icingacli director kickstart run +icingacli director config render +icingacli director config deploy +shred -uz /etc/icingaweb2/modules/director/kickstart.ini + +echo "\n\nNOW\n\nBrowse to http://$(hostname)/icingaweb2/ and login as $admin_user" -- cgit v1.2.3