start --> start --> wms| raspberry oder banana pi als Icinga 2 Monitoring Instanz
Rothirsch Technologies Hintergrund
Pfeilsymbol zum rauf scrollen der Bilder
Pfeilsymbol zum runter scrollen der Bilder

Monitoring

Is an open source monitoring tool that allows you to control different services on servers in your local and/or remote network. It is also possible to connect your smartphone with your icinga2 instance.

Build

Icinga2 and Icingaweb2

Add icinga repositories and install the packages

Add key for the maintainers repository

wget -O - https://packages.icinga.com/icinga.key | apt-key add -

Add repository to /etc/apt/source.list

echo -e '# Icinga
deb-src http://packages.icinga.com/debian icinga-stretch main' > /etc/apt/sources.list.d/icinga.list

Install icinga2 from repo

apt update

pbuilder setup

apt-get install pbuilder debootstrap devscripts
pbuilder create --distribution stretch --debootstrapopts --variant=buildd

Build icinga2

mkdir -p /opt/icinga2
cd /opt/icinga2
apt-get source icinga2

Reading package lists... Done
NOTICE: 'icinga2' packaging is maintained in the 'Git' version control system at:
https://anonscm.debian.org/git/pkg-nagios/pkg-icinga2.git
Please use:
git clone https://anonscm.debian.org/git/pkg-nagios/pkg-icinga2.git
to retrieve the latest (possibly unreleased) updates to the package.
Need to get 2,226 kB of source archives.
Get:1 http://packages.icinga.com/debian icinga-stretch/main icinga2 2.9.1-1.stretch (diff) [31.0 kB]
Get:2 http://packages.icinga.com/debian icinga-stretch/main icinga2 2.9.1-1.stretch (dsc) [1,873 B]
Get:3 http://packages.icinga.com/debian icinga-stretch/main icinga2 2.9.1-1.stretch (tar) [2,193 kB]
Fetched 2,226 kB in 0s (2,550 kB/s)
dpkg-source: info: extracting icinga2 in icinga2-2.9.1
dpkg-source: info: unpacking icinga2_2.9.1.orig.tar.gz
dpkg-source: info: unpacking icinga2_2.9.1-1.stretch.debian.tar.xz
dpkg-source: info: applying 21_config_changes
W: Download is performed unsandboxed as root as file 'icinga2_2.9.1-1.stretch.debian.tar.xz' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)

OUTPUT

pbuilder build --debbuildopts "-j4" icinga2_2.9.1-1.stretch.dsc

W: /root/.pbuilderrc does not exist
I: using fakeroot in build.
I: pbuilder: network access will be disabled during build
I: Current time: Wed Aug 1 09:01:29 CEST 2018
I: pbuilder-time-stamp: 1533106889
I: Building the build Environment
I: extracting base tarball [/var/cache/pbuilder/base.tgz]
I: copying local configuration
I: mounting /proc filesystem
I: mounting /sys filesystem
I: creating /{dev,run}/shm
I: mounting /dev/pts filesystem
I: redirecting /dev/ptmx to /dev/pts/ptmx
I: policy-rc.d already exists
I: Obtaining the cached apt archive contents
I: Copying source file
I: copying [icinga2_2.9.1-1.stretch.dsc]
I: copying [./icinga2_2.9.1.orig.tar.gz]
I: copying [./icinga2_2.9.1-1.stretch.debian.tar.xz]
I: Extracting source
dpkg-source: warning: extracting unsigned source package (icinga2_2.9.1-1.stretch.dsc)
dpkg-source: info: extracting icinga2 in icinga2-2.9.1
dpkg-source: info: unpacking icinga2_2.9.1.orig.tar.gz
dpkg-source: info: unpacking icinga2_2.9.1-1.stretch.debian.tar.xz
dpkg-source: info: applying 21_config_changes
I: Installing the build-deps
 -> Attempting to satisfy build-dependencies
 -> Creating pbuilder-satisfydepends-dummy package
