- Работа
- Linux
- Monitoring
- Icinga2 связка master + agent
Icinga2 связка master + agent
Мастер
Запускаем icinga2 node wizard
и делаем настройки для мастера. Если вы собираетесь опрашивать локальные или удаленные узлы и другим способом не отключайте conf.d .
Базовый конфиг zones.conf
будет выглядеть примерно так.
object Endpoint "master-node" {
}
object Zone "master" {
endpoints = [ "master-node" ]
}
object Zone "global-templates" {
global = true
}
object Zone "director-global" {
global = true
}
Настройки узлов, шаблонов и тп.
По умолчанию icinga
предлагает использовать каталог zones.d
для настроек агентов.
templates.conf
template Host "icinga-agent" {
import "generic-host"
vars.agent_type = "icinga"
vars.os = "Linux"
vars.agent_endpoint = name
}
services.conf
apply Service for (disk_icinga_agent => config in host.vars.disks) {
import "generic-service"
check_command = "disk"
vars.disk_local = true
command_endpoint = host.vars.agent_endpoint
vars += config
assign where host.vars.agent_type == "icinga" && host.vars.agent_endpoint
}
apply Service "mem_icinga_agent" {
import "generic-service"
vars.mem_warning = 10
vars.mem_critical = 5
vars.mem_available = true
check_command = "mem"
command_endpoint = host.vars.agent_endpoint
assign where host.vars.agent_type == "icinga" && host.vars.agent_endpoint
}
apply Service "load_icinga_agent" {
import "generic-service"
command_endpoint = host.vars.agent_endpoint
assign where host.vars.agent_type == "icinga" && host.vars.agent_endpoint
}
Добавляем агента
В данном примере агент с имененм client
icinga2 pki ticket --cn 'client'
Сохраняем полученный код, он понадобиться для агента.
Далее обазятально добавляем в конфиг zones.conf
информацию об агентах, иначе другие конфиги работать не будут.
object Endpoint "client" {
}
object Zone "agents" {
parent = "master"
endpoints = [ "client" ]
}
И настраиваем самого агента в zones.d/hosts.con
object Host "client" {
import "icinga-agent"
vars.disks["disk"] = {
// disk_partitions = ["/", "/home"]
}
vars.load_cload1 = 20
vars.load_wload1 = 18
vars.load_cload5 = 20
vars.load_wload5 = 18
vars.load_cload15 = 20
vars.load_wload15 = 18
address = "192.168.0.4"
}
Агент
Запускаем ту же команду что на мастере icinga2 node wizard
, только делаем настройки для агента, в конце можно отключить conf.d.
Welcome to the Icinga 2 Setup Wizard!
We will guide you through all required configuration details.
Please specify if this is an agent/satellite setup ('n' installs a master setup) [Y/n]:
Starting the Agent/Satellite setup routine...
Please specify the common name (CN) [db]: db
Please specify the parent endpoint(s) (master or satellite) where this node should connect to:
Master/Satellite Common Name (CN from your master/satellite node): master-node
Do you want to establish a connection to the parent node from this node? [Y/n]:
Please specify the master/satellite connection information:
Master/Satellite endpoint host (IP address or FQDN): 192.168.0.1
Master/Satellite endpoint port [5665]:
Add more master/satellite endpoints? [y/N]:
Parent certificate information:
Version: 3
Subject: CN = master-node
Issuer: CN = Icinga CA
Valid From: Nov 2 19:23:22 2023 GMT
Valid Until: Dec 3 19:23:22 2024 GMT
Serial: 5b:b8:1a:90:04:af:91:fa:55:2b:f3:6c:ce:84:e6:98:6c:64:eb:a9
Signature Algorithm: sha256WithRSAEncryption
Subject Alt Names: master-node
Fingerprint: AD 40 90 BC D8 1C 54 A9 23 1B F5 FD 75 E7 67 AE 43 51 B4 4C 00 2B 1D 25 1C BB 89 C3 2F 0E B4 6D
Is this information correct? [y/N]: y
Please specify the request ticket generated on your Icinga 2 master (optional).
(Hint: # icinga2 pki ticket --cn 'db'): 6dbe06a952eb6a9026eb7b508e2a93dfaf7f210f
Please specify the API bind host/port (optional):
Bind Host []:
Bind Port []:
Accept config from parent node? [y/N]: y
Accept commands from parent node? [y/N]: y
Reconfiguring Icinga...
Disabling feature notification. Make sure to restart Icinga 2 for these changes to take effect.
Enabling feature api. Make sure to restart Icinga 2 for these changes to take effect.
Local zone name [client]:
Parent zone name [master]:
Default global zones: global-templates director-global
Do you want to specify additional global zones? [y/N]: n
Do you want to disable the inclusion of the conf.d directory [Y/n]:
Disabling the inclusion of the conf.d directory...
Done.
Now restart your Icinga 2 daemon to finish the installation!
[ Править ]