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.
If I enter a number instead of $_SERVICECHECK_INTERVAL$ everything is fine, the service works as expected and in the webinterface the correct interval can be checked. With the definition above (and some variations I tried) the service_interval is shown as Zero in the web-interface.
Custom variable are intended to be passed to plugins/scripts/etc. They are not intended for use as values for config directives and by all accounts, should not work in the method you are attempting.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
technick wrote:You can look at /usr/local/nagios/var/objects.cache and view your custom variable.
Very cool, thank you. That files list every defined object with all its properties. Allows a quick check of config-changes.
(Side note: In my installation of nagios-core this file is in a different location /var/cache/nagios3/objects.cache)
abrist wrote:Custom variable are intended to be passed to plugins/scripts/etc. They are not intended for use as values for config directives and by all accounts, should not work in the method you are attempting.
No, they don't, apparently
Let me rephrase my question.
I have several identical hosts with identical services. The only differences between the hosts are host_name and address.
So I was wondering
Is there a way to duplicate the complete config of a host without having to copy every codeblock (define host{}, define service{}) individually ?
or: is it possible to define host{} and services in a single definition so that the whole definition can be replicated in a single short block (or even a single line) with just a different host_name and address ?
and: suppose I would like to quickly change a single variable for a host and all its services, for example set check_interval to 1 or 1440 instead of the default 5, and optionally quickly change it back (after testing). What is the quickest way to do that, if possible without rewriting every service ?
define host {
name linux-server
check_command check-host-alive!!!!!!!!
use generic-host
max_check_attempts 4
check_interval 1
retry_interval 1
active_checks_enabled 1
check_period 24x7
contact_groups nagios-ops
notification_interval 5
notification_period 24x7
notification_options d,u,r,
notifications_enabled 1
icon_image linux.png
register 0
}
The above is a template called linux-server. This template is chained to another template called generic-service as well. If you are unaware of how chaining works, please read up on inheritances in Nagios. Now Here are some defined hosts that all use the linux-server template.
define host {
host_name dertcn00
use linux-server
display_name dertcn00
address dertcn00
register 1
}
define host {
host_name dertcn01
use linux-server
display_name dertcn01
address dertcn01
register 1
}
define host {
host_name dertcn02
use linux-server
display_name dertcn02
address dertcn02
register 1
}
Only the bare minimum is being defined with each host and its inheriting the rest of the stuff from the linux-server template.
Technick is dead-on once again. Let us know if you have any further questions regarding templates, object inheritance, or custom variables. . .
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
tmcdonald wrote:Are you asking a question or just stating that you are going to try some things?
That was shorthand for "thank you all for the valuable hints and I will now now explore the numerous possibilies to make config files shorter". Sorry, was in a bit of a hurry