Install Icinga2 and Icingaweb2 » History » Version 16
Jon Goldberg, 03/28/2019 08:04 PM
| 1 | 1 | Jon Goldberg | {{last_updated_at}} by {{last_updated_by}} |
|---|---|---|---|
| 2 | # Install Icinga2 and Icingaweb2 |
||
| 3 | |||
| 4 | {{>toc}} |
||
| 5 | |||
| 6 | ### Installation (Master Node) |
||
| 7 | |||
| 8 | 4 | Jon Goldberg | Steps are adapted from [this guide](http://linoxide.com/ubuntu-how-to/install-icinga2-ubuntu-16-04/). |
| 9 | 1 | Jon Goldberg | |
| 10 | 4 | Jon Goldberg | #### Install Icinga2 |
| 11 | 11 | Jon Goldberg | ```bash |
| 12 | 5 | Jon Goldberg | # Install MySQL if you haven't yet |
| 13 | |||
| 14 | 16 | Jon Goldberg | # These lines for Ubuntu 18.04 only: |
| 15 | curl https://packages.icinga.com/icinga.key | apt-key add - |
||
| 16 | echo "deb http://packages.icinga.com/ubuntu icinga-bionic main" > /etc/apt/sources.list.d/bionic-icinga.list |
||
| 17 | 4 | Jon Goldberg | apt update |
| 18 | apt-get install icinga2 |
||
| 19 | 5 | Jon Goldberg | apt-get install icinga2-ido-mysql |
| 20 | 4 | Jon Goldberg | |
| 21 | # These 3 lines for Debian 8 only: |
||
| 22 | echo 'deb http://ftp.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/jessie-backports.list |
||
| 23 | apt-get update |
||
| 24 | 1 | Jon Goldberg | apt-get -t jessie-backports install icinga2 |
| 25 | 5 | Jon Goldberg | apt-get -t jessie-backports install icinga2-ido-mysql |
| 26 | 4 | Jon Goldberg | |
| 27 | systemctl enable icinga2.service |
||
| 28 | 1 | Jon Goldberg | systemctl start icinga2.service |
| 29 | 5 | Jon Goldberg | apt install nagios-plugins |
| 30 | # nagios-plugins has Samba as a dependency, but you should remove it. |
||
| 31 | apt remove samba-common samba-libs |
||
| 32 | icinga2 feature enable ido-mysql |
||
| 33 | systemctl restart icinga2.service |
||
| 34 | |||
| 35 | 4 | Jon Goldberg | ``` |
| 36 | 1 | Jon Goldberg | |
| 37 | 5 | Jon Goldberg | #### Install Icingaweb2 |
| 38 | ```bash |
||
| 39 | apt install icingaweb2 |
||
| 40 | 4 | Jon Goldberg | ``` |
| 41 | 6 | Jon Goldberg | * Go to http://<your IP>/icingaweb2/setup. |
| 42 | * Finish from here: https://linoxide.com/ubuntu-how-to/install-icinga2-ubuntu-16-04, starting with "Configuring Icinga Web2 plugin" |
||
| 43 | 1 | Jon Goldberg | |
| 44 | ### Configuration |
||
| 45 | |||
| 46 | - Run `icinga2 node wizard. `Select "N" to create a master node. |
||
| 47 | 8 | Jon Goldberg | - Enable the api and command module to allow issuing commands from Icingaweb2 and to allow API: |
| 48 | `icinga2 feature enable api command; service icinga2 restart` |
||
| 49 | 1 | Jon Goldberg | - Add an API user for remote checks. For instance, a user that can |
| 50 | 9 | Jon Goldberg | receive backupninja checks. Add this to `/etc/icinga2/conf.d/api-users.conf`: |
| 51 | 1 | Jon Goldberg | |
| 52 | 11 | Jon Goldberg | ``` |
| 53 | 1 | Jon Goldberg | object ApiUser "backupninja" { |
| 54 | password = "<redacted>" |
||
| 55 | permissions = [ |
||
| 56 | { |
||
| 57 | permission = "actions/process-check-result" |
||
| 58 | filter = {{ match("backupninja", service.display_name) }} |
||
| 59 | 15 | Jon Goldberg | }, |
| 60 | { |
||
| 61 | permission = "actions/reschedule-check" |
||
| 62 | filter = {{ match("backupninja", service.display_name) }} |
||
| 63 | 14 | Jon Goldberg | } |
| 64 | 1 | Jon Goldberg | ] |
| 65 | } |
||
| 66 | ``` |
||
| 67 | |||
| 68 | 12 | Jon Goldberg | ### Open the firewall |
| 69 | Open port 5665 on the master node's firewall. Edit the files in `/etc/iptables` and restart `netfilter-persistent`. |
||
| 70 | |||
| 71 | 1 | Jon Goldberg | ### Install additional checks |
| 72 | |||
| 73 | #### Install Plugins |
||
| 74 | |||
| 75 | Place the following two scripts in your plugins directory |
||
| 76 | (`/usr/lib/nagios/plugins`) and ensure they're executable: |
||
| 77 | |||
| 78 | 11 | Jon Goldberg | - **check_drupal** - installs with the Drupal "nagios" plugin, also |
| 79 | 1 | Jon Goldberg | available |
| 80 | 2 | Jon Goldberg | [here](http://cgit.drupalcode.org/nagios/plain/nagios-plugin/check_drupal?id=7da732e2d4943ec5368243f4cd2e33eb02769f23). |
| 81 | 11 | Jon Goldberg | - **check_civicrm** - There are two scripts - one for Civi 4.6 and |
| 82 | 1 | Jon Goldberg | below, another for 4.7 and up. 4.7 version is available |
| 83 | 10 | Jon Goldberg | [here](https://raw.githubusercontent.com/PalanteJon/check_civicrm/master/check_civicrm.php), |
| 84 | 4.6 version is [here](https://raw.githubusercontent.com/aghstrategies/com.aghstrategies.civimonitor/master/check_civicrm.php). |
||
| 85 | 11 | Jon Goldberg | - **check_domain** - This does a WHOIS lookup to ensure domain names aren't about to expire. Install from |
| 86 | 10 | Jon Goldberg | [here](https://raw.githubusercontent.com/glensc/monitoring-plugin-check_domain/master/check_domain.sh). |
| 87 | 11 | Jon Goldberg | - **check_rbl** - Check spam blacklists. File is [here](https://raw.githubusercontent.com/matteocorti/check_rbl/master/check_rbl), also install dependencies: |
| 88 | 2 | Jon Goldberg | `apt install libreadonly-xs-perl libnagios-plugin-perl libdata-validate-ip-perl libdata-validate-domain-perl libnet-dns-perl` |
| 89 | 1 | Jon Goldberg | |
| 90 | 2 | Jon Goldberg | #### Define CheckCommand and Service objects for the new plugins |
| 91 | 1 | Jon Goldberg | |
| 92 | 2 | Jon Goldberg | Copy the CheckCommand and Service files from |
| 93 | 1 | Jon Goldberg | `icinga.jmaconsulting.biz:/etc/icinga2/zones.d/global-templates/CheckCommands` |
| 94 | 2 | Jon Goldberg | and `icinga.jmaconsulting.biz:/etc/icinga2/conf.d/services`. See [[Add New Checks to Icinga2]] for details. |
| 95 | 1 | Jon Goldberg | |
| 96 | 13 | Jon Goldberg | ### Harden the TLS connection |
| 97 | Add this line to the bottom of the "api" object in `/etc/icinga2/features-available/api.conf`: |
||
| 98 | ``` |
||
| 99 | tls_protocolmin = "TLSv1.2" |
||
| 100 | ``` |
||
| 101 | 1 | Jon Goldberg | |
| 102 | 2 | Jon Goldberg | ### Set up vim syntax highlighting on the Icinga2 server |
| 103 | 11 | Jon Goldberg | ```bash |
| 104 | 2 | Jon Goldberg | mkdir -p ~/.vim/{syntax,ftdetect} |
| 105 | cd ~/.vim/syntax |
||
| 106 | wget https://raw.githubusercontent.com/Icinga/icinga2/master/tools/syntax/vim/syntax/icinga2.vim |
||
| 107 | cd ~/.vim/ftdetect |
||
| 108 | wget https://raw.githubusercontent.com/Icinga/icinga2/master/tools/syntax/vim/ftdetect/icinga2.vim |
||
| 109 | ``` |