= Icinga Hands - On - Cont= Through this hands-on you see * How to add a host * How to add a service * How to check DNS * How to add an agent * How to monitor disk space * How to check files == How to add a host == === How to add a host template === Before adding hosts, the host templates have to be added. These templates should have the details on how host needs to be checked. [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/iCinga/host_template28.png, 600)]] === Add a host === Add the hosts after adding host template: [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/iCinga/add_hosts30.png, 600)]] == How to add a Service == === How to add a service template === Before adding services, the service templates has to be added, [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/iCinga/service_template32.png, 600)]] === Add a Service === After, services can be added as following as per requirements: [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/iCinga/service33.png, 600)]] === Check DNS === Add the service template to dns check as follows, [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/dns_template.png, 600)]] After, adding the service template, you will see a field when select the service template as in the example below, as Custom fields : dns check [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/fields_dns.png, 600)]] After selecting the fields from dropdown list as per the requirements, add the fields to the service template. [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/dns_fields.png, 600)]] Deply the changes you made and then you can modify the service template as follows if you need. [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/dns_check3.png, 600)]] Use the DNS service you created as needed. == How to add an Agent== ==== Host template for agents ==== Agent settings are not available for modification directly on a host object. This requires you to create an “Icinga Agent” template. You could name it exactly like that; it’s important to use meaningful names for your templates. For setting up an agent, Host template should be created using iCinga director as follows, `Icinga director > Hosts > Host Templates` Main Properties will be shown as following [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/agent1_host_template.png, 600)]] In the `Icinga agent and zone settings` , Following options should be selected, [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/agent_host_template2.png, 600)]] '''NOTE : You should click deploy pending changes in Activity log section under Icinga Director''' ==== Adding hosts as agents ==== ''Note : Always try to use meaningful names in configurations'' After creating host template for, host can be added as an agent for the system. `Icinga director > Hosts > Host` As following example, the details should be assigned as per the requirement, [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/adding_agent_host.png, 600)]] After apply the deployment, setup preparation for agent has to be done ==== Before Executing the agent scripts... ==== Before executing the agent scripts in the relevant machines, Icinga2 have to be installed in the Agent as following instructions below, {{{ apt-get -y install apt-transport-https wget gnupg wget -O - https://packages.icinga.com/icinga.key | apt-key add - . /etc/os-release; if [ ! -z ${UBUNTU_CODENAME+x} ]; then DIST="${UBUNTU_CODENAME}"; else DIST="$(lsb_release -c| awk '{print $2}')"; fi; echo "deb https://packages.icinga.com/ubuntu icinga-${DIST} main" > /etc/apt/sources.list.d/${DIST}-icinga.list echo "deb-src https://packages.icinga.com/ubuntu icinga-${DIST} main" >> /etc/apt/sources.list.d/${DIST}-icinga.list apt-get update apt-get install icinga2 monitoring-plugins }}} '''Note : Please check the `/etc/hosts` file and verify that the agent is resolving for the FQDNvof master node before executing the agent scripts.''' (Otherwise you will not be able to connect agent hosts with a certificate error) `icinga director > hosts > host >`, click on the agent and agent tab contains the scripts for agent manual configurations. Click on the agent host you added and a tab called Agent will be shown as in the following image, [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/agent_scripts.png, 600)]] You will see two scripts to execute on agent hosts. They are for Agent deployment instructions, you will get Windows Kickstart Script and a command line script for the agents as above in the example. Download them in the the agent hosts and execute the scripts for configurations. `./icinga-agent.sh` After, To check wether the agent is added, execute following command on master as follow in the exemple `icinga2 ca list --all` [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/master_listing_agents.jpeg, 600)]] == How to check disk space == Before adding the service to check the disk space in a host, add the service template for the diskspace with necessary commands as following image [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/diskspace_service.png, 600)]] And after, Please add the service to the host to monitor the diskspace as follows [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/diskcheck1.png, 600)]] [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/diskcheck2.png, 600)]] == How to check files ==