Package: pbuilder-satisfydepends-dummy
Version: 0.invalid.0
Architecture: arm64
Maintainer: Debian Pbuilder Team pbuilder-maint@lists.alioth.debian.org
Description: Dummy package to satisfy dependencies with aptitude - created by pbuilder
 This package was created automatically by pbuilder to satisfy the
 build-dependencies of the package being currently built.

OUTPUT

Installation mysql

The user informations are stored in a mySql database. It makes sense to install the mysql server on the same host as the icinga2 service. Therefore it is not necessary to think about hardware problems if the icinga2 service crashes. To check the mySql database, icinga2 uses the ido modul.

apt install mysql-server icinga2-ido-mysql

Installation steps

mysql root password

Click! for installation steps

Note

The installation is done. For later configuration we need to note the root password.

Installation icingaweb2

icingaweb2 is the web administration interface of icinga2. So we need a web-server.

For this how-to we use apache2

apt install php5-intl php5-gd php5-imagick php5-mysql apache2 libapache2-mod-php5 icingaweb2 icingacli icingaweb2-module-monitoring icinga-web-config-icinga2-ido-mysql

Change following entries in the /etc/php5/apache2/php.ini (date.timezone)

from

date.timezone =

to

date.timezone = Europe/Vienna #_your timezone_

Change permissions and reload the webserver

usermod -a -G icingaweb2 www-data
chown -R www-data:icingaweb2 /etc/icingaweb2/
service apache2 reload

Icingaweb2 basic configuration

Create the icnageweb2 configuration

icingacli setup config directory --group icingaweb2

Create the setup tokens and note them for later configuration

icingacli setup token create
The newly generated setup token is: 8fabc89ff4b537dd                    

You are now able to configure the service over the web interface (icingaweb2). Change following string so it uses your server IP address and use it in you browser.

http://172.17.0.1/icingaweb2/setup

Interface configuration step by step

Installation beendet

Master/Satellite

Um mehrer Server von einem Master überwachen zu lassen, werden diese unterschiedlich konfiguriert

Checkliste:

  • Port 5665, muss von und zum Master von der Firewall freigegeben sein.
  • Bewerkstelligt wird die Überwachung mit dem icinga2 client.

Master Konfiguration

icinga2 node wizard

_Output_
Welcome to the Icinga 2 Setup Wizard!

We'll guide you through all required configuration details.



Please specify if this is a satellite setup ('n' installs a master setup) [Y/n]: n
Starting the Master setup routine...
Please specifiy the common name (CN) [your.master.local]:
Checking for existing certificates for common name 'your.master.local'...
Certificates not yet generated. Running 'api setup' now.
information/cli: Generating new CA.
critical/cli: CA files '/var/lib/icinga2/ca/ca.crt' and '/var/lib/icinga2/ca/ca.key' already exist.
warning/cli: Found CA, skipping and using the existing one.
information/cli: Generating new CSR in '/etc/icinga2/pki/your.master.local.csr'.
information/base: Writing private key to '/etc/icinga2/pki/your.master.local.key'.
information/base: Writing certificate signing request to '/etc/icinga2/pki/your.master.local.csr'.
information/cli: Signing CSR with CA and writing certificate to '/etc/icinga2/pki/your.master.local.crt'.
information/cli: Copying CA certificate to '/etc/icinga2/pki/ca.crt'.
information/cli: Created backup file '/etc/icinga2/pki/ca.crt.orig'.
Generating master configuration for Icinga 2.
information/cli: API user config file '/etc/icinga2/conf.d/api-users.conf' already exists, not creating config file.
'api' feature already enabled.
information/cli: Dumping config items to file '/etc/icinga2/zones.conf'.
warning/cli: Backup file '/etc/icinga2/zones.conf.orig' already exists. Skipping backup.
Please specify the API bind host/port (optional):
Bind Host []:
Bind Port []:
warning/cli: Backup file '/etc/icinga2/features-available/api.conf.orig' already exists. Skipping backup.
information/cli: Updating constants.conf.
warning/cli: Backup file '/etc/icinga2/constants.conf.orig' already exists. Skipping backup.
information/cli: Updating constants file '/etc/icinga2/constants.conf'.
information/cli: Updating constants file '/etc/icinga2/constants.conf'.
information/cli: Updating constants file '/etc/icinga2/constants.conf'.
Done.

