Skip to content

Commit f4e71b2

Browse files
authored
How to update a host group name (#2791)
* How to update a host group name * Update to right README.md directory
1 parent 490ad11 commit f4e71b2

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

ansible/playbooks/nagios/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,72 @@ The Encrypted File Can Have Its Password Changed With The Following command
6262
Based off the [installation guide](https://support.nagios.com/kb/article/nagios-core-installing-nagios-core-from-source-96.html):
6363
And Off This [GitRepo](https://github.com/Willsparker/AnsibleBoilerPlates/tree/main/Nagios) :
6464
For some useful tips for working with vault files see [here](https://docs.ansible.com/ansible/latest/user_guide/vault.html)
65+
66+
### How to update a host group name to the nagios core configurations
67+
68+
* The hostgroups.cfg can be located at
69+
70+
```bash
71+
/usr/local/nagios/etc/objects/hostgroups.cfg
72+
```
73+
74+
* Navigate to
75+
76+
```bash
77+
cd /usr/local/nagios/etc/objects
78+
```
79+
80+
* Open hostgroups.cfg in a text editor
81+
82+
```bash
83+
vi hostgroups.cfg
84+
```
85+
86+
* After opening the `hostgroups.cfg` update the host group name in the code related to the following block of code.
87+
88+
```bash
89+
define hostgroup {
90+
hostgroup_name linuxubuntu
91+
alias linux-ubuntu
92+
}
93+
```
94+
95+
* Move a directory up and then edit the nagios.cfg file:
96+
97+
```bash
98+
cd ..
99+
vi nagios.cfg
100+
```
101+
102+
* Check whether the config file is declared in nagios.cfg. It should look like this
103+
104+
```bash
105+
cfg_file=/usr/local/nagios/etc/objects/hostgroups.cfg
106+
```
107+
108+
and can be added if there is non
109+
110+
* For each of the hosts we want to be part of the group, find their definitions and update a hostgroups directive to put them into the updated hostgroup. In this case, our definitions for sparta.example.net and athens.example.net ends up looking like this: The hostgroups name can be updated to the corresponding name `linuxubuntu`
111+
112+
```bash
113+
define host {
114+
use linux-server
115+
host_name khan.example.net
116+
alias khan
117+
address 192.0.2.21
118+
hostgroups linuxubuntu
119+
}
120+
define host {
121+
use linux-server
122+
host_name khu.example.net
123+
alias khu
124+
address 192.0.2.22
125+
hostgroups linuxubuntu
126+
}
127+
```
128+
129+
* Restart Nagios:
130+
131+
```bash
132+
/etc/init.d/nagios reload
133+
```

0 commit comments

Comments
 (0)