Page 1 of 1

Create a Template to Group Several Services

Posted: Wed Oct 06, 2021 6:26 am
by idsev89
Hi. Mi name is Israel, and I'm new in Nagios. I've tried for some days to create a template to group several services and use this template to monitor the same services in several hosts. However, I couldn't do it. Let me show an example.

I want to define a template called "check-system" to monitor cpu, disk, memory (ram), uptime, etc. After that, I want to define a service (only once) using "check-system" template to monitor previous parameters of a specific host. (I've attached an image, maybe it helps...).

I want to monitor several servers (about 80), and I can't imagine how long time I will need to define a service for every parameter and server to monitor... :o Could you help me, please?

Thank you very much.

Re: Create a Template to Group Several Services

Posted: Wed Oct 06, 2021 11:52 am
by gormank
Your idea is perfect, but the implementation would be a bit different. Templates are applied to hosts/services to make the hosts/services more generic and to allow settings to be defined more globally and reduce duplication of settings.

For example if you want a service to check something every 5 minutes, recheck every minute 4 times and notify after 15 minutes, this info can be placed in a template, and the template applied to all services.

Let's use check-cpu as an example that can be used for all the other checks (services). I would define a service named check-cpu-linux (a windows host would require a different service). I'd create a hostgroup, say linux_hosts that contains all the linux hosts and add the hostgroup to check-cpu-linux. Now all the hosts in the hostgroup will be checked.

You could define a template with the check interval, etc. and apply it to the service. Similarly, you can define a host template that defines the host check (such as ping), etc. When applying a template, be sure to remove from the host/service the stuff you set in the template.

Whae I define hosts, the only thing in the host is the name, IP and the template. Similarly, for services, I put as much global info in a template (or templates), and only put things related to the service in the service definition.

Looking at your drawing, in the left column I'd change template to service. In the center, I'd change template to hostgroup.

Re: Create a Template to Group Several Services

Posted: Tue Nov 09, 2021 4:33 am
by idsev89
Thank you very much @gormank for your reply and help. I will do it like you say then. It would be interesting that Nagios let use templates like I explained because it help to save a lot of work.

Thank you @gormank.