Project

General

Profile

Distributed Icinga2 » History » Version 2

Jon Goldberg, 06/09/2017 05:00 AM

1 1 Jon Goldberg
# Distributed Icinga2
2
3
### Overview
4
5
With a single instance of Icinga2, we can check the status of remote services that are publicly accessible.  For instance, we can check if SSH responds on a remote host.  However, we can NOT check information that is not publicly accessible - for instance, whether the remote server has low disk space.
6
7
To handle this, we use a distributed Icinga2 infrastructure.  Our original Icinga instance becomes a **master** instance.  We also install a minimal version of Icinga on remote servers, known as **satellite** instances.  Icinga2 has a wizard that establishes encrypted communication links between servers.  We use a [top-down configuration](https://docs.icinga.com/icinga2/latest/doc/module/icinga2/chapter/distributed-monitoring#distributed-monitoring-top-down), which means that all checks are initiated from the master instance - but some service checks are configured to run on a different endpoint.
8
9
In our instance, that means that some checks run entirely on the master - e.g. an SSH check - but a "low disk space" check is scheduled on the master instance, which contacts the satellite, instructs it to run the plugin, and return the result.
10
### Installing Icinga2 as a Satellite
11
12
Source: https://www.olindata.com/blog/2015/03/monitoring-remote-systems-icinga-2
13
14
Run these commands on the satellite (assumes the satellite OS is Ubuntu)
15 2 Jon Goldberg
16 1 Jon Goldberg
```
17
apt install software-properties-common
18
add-apt-repository ppa:formorer/icinga
19
apt update
20
apt install icinga2
21
systemctl enable icinga2.service
22
systemctl start icinga2.service
23
# Get the salt from the master node in /etc/icinga2/constants.conf
24
icinga2 pki ticket --cn 'icinga.jmaconsulting.biz' --salt <salt goes here>
25
icinga2 node wizard
26
```
27
Alternate instructions for Debian Jessie:
28 2 Jon Goldberg
29 1 Jon Goldberg
```
30
# Note: Ensure you have jessie-backports enabled: https://backports.debian.org/Instructions/
31
apt install software-properties-common
32
apt-get -t jessie-backports install icinga2
33
# Debian installs some some host definitions that interfere with being a satellite; delete them
34
rm -rf /etc/icinga2/conf.d/hosts
35
systemctl enable icinga2.service
36
systemctl start icinga2.service
37
# Get the salt from the master node in /etc/icinga2/constants.conf
38
icinga2 pki ticket --cn 'orange.megaphonetech.com' --salt <salt goes here>
39
icinga2 node wizard
40
```
41
Here's an example of the node wizard setup for a red.megaphonetech.com:
42 2 Jon Goldberg
43 1 Jon Goldberg
```
44
Please specify if this is a satellite setup ('n' installs a master setup) [Y/n]: 
45
Starting the Node setup routine...
46
Please specify the common name (CN) [rh6.jmaconsulting.biz]: 
47
Please specify the master endpoint(s) this node should connect to:
48
Master Common Name (CN from your master setup): icinga.jmaconsulting.biz
49
Do you want to establish a connection to the master from this node? [Y/n]: 
50
Please fill out the master connection information:
51
Master endpoint host (Your master's IP address or FQDN): icinga.jmaconsulting.biz
52
Master endpoint port [5665]: 
53
Add more master endpoints? [y/N]: 
54
Please specify the master connection for CSR auto-signing (defaults to master endpoint host):
55
Host [icinga.jmaconsulting.biz]: 
56
Port [5665]: 
57
information/base: Writing private key to '/etc/icinga2/pki/rh6.jmaconsulting.biz.key'.
58
information/base: Writing X509 certificate to '/etc/icinga2/pki/rh6.jmaconsulting.biz.crt'.
59
information/cli: Fetching public certificate from master (icinga.jmaconsulting.biz, 5665):
60
61
Certificate information:
62
63
 Subject:     CN = icinga.jmaconsulting.biz
64
 Issuer:      CN = Icinga CA
65
 Valid From:  Jan 25 23:12:52 2017 GMT
66
 Valid Until: Jan 22 23:12:52 2032 GMT
67
 Fingerprint: B7 DC AF 0C F7 B2 EF DD C9 8F 34 99 5C C2 9A 86 57 9C D2 B0 
68
69
Is this information correct? [y/N]: Y
70
information/cli: Received trusted master certificate.
71
72
Please specify the request ticket generated on your Icinga 2 master.
73
 (Hint: # icinga2 pki ticket --cn 'rh6.jmaconsulting.biz'): #Run this command on the master to generate a ticket number
74
information/cli: Requesting certificate with ticket '00a2aff74b3b3145630504276912a9addd714810'.
75
76
information/cli: Created backup file '/etc/icinga2/pki/rh6.jmaconsulting.biz.crt.orig'.
77
information/cli: Writing signed certificate to file '/etc/icinga2/pki/rh6.jmaconsulting.biz.crt'.
78
information/cli: Writing CA certificate to file '/etc/icinga2/pki/ca.crt'.
79
Please specify the API bind host/port (optional):
80
Bind Host []: 
81
Bind Port []: 
82
Accept config from master? [y/N]: Y
83
Accept commands from master? [y/N]: Y
84
information/cli: Disabling the Notification feature.
85
Disabling feature notification. Make sure to restart Icinga 2 for these changes to take effect.
86
information/cli: Enabling the Apilistener feature.
87
Enabling feature api. Make sure to restart Icinga 2 for these changes to take effect.
88
information/cli: Created backup file '/etc/icinga2/features-available/api.conf.orig'.
89
information/cli: Generating local zones.conf.
90
information/cli: Dumping config items to file '/etc/icinga2/zones.conf'.
91
information/cli: Created backup file '/etc/icinga2/zones.conf.orig'.
92
information/cli: Updating constants.conf.
93
information/cli: Created backup file '/etc/icinga2/constants.conf.orig'.
94
information/cli: Updating constants file '/etc/icinga2/constants.conf'.
95
information/cli: Updating constants file '/etc/icinga2/constants.conf'.
96
Done.
97
```
98
Now run `service icinga2 checkconfig && service icinga2 restart` to finish the installation on the satellite.
99
### Create Zones and Endpoints
100
101
You must also set up the `Zone` and `Endpoint` objects, stored in `/etc/icinga2/zones.conf`. In our model, each zone contains one and only one endpoint.
102
#### Zones and Endpoints on the Satellite
103
104
The node wizard mostly handles this for you on the satellite, it will generate a file with these constants.  Note that NodeName and ZoneName are defined in /etc/icinga2/constants.conf, and should both be the name of the host.
105 2 Jon Goldberg
106 1 Jon Goldberg
```
107
object Endpoint "orange.megaphonetech.com" {
108
        host = "orange.megaphonetech.com"
109
        port = "5665"
110
}
111
112
object Zone "master" {
113
        endpoints = [ "orange.megaphonetech.com" ]
114
}
115
116
object Endpoint NodeName {
117
}
118
119
object Zone ZoneName {
120
        endpoints = [ NodeName ]
121
        parent = "master"
122
}
123
```
124
Add the following Zone object on your satellite.  Files in this zone are synced to all Icinga2 instances, so you can distribute many configuration files this way:
125 2 Jon Goldberg
126 1 Jon Goldberg
```
127
/* sync global commands */
128
object Zone "global-templates" {
129
        global = true
130
}
131
```
132
#### Zones and Endpoints on the Master
133
134
Edit `/etc/icinga2/zones.conf`.  Add the Zone and Endpoint of the new satellite.  For instance, if the satellite has a ZoneName and NodeName of database.lavabrooklyn.org defined in its constants /etc/icinga2/constants.conf then you should add these objects on the master:
135 2 Jon Goldberg
136 1 Jon Goldberg
```
137
object Endpoint "database.lavabrooklyn.org" {
138
}
139
140
object Zone "database.lavabrooklyn.org" {
141
        endpoints = [ "database.lavabrooklyn.org" ]
142
        parent = "master"
143
}
144
```
145
#### Testing the Zones/Endpoints
146
147
After reloading Icinga2 on both satellite and master, you should be able to see the new checks reflected in Icingaweb2 immediately, though they might be listed as "Pending".  Click "Check now" to ensure they're working as expected.
148
### How to change a satellite's hostname
149
150
    Re-run `icinga2 node wizard` on the satellite.  This will fix the satellite's "constants.conf" and "zones.conf".
151
    Edit `/etc/icinga2/zones.conf` Zone and Endpoint on the master to change the name.