Create a Template to Group Several Services

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
idsev89
Posts: 2
Joined: Fri Nov 27, 2020 1:43 am

Create a Template to Group Several Services

Post 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.
Attachments
Schema
Schema
Captura_03.PNG (10.61 KiB) Viewed 2039 times
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Create a Template to Group Several Services

Post 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.
idsev89
Posts: 2
Joined: Fri Nov 27, 2020 1:43 am

Re: Create a Template to Group Several Services

Post 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.
Locked