| 54 | == How to add an Agent== |
| 55 | |
| 56 | ==== Host template for agents ==== |
| 57 | |
| 58 | 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. |
| 59 | |
| 60 | For setting up an agent, Host template should be created using iCinga director as follows, |
| 61 | |
| 62 | `Icinga director > Hosts > Host Templates` |
| 63 | |
| 64 | Main Properties will be shown as following |
| 65 | |
| 66 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/agent1_host_template.png, 600)]] |
| 67 | |
| 68 | In the `Icinga agent and zone settings` , Following options should be selected, |
| 69 | |
| 70 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/agent_host_template2.png, 600)]] |
| 71 | |
| 72 | '''NOTE : You should click deploy pending changes in Activity log section under Icinga Director''' |
| 73 | |
| 74 | ==== Adding hosts as agents ==== |
| 75 | |
| 76 | ''Note : Always try to use meaningful names in configurations'' |
| 77 | |
| 78 | After creating host template for, host can be added as an agent for the system. |
| 79 | |
| 80 | `Icinga director > Hosts > Host` |
| 81 | |
| 82 | As following example, the details should be assigned as per the requirement, |
| 83 | |
| 84 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/adding_agent_host.png, 600)]] |
| 85 | |
| 86 | After apply the deployment, setup preparation for agent has to be done |
| 87 | |
| 88 | ==== Before Executing the agent scripts... ==== |
| 89 | |
| 90 | Before executing the agent scripts in the relevant machines, |
| 91 | |
| 92 | Icinga2 have to be installed in the Agent as following instructions below, |
| 93 | |
| 94 | {{{ |
| 95 | |
| 96 | apt-get -y install apt-transport-https wget gnupg |
| 97 | |
| 98 | wget -O - https://packages.icinga.com/icinga.key | apt-key add - |
| 99 | |
| 100 | . /etc/os-release; if [ ! -z ${UBUNTU_CODENAME+x} ]; then DIST="${UBUNTU_CODENAME}"; else DIST="$(lsb_release -c| awk '{print $2}')"; fi; |
| 101 | |
| 102 | echo "deb https://packages.icinga.com/ubuntu icinga-${DIST} main" > /etc/apt/sources.list.d/${DIST}-icinga.list |
| 103 | |
| 104 | echo "deb-src https://packages.icinga.com/ubuntu icinga-${DIST} main" >> /etc/apt/sources.list.d/${DIST}-icinga.list |
| 105 | |
| 106 | apt-get update |
| 107 | |
| 108 | apt-get install icinga2 monitoring-plugins |
| 109 | |
| 110 | }}} |
| 111 | |
| 112 | '''Note : Please check the `/etc/hosts` file and verify that the agent is resolving for the FQDNvof master node before executing the agent scripts.''' |
| 113 | (Otherwise you will not be able to connect agent hosts with a certificate error) |
| 114 | |
| 115 | `icinga director > hosts > host >`, click on the agent and agent tab contains the scripts for agent manual configurations. |
| 116 | |
| 117 | Click on the agent host you added and a tab called Agent will be shown as in the following image, |
| 118 | |
| 119 | [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/NSM2021/Agenda/icinga_handson_cont/agent_scripts.png, 600)]] |
| 120 | |
| 121 | You will see two scripts to execute on agent hosts. |
| 122 | |
| 123 | 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. |
| 124 | |
| 125 | Download them in the the agent hosts and execute the scripts for configurations. |
| 126 | |
| 127 | `./icinga-agent.sh` |