Now restart your Icinga 2 daemon to finish the installation!

service icinga2 restart
service icinga2 status

_Ouput_
● icinga2.service - Icinga host/service/network monitoring system
Loaded: loaded (/lib/systemd/system/icinga2.service; enabled)
Active: active (running) since Wed 2016-02-17 18:24:55 UTC; 3min 25s ago
Process: 4859 ExecStartPre=/usr/lib/icinga2/prepare-dirs /usr/lib/icinga2/icinga2 (code=exited, status=0/SUCCESS)
Main PID: 4919 (icinga2)
CGroup: /system.slice/icinga2.service
└─4919 /usr/lib/arm-linux-gnueabihf/icinga2/sbin/icinga2 --no-stack-rlimit daemon -e

Feb 17 18:25:00 mi icinga2[4919]: [2016-02-17 18:24:56 +0000] information/ConfigItem: Activated all objects.
Feb 17 18:25:00 mi icinga2[4919]: [2016-02-17 18:24:56 +0000] information/DbConnection: Resuming IDO connection: ido-mysql
Feb 17 18:25:00 mi icinga2[4919]: [2016-02-17 18:24:56 +0000] information/ConfigCompiler: Compiling config file: /var/lib/icinga2/modified-attributes.conf
Feb 17 18:25:00 mi icinga2[4919]: [2016-02-17 18:24:56 +0000] information/IdoMysqlConnection: MySQL IDO instance id: 1 (schema version: '1.14.0')
Feb 17 18:25:00 mi icinga2[4919]: [2016-02-17 18:24:57 +0000] information/IdoMysqlConnection: Finished reconnecting to MySQL IDO database in 1.50388 second(s).
Feb 17 18:25:00 mi icinga2[4919]: [2016-02-17 18:25:00 +0000] information/ApiListener: New client connection for identity 'your.satellite.local'
Feb 17 18:25:00 mi icinga2[4919]: [2016-02-17 18:25:00 +0000] information/ApiListener: Sending config updates for endpoint 'your.satellite.local'.
Feb 17 18:25:00 mi icinga2[4919]: [2016-02-17 18:25:00 +0000] information/ApiListener: Syncing runtime objects to endpoint 'your.satellite.local'.
Feb 17 18:25:00 mi icinga2[4919]: [2016-02-17 18:25:00 +0000] information/ApiListener: Finished sending config updates for endpoint 'your.satellite.local'.
Feb 17 18:25:00 mi icinga2[4919]: [2016-02-17 18:25:00 +0000] information/ApiListener: Sending replay log for endpoint 'your.satellite.local'.

Satellite am Master bekannt machen

Ändere /etc/icinga2/zones.conf

/*
* Generated by Icinga 2 node setup commands
* on 2016-06-27 22:04:57 +0200
*/

object Endpoint NodeName {
}

object Zone "master" {
endpoints = [ NodeName ]
}

object Endpoint "your.satellite.local" {
host = "your.satellite.local"
}
object Zone "your.satellite.local" {
endpoints = [ "your.satellite.local" ]
parent = "master"
}

Füge Satellite zu /etc/icinga2/conf.d/hosts.conf hinzu

object Host "your.satellite.local" {
import "generic-host"

address = "your.satellite.local"
//address6 = "::1"

vars.os = "Linux"

vars.remote_client = "your.satellite.local"

vars.ssh_port = 908
//vars.users_wgreater = 10
//vars.users_cgreater = 20

/* Define disks and attributes for service apply rules in `services.conf`. */
vars.disks["disk"] = {
/* No parameters. */
}
vars.disks["disk /"] = {
disk_partitions = "/"
}

/* Define notification mail attributes for notification apply rules in `notifications.conf`. */
vars.notification["mail"] = {
/* The UserGroup `icingaadmins` is defined in `users.conf`. */
groups = [ "icingaadmins" ]
}
}

