Last Updated: September 27, 2021
·
1.097K
· kde

Monitor your infrastructure using icinga2 with multiple zones Part 1

https://www.youtube.com/watch?v=vvxaw-6fQHM

apt-get update

apt-get install -y wget curl python openssh-server
wget -O - http://packages.icinga.org/icinga.key | apt-key add -
echo 'deb http://packages.icinga.org/ubuntu icinga-trusty main' > /etc/apt/sources.list.d/icinga-main-trusty.list
apt-get update
apt-get install icinga2

To Install Icinga2 Classic

apt-get install icinga2-classicui

To Install Icinga2 ًWeb2 GUI

sudo apt-get install mysql-server mysql-client icinga2-ido-mysql

sudo apt-get install icingaweb2 php5-gd php5-mysql

icingacli setup config directory --group icingaweb2;
icingacli setup token create;

Mysql Database

GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icingaweb_db.* TO 'icingaweb'@'localhost' IDENTIFIED BY 'password'

FLUSH PRIVILEGES;

Configure Master Zone

icinga2 api setup

Sudo

nagios ALL= NOPASSWD: ALL

Install Plugins

apt-get install nagios-plugins-basic

To Add Node via API

curl -k -s -u root:password -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/hosts/XXXX' -d '{ "templates": [ "generic-host" ], "attrs": { "address": "XXXXXX", "check_command": "hostalive", "vars.os" : "Linux" ,"zone": "XX" } }' | python -m json.tool

To Delete node via API

curl -k -s -u root:password -H 'Accept: application/json' -X DELETE 'https://localhost:5665/v1/objects/hosts/XXX?cascade=1' | python -m json.tool

To Get info about the object via API

curl -k -s -u root:password 'https://localhost:5665/v1/objects/hosts' | python -m json.tool