CIV:Granty/Moderní monitoring IT infrastruktury/Workshop

Z HelpDesk
Verze k tisku již není podporovaná a může obsahovat chyby s vykreslováním. Aktualizujte si prosím záložky ve svém prohlížeči a použijte prosím zabudovanou funkci prohlížeče pro tisknutí.

Instalace

Průvodce instalací

Základní instalace Icingy

  • Získání tokenu
usermod -a -G icingaweb2 www-data
icingacli setup config directory --group icingaweb2
icingacli setup token create
The newly generated setup token is: xxxxxxxxxxxxxxxxxxxx
  • Nastaveni databáze
Resource Name: icingaweb_db
Database Type: PostgreSQL
Host:          localhost
Port:          5432
Database Name: icinga2
Username:      icinga2
Password:      z výstupu ansible
Character Set: utf8
Use SSL:
-> Validate Configuration -> Next
  • Nastavení Backendu
 Backend Name: icingaweb2
 -> Next
  • Nastavení administratora:
 Username: admin
 Password: mojeadminheslo
 Repeat password: mojeadminheslo
 -> Next
  • Základní nastavení aplikace: ponechat defaultní
 -> Next
  • Přehledová stránka
 -> Next
  • Welcome
 -> Next

Modul Monitoring

  • Backend monitoringu
Backend Name: icinga
Backend Type: IDO
-> Next
 
  • Vytvoření databáze a schématu pro monitoring:
cd /tmp
sudo -u postgres psql -c "CREATE ROLE icinga WITH LOGIN PASSWORD 'icinga'"
sudo -u postgres createdb -O icinga -E UTF8 icinga
export PGPASSWORD=icinga
psql -h localhost -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/pgsql.sql
  • Nastavit přístup Icingy do PostgreSQL databáze aby tam ukládala výsledky:
vim /etc/icinga2/features-available/ido-pgsql.conf
/**
 * The db_ido_pgsql library implements IDO functionality
 * for PostgreSQL.
 */

library "db_ido_pgsql" 

object IdoPgsqlConnection "ido-pgsql" {
  user = "icinga",
  password = "icinga",
  host = "localhost",
  database = "icinga"
}
icinga2 feature enable ido-pgsql
systemctl restart icinga2
  • Monitoring IDO Resource
Resource Name: icinga_ido
Database Type: PostgreSQL
Host:          localhost
Port:          5432
Databese Name: icinga
Username:      icinga
Password:      icinga
Character Set: utf8
Use SSL:
-> Validate Configuration -> Next
  • vytvoření certifikátů, okopírování na správná místa a nastavení práv
