Page 1 of 1

Nagios Core Host Groups

Posted: Tue Apr 27, 2021 2:21 am
by tremafra
Hi all,
maybe i'm failing to unerstand certain dynamics in Nagios Core and that's the way it's supposed to be.
Therfore I ask for a confirmation because I was not able to find it anywhere and I need to keep my mental sanity avoiding to look for a solution.
I've installed Nagios Core on Centos 8.
Uploaded more than 400 hosts with basic checks to start with.
cfg file is like this for all of them (made with a script)

Code: Select all

# HOST DEFINITION
define host {
    use                     linux-server
    host_name               PRT_001-ACCESSORI_BAGNO_A04_Solbiate_Arno
    alias                   WSxx
    address                 10.xx.xx.xx
}
define service {
    use                     local-service           ;
    host_name               PRT_001-ACCESSORI_BAGNO_A04_Solbiate_Arno
    service_description     PING IP_ADDRESS
    check_command           check_ping!100.0,20%!500.0,60%
}
define service {
    use                     local-service           ;
    host_name               PRT_001 - ACCESSORI BAGNO A04_Solbiate Arno
    service_description     Check Web Server
    check_command           check_http!WSxx
define service {
    use                     local-service           ;
    host_name               PRT_001 - ACCESSORI BAGNO A04_Solbiate Arno
    service_description     Check IP
    check_command           check_if_alive!10.xx.xx.xx
}
define service {
    use                     local-service           ;
    host_name               PRT_001 - ACCESSORI BAGNO A04_Solbiate Arno
    service_description     Check PORT
    check_command           check_if_alive!110.xx.xx.xx
As you can see i didn't define any hostgroup yet.
I wanted to have a separated hostgroup cfg file so that i can easily edit group names or members.

Code: Select all

# GROUP DEFINITION
define hostgroup {
    hostgroup_name          001_Group
    alias                   001_Group
    members                 PRT_001 - ACCESSORI BAGNO A04_Solbiate Arno,PRT_001 - CASSA SCO A17_Solbiate Arno,PRT_001 - CORNICI A08_Solbiate Arno,PRT_001 - EDILIZIA ESTERNA A26_Solbiate Arno,PRT_001 - FERRAMENTA A13_Solbiate Arno,PRT_001 - GIARDINO A14_Solbiate Arno,PRT_001 - HP M402 A05_Solbiate Arno,PRT_001 - HP M506 I06_Solbiate Arno,PRT_001 - HP M775 I08_Solbiate Arno,PRT_001 - ILLUMINAZIONE A09_Solbiate Arno,PRT_001 - KPC02_Solbiate Arno,PRT_001 - KPC03_Solbiate Arno,PRT_001 - KPC04_Solbiate Arno,PRT_001 - KPC05_Solbiate Arno,PRT_001 - KPC06_Solbiate Arno,PRT_001 - KPC07_Solbiate Arno,PRT_001 - KPC08_Solbiate Arno,PRT_001 - KPC09_Solbiate Arno,PRT_001 - KPC10_Solbiate Arno,PRT_001 - KPC11_Solbiate Arno,PRT_001 - KPC12_Solbiate Arno,PRT_001 - KPC17_Solbiate Arno,PRT_001 - KPC21_Solbiate Arno,PRT_001 - KPC22_Solbiate Arno,PRT_001 - LOGISTICA COPIER A23_Solbiate Arno,PRT_001 - LOGISTICA INTERNA_1 A20_Solbiate Arno,PRT_001 - LOGISTICA INTERNA_2 A21_Solbiate Arno,PRT_001 - PAVIMENTI A00_Solbiate Arno,PRT_001 - PODIUM ESTERNO STAGIONALE A31_Solbiate Arno,PRT_001 - PORTE 2 A28_Solbiate Arno,PRT_001 - PORTE_1 A02_Solbiate Arno,PRT_001 - PROGETTO BAGNO A10_Solbiate Arno,PRT_001 - RISERVA 1PIANO A22_Solbiate Arno,PRT_001 - RUN I07_Solbiate Arno,PRT_001 - SRM CASSA15 A15_Solbiate Arno,PRT_001 - SRM CLIENTI CASSA16 A16_Solbiate Arno,PRT_001 - SRM INTERNO A18_Solbiate Arno,PRT_001 - TAGLIO LEGNO A11_Solbiate Arno,PRT_001 - TENDE A30_Solbiate Arno,PRT_001 - UFFICIO EDILIZIA ESTERNA A25_Solbiate Arno,PRT_001 - UFFICIO PROGETTO BAGNO A03_Solbiate Arno,PRT_001 - VERNICI A24_Solbiate Arno,PRT_001 - VISUAL A29_Solbiate Arno,PRT_001 - WSA01_Solbiate Arno,PRT_001 - WSA06_Solbiate Arno,PRT_001 - WSA12_Solbiate Arno,PRT_001 - WSI00_Solbiate Arno,PRT_001 -UFFICI SRM INTERNO A19_Solbiate Arno
}
So i created a hostgroups.cfg file anche saved in the object directory and made the adjustments to nagios.cfg using cfg_dir=xxxx

Doing the pre-flight check, I always get the error "Unexpected token or expressesion in hostgroup.cfg at line 1".
It doesn't change if i remove the first host.
Get the error whatever i write.

The funny thing is that if I copy the same group definition inside on on the host.cfg file, everything works fine adding all the host to the group.

So, my question is: Can i have a separate hostgroup cfg file or I've to put the host group definition in one of the host cfg?

Thanks for any help.