summaryrefslogtreecommitdiff
path: root/monitoring/icinga-master
diff options
context:
space:
mode:
authorSam Chudnick <sam@chudnick.com>2022-04-15 21:08:34 -0400
committerSam Chudnick <sam@chudnick.com>2022-04-15 21:08:34 -0400
commit85c561f9a32f8f2b9ddf34e7d60ef4b7bf0d3680 (patch)
tree637c319270201555d66f9bf1cbcc63d893405e69 /monitoring/icinga-master
inital commit - various scripts
Diffstat (limited to 'monitoring/icinga-master')
-rwxr-xr-xmonitoring/icinga-master120
1 files changed, 120 insertions, 0 deletions
diff --git a/monitoring/icinga-master b/monitoring/icinga-master
new file mode 100755
index 0000000..ed82bc5
--- /dev/null
+++ b/monitoring/icinga-master
@@ -0,0 +1,120 @@
1#!/bin/sh
2#
3# Configuration for an Iciniga2 master (with icingaweb2, director, and mysql backend)
4
5ido_user="icinga2"
6ido_password="changeme"
7
8icingaweb2_user="icingaweb2"
9icingaweb2_password="changeme"
10
11director_user="director"
12director_password="changeme"
13
14admin_user="admin"
15admin_password="changeme"
16
17# Install packages
18apt install -y incinga2 icingaweb2 icinga2-ido-mysql icingaweb2-module-director \
19 monitoring-plugins monitoring-plugins-contrib
20
21# Secure mysql
22mysql_secure_installation
23
24# Create primary monitoring database
25mysql -u root -e "CREATE DATABASE icinga2;
26GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE
27ON icinga2.* TO '$ido_user'@'localhost' IDENTIFIED BY '$ido_password';
28FLUSH PRIVILEGES; "
29mysql -u root icinga2 </usr/share/icinga2-ido-mysql/scheme/mysql.sql
30echo "library \"db_ido_mysql\"
31object IdoMysqlConnection \"ido-mysql\" {
32 user = \"$ido_user\",
33 password = \"$ido_password\",
34 host = \"localhost\",
35 databse = \"icinga2\"
36}" > /etc/icinga2/features-available/ido-mysql.conf
37icinga2 feature enable ido-mysql
38
39# Create icingaweb2 database
40mysql -u root -e "CREATE DATABASE icingaweb2;
41GRANT ALL ON icingaweb2.* TO '$icingaweb2_user'@'localhost'
42IDENTIFIED BY '$icingaweb2_password';
43FLUSH PRIVILEGES;"
44mysql icingaweb2 </usr/share/icingaweb2/etc/scheme/mysql.schema.sql
45# Create initial admin user to login to icingaweb2
46passhash="$(php -r "echo password_hash(\"$admin_password\", PASSWORD_DEFAULT);")"
47mysql -u root -e "USE icingaweb2;
48INSERT INTO icingaweb_user (name, active, password_hash)
49VALUES (\"$admin_user\", 1, \"$passhash\");
50FLUSH PRIVILEGES; "
51
52# Create director database
53mysql -u root -e "CREATE DATABASE director CHARACTER SET 'utf8';
54GRANT ALL on director.* TO '$director_user'@'localhost'
55IDENTIFIED BY '$director_password';
56FLUSH PRIVILEGES;"
57icingacli module enable director
58icingacli director migration run --verbose
59
60# Setup API
61icinga2 api setup
62
63# Restart service
64systemctl restart icinga2
65
66
67# -- Icingaweb2 Configuration --
68
69# Configure authentication
70echo "[icingaweb2]
71backend = \"db\"
72resource = \"icingaweb2\"
73" > /etc/icingaweb2/authentication.ini
74
75# Configure resources
76echo "[icinga2]
77type = \"db\"
78db = \"mysql\"
79host \"localhost\"
80port = \"\"
81dbname = \"icinga2\"
82username = \"$icinga2_user\"
83password = \"$icinga2_password\"
84charset = \"\"
85use_ssl = \"0\"
86
87[icingaweb2]
88type = \"db\"
89db = \"mysql\"
90host \"localhost\"
91port = \"\"
92dbname = \"icingaweb2\"
93username = \"$icingaweb2_user\"
94password = \"$icingaweb2_password\"
95charset = \"\"
96use_ssl = \"0\"
97
98[icingaweb2]
99type = \"db\"
100db = \"mysql\"
101host \"localhost\"
102port = \"\"
103dbname = \"director\"
104username = \"$director_user\"
105password = \"$director_password\"
106charset = \"utf8\"
107use_ssl = \"0\"
108" > /etc/icingaweb2/resources.ini
109
110# Configure roles
111echo "[admins]
112users = \"$admin_user\"
113permissions = \"*\" " > /etc/icingaweb2/roles.ini
114
115# Configure director
116echo "[db]
117resource = \"director\"
118" > /etc/icingaweb2/modules/director/config.ini
119
120echo "NOW\nBrowse to http://$(hostname)/icingaweb2/ and login as $admin_user"