loading host specific variables?

ibloodyhatespam at gmail.com ibloodyhatespam at gmail.com
Tue Jul 28 13:48:39 CEST 2009


Just realised I might as well make nagios load a fixed
"/etc/objects/customscripts.cfg" and have a shell script copy the right
hostname.cfg to that file, based on hostname output.
Still a workaround, but at least this will go right automatically :)

-----Original Message-----
From: ibloodyhatespam at gmail.com [mailto:ibloodyhatespam at gmail.com] 
Sent: Tuesday 28 July 2009 13:43
To: nagios-users at lists.sourceforge.net
Subject: RE: [Nagios-users] loading host specific variables?

That's quite similar to the workaround I have right now :) I've commented
out lines in nagios.cfg that have to be disabled/enabled manually after
copying and load specific cfgs...
I'm wondering if it's possible to have nagios pay attention to variables
within its cfgs and load based on that, simple example:

Hostname 1 = thismachine
Hostname 2 = thatmachine

etc/objects/thismachine.cfg -> rolled up custom set of definitions 1
etc/objects/thatmachine.cfg -> rolled up custom set of definitions 2

nagios.cfg:
cfg_file=/usr/local/nagios/etc/objects/$HOSTNAME$.cfg -> reads either of
these depending on hostname

This of course doesn't work, but perhaps there is a different way?


-----Original Message-----
From: Christian Schneemann [mailto:cschneemann at suse.de]
Sent: Tuesday 28 July 2009 13:34
To: ibloodyhatespam at gmail.com
Subject: Re: [Nagios-users] loading host specific variables?

On Tuesday July 28 2009 01:21:46 pm ibloodyhatespam at gmail.com wrote:
> Well, next to the regular servers.cfg, commands_check.cfg, 
> commands_definition.cfg etc etc etc there are a couple of things that 
> are different between hosts (notably event handlers), making one the 
> master host and one the slave host.
>
> I've already created a hostname1.cfg and a hostname2.cfg containing 
> the host and service definitions that differ, but I'd like nagios to 
> read either of these based on the current machine hostname, instead of 
> having to manually edit nagios.cfg after copying cfgs over from the 
> master host to the slave host.
You could create different config-dirs in your configuration, one for each
server and just add the directory on that server, that should use the
configuration from that directory.

server1:
/etc/nagios/objects/server1_configs/ <-- added as config_dir to nagios.cfg
/etc/nagios/objects/server2_configs/
/etc/nagios/objects/other_configs/ <-- added as config_dir to nagios.cfg

server2:
/etc/nagios/objects/server1_configs/
/etc/nagios/objects/server2_configs/ <-- added as config_dir to nagios.cfg
/etc/nagios/objects/other_configs/ <-- added as config_dir to nagios.cfg

Would that be an option?

Greetings,
 Christian


--
Christian Schneemann
Operations & Services
-------------------------------------
SUSE LINUX Products GmbH,
Maxfeldstr. 5, D - 90409 Nürnberg

Phone:  +49 (0)911 - 740 53 0
e-mail: cschneemann at suse.de
-------------------------------------
SUSE LINUX Products GmbH, GF: Markus Rex HRB 16746 (AG Nürnberg)



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list