SERVERNAME=$HOSTNAME.zcu.cz
cd /tmp
icinga2 pki new-ca
icinga2 pki new-cert --cn $SERVERNAME --key $SERVERNAME.key --csr $SERVERNAME.csr
icinga2 pki sign-csr --csr $SERVERNAME.csr --cert $SERVERNAME.crt
mkdir -p /var/lib/icinga2/certs
cp $SERVERNAME.{crt,key} /var/lib/icinga2/certs
cp /var/lib/icinga2/ca/ca.crt /var/lib/icinga2/certs
chown -R nagios:nagios /var/lib/icinga2/certs
chmod 600 /var/lib/icinga2/certs/*.key
chmod 644 /var/lib/icinga2/certs/*.crt
  • Příprava uživatele pro import dat z Directoru:
cat > /etc/icinga2/conf.d/api-users.conf << EOF
object ApiUser "director" {
  password = "director"
  permissions = [ "*" ]
}
EOF
  • Povolení Icinga 2 API
icinga2 feature enable api
systemctl restart icinga2


  • Command Transport
Transport Name: director
Transport Type: Icinga 2 API
Host:           localhost
Port:           5665
API Username:   director
API Password:   director
-> Validate Configuration 
-> Next
  • Monitoring Security: ponechat defaultní
-> Next
-> Finish
-> Login to Icinga Web 2

Modul Director

  • Příprava databáze (v našem případe PostgreSQL)
su postgres
cd /tmp
psql -q -c "CREATE DATABASE director WITH ENCODING 'UTF8';"
psql director -q -c "CREATE USER director WITH PASSWORD 'some-password'";
psql director -q -c "GRANT ALL PRIVILEGES ON DATABASE director TO director;"
exit
  • Zrušení předdefinované konfigurace (podívej se, co se teď monitoruje)
cp -r /etc/icinga2/conf.d /etc/icinga2/conf.d.orig
rm /etc/icinga2/conf.d/{apt,downtimes,groups,hosts,notifications,services}.conf
  • Nastavení resources pro databázi
-> Configuration -> Application -> Resources -> Create a New Resource:
Resource Type: SQL
Resource Name: director_db
Database Type: PostgreSQL
Host:          localhost
Port:          5432
Database Name: director
Username:      director
Password:      some-password
Character Set: utf8
Use SSL:       No
-> Validate Configuration -> Save Changes
  • Instalace
git clone https://github.com/Icinga/icingaweb2-module-director /usr/share/icingaweb2/modules/director
  • Nastavení
-> Configuration -> Modules -> Director -> enable -> Configuration:
DB Resource: director_db -> Create Database Schema (čekej)
Endpoint Name: aetherXY.zcu.cz
Icinga Host: aetherXY.zcu.cz
Port: 5665
API user: director
Password: director
-> Run import (čekej)
-> Store configuration
  • Deploy připravené konfigurace
Icinga Director -> Deployments -> Render config

Grafana

Grafana je dostupná na /grafana.

  • Vytvoření databáze v InfluxDB
influx
create database icinga
  • Konfigurace InfluxDB - Icinga
icinga2 feature enable influxdb
cat > /etc/icinga2/features-enabled/influxdb.conf << EOF
/**
 * The InfluxdbWriter type writes check result metrics and
 * performance data to an InfluxDB HTTP API
 */

object InfluxdbWriter "influxdb" {
  host = "127.0.0.1"
  port = 8086
  database = "icinga"
  flush_threshold = 1024
  flush_interval = 10s
  host_template = {
    measurement = "\$host.check_command\$"
    tags = {
      hostname = "\$host.name\$"
    }
  }
  service_template = {
    measurement = "\$service.check_command\$"
    tags = {
      hostname = "\$host.name\$"
      service = "\$service.name\$"
    }
  }
}
EOF
systemctl restart icinga2
  • První přihlášení
Username: admin
Password: admin
  • Přidání InfluxDB
Add data source ->
Name: influx
Type: InfluxDB
URL: http://localhost:8086
Access: Server (Default)
Database: icinga
-> Save & Test
  • Přídání dashboardu
-> New Dashboard
-> New Panel -> Graph
-> Panel Title -> Edit
-> Metrics
-> A: FROM default load WHERE host = icinga
      SELECT field(value) mean()
      GROUP BY time($__interval) fill(null)
      FORMAT AS Time series
      ALIAS BY load
-> ❌
-> 🖫 (Save dashboard)

Monitorujeme

Host

  • Vytvořit template hosta
  • Vytvořit hosta
  • Deploy & Overview

Service

  • Vzdálený test - ping4
    • Vytvořit template služby
    • Apply rule (ping4 pokud je nastavena adresa)
    • Deploy & Overview
  • Lokální test - load
    • Vytvořit hostgroup linux na aether*.zcu.cz
    • Vytvořit template služby
    • Apply rule (load pokud je ve skupine linux)
    • Deploy & Overview
  • Test s parametry - disk usage
    • External Commands - přidat parametry
    • Vytvořit template služby s parametry
    • Apply rule (pokud je ve skupině linux)
    • Deploy & Overview
    • Vytvořit Host template pro disk usage
    • Přidat template hostovi

Rozšíření

  • modul pro RT
  • modul pro mapy

Ostatní

  • ukázka monitoringu na ZČU
    • dashboardy
    • director
    • grafana
    • automatizace
      • LDAP, DNS
      • cfengine - JSON API