Anschließend kann gleich ein Ticket erstellt werden. Bitte notieren, da die ID bei der Satelliten Konfiguration verwendet wird.

icinga2 pki ticket --cn 'your.satellite.local'
a18672b3ad1fa2ay2a6d84a1234d5ddc2420789

Satellite Installation/Konfiguration

Installation Satellite

wget -O - http://debmon.org/debmon/repo.key | apt-key add -

Füge zu /etc/apt/sources.list hinzu

# Icinga<br>
deb http://debmon.org/debmon debmon-jessie main</p>

Installation Icinga2 apt-get update && apt-get install icinga2

Konfiguration Satellite

icinga2 node wizard

Welcome to the Icinga 2 Setup Wizard!

We'll guide you through all required configuration details.



Please specify if this is a satellite setup ('n' installs a master setup) [Y/n]: Y
Starting the Node setup routine...
Please specifiy the common name (CN) [gsx100]: your.satellite.local
Please specify the master endpoint(s) this node should connect to:
Master Common Name (CN from your master setup): your.master.local
Do you want to establish a connection to the master from this node? [Y/n]: Y
Please fill out the master connection information:
Master endpoint host (Your master's IP address or FQDN): your.master.local
Master endpoint port [5665]:
Add more master endpoints? [y/N]: N
Please specify the master connection for CSR auto-signing (defaults to master endpoint host):
Host [your.master.local]:
Port [5665]:
information/cli: Created backup file '/etc/icinga2/pki/your.satellite.local.key.orig'.
information/cli: Created backup file '/etc/icinga2/pki/your.satellite.local.crt.orig'.
information/base: Writing private key to '/etc/icinga2/pki/your.satellite.local.key'.
information/base: Writing X509 certificate to '/etc/icinga2/pki/your.satellite.local.crt'.
information/cli: Fetching public certificate from master (your.master.local, 5665):

Certificate information:

Subject:     CN = your.master.local
Issuer:      CN = Icinga CA
Valid From:  Feb 17 17:33:05 2016 GMT
Valid Until: Feb 13 17:33:05 2031 GMT
Fingerprint: 15 EE F1 FA 5A 40 87 39 B1 C0 A0 D8 74 CB 58 E3 A8 74 C1 35

Is this information correct? [y/N]: y
information/cli: Received trusted master certificate.

Please specify the request ticket generated on your Icinga 2 master.
(Hint: # icinga2 pki ticket --cn 'your.satellite.local'): a18672b3ad1fa2ay2a6d84a1234d5ddc2420789
information/cli: Requesting certificate with ticket 'a18672b3ad1fa2ay2a6d84a1234d5ddc2420789'.

warning/cli: Backup file '/etc/icinga2/pki/your.satellite.local.crt.orig' already exists. Skipping backup.
information/cli: Writing signed certificate to file '/etc/icinga2/pki/your.satellite.local.crt'.
information/cli: Writing CA certificate to file '/etc/icinga2/pki/ca.crt'.
Please specify the API bind host/port (optional):
Bind Host []:
Bind Port []:
Accept config from master? [y/N]: y
Accept commands from master? [y/N]: y
information/cli: Disabling the Notification feature.
Disabling feature notification. Make sure to restart Icinga 2 for these changes to take effect.
information/cli: Enabling the Apilistener feature.
Enabling feature api. Make sure to restart Icinga 2 for these changes to take effect.
information/cli: Created backup file '/etc/icinga2/features-available/api.conf.orig'.
information/cli: Generating local zones.conf.
information/cli: Dumping config items to file '/etc/icinga2/zones.conf'.
information/cli: Created backup file '/etc/icinga2/zones.conf.orig'.
warning/cli: CN 'your.satellite.local' does not match the default FQDN 'gsx100'. Requires update for NodeName constant in constants.conf!
information/cli: Updating constants.conf.
information/cli: Created backup file '/etc/icinga2/constants.conf.orig'.
information/cli: Updating constants file '/etc/icinga2/constants.conf'.
information/cli: Updating constants file '/etc/icinga2/constants.conf'.
Done.

Now restart your Icinga 2 daemon to finish the installation!

wms|Icinga