Mass Host Editing

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
peakyblinder
Posts: 63
Joined: Tue Mar 25, 2014 4:39 am

Mass Host Editing

Post by peakyblinder »

Hi All,

This is more of a *nix questions but heavily tailored to Nagios.

i would like to add a new service to every host I have configured without having to actually edit each host manually. Doesn't matter where in the host its added but I guess the end of the file would be the best and easiest.
This is roughly what I would like to add to each host file;
define service{
use generic-service,srv-pnp
host_name hostname
service_description OS Version
check_command check_os_version
}

I'm fairly new o *nix so just finding my feet and would like some pointers on the best way to do this. I'm sure some of you must have come across this requirements in the past?

Anyway, open to ideas.

Thanks,
Stuart Watts
Posts: 40
Joined: Wed Sep 25, 2013 7:01 am

Re: Mass Host Editing

Post by Stuart Watts »

I'd recommend doing this "the Nagios way" - create a hostgroup and add all of the hosts you need to apply this check to. Then define the service and apply it against the hostgroup. This is particularly suitable for checks that aren't dependent on thresholds (like checking OS versions!).

As much as I love command line trickery to achieve stuff like this, it's a little complicated if you're new to this sort of thing, not to mention potentially dangerous! ;)
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Mass Host Editing

Post by eloyd »

Total agreement here. In fact, we rarely have services attached to individual hosts. All our services (with very few exceptions) are attached to hostgroups. Remember - the template system within Nagios is quite powerful.

You can assign a service to a host.
You can assign a service to a bunch of hosts or a service to a hostgroup.
You can assign a bunch of services to a host or a servicegroup to a host.
You can assign a bunch of services to a bunch of hosts or a servicegroup to a hostgroup

And don't forget that you can use wildcards as well and that servicegroups and hostgroups apply to things other than just service definitions (see http://nagios.sourceforge.net/docs/3_0/ ... ricks.html).
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
peakyblinder
Posts: 63
Joined: Tue Mar 25, 2014 4:39 am

Re: Mass Host Editing

Post by peakyblinder »

Excellent feedback guys.... Thank you very much!

Think it might be a time for a little reorganization of my Nagios config.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Mass Host Editing

Post by tmcdonald »

I'm going to close this topic now, but if you have specific questions feel free to open another.
Former Nagios employee
Locked