[Nagios-devel] Recursive Service definitions

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
Guest

[Nagios-devel] Recursive Service definitions

Post by Guest »


Here's on for crowd. I am using and loving the custom variables and have run
into an interesting idea. I have a host, a firewall, that has multiple
interfaces and multiple address per interface. I also have a hostgroup that
contains basic host checks for the os type. In the host group object file I
have a check for the first interface using a custom variable. What I would
like to do is have the hostgroup definition check all enumerated interface on
that host. I figure it can currently be done two ways:

1) Write a wrapper to grab all the environment vars for the interfaces and
loop through them. This would be a single service definition.
2) Define a service for each interface. ( Currently being done in the host
object file )

What I an wondering is would there be a way to dynamically generate the
service definitions for each interface?

Below are sanitized versions of my object files.

## begin host file billy.cfg
define host {
use all-hosts
host_name billy
alias Core Firewall
address 10.2.2.1
check_command check-host-alive
parents sw3548u1
_IF0 eth0
_IF0_MAC 00:00:00:00:00:00
_IF0_IP 24.0.0.2
_IF0_IP1 24.0.0.3
_IF0_IP2 24.0.0.4
_IF0_IP3 24.0.0.5
_IF0_IP4 24.0.0.6
_IF0_CONN Public
_IF1 eth1
_IF1_MAC 00:00:00:00:00:00
_IF1_IP 10.2.0.1
_IF1_CONN Private
_IF2 eth2
_IF2_MAC 00:00:00:00:00:00
_IF2_IP 10.2.1.1
_IF2_CONN WLAN
_IF3 eth3
_IF3_MAC 00:00:00:00:00:00
_IF3_IP 10.2.2.1
_IF3_CONN Server
}

define service {
use crit-service
host_name billy
service_description Interface - IF1
check_command check_ifopstat!$_HOSTIF1$
}

define service {
use crit-service
host_name billy
service_description Interface - IF2
check_command check_ifopstat!$_HOSTIF2$
}

define service {
use crit-service
host_name billy
service_description Interface - IF3
check_command check_ifopstat!$_HOSTIF3$
}
## End host object file

## Begin Host group object file hg-osDebian.cfg
define hostgroup{
hostgroup_name debian-servers
alias All Debian Servers
members billy
}
define service {
use crit-service
hostgroup_name debian-servers
service_description Interface - IF0
servicegroups baseos
check_command check_ifopstat!$_HOSTIF0$
}
## End Host group object file


--
Syd Alsobrook
IT Tag Team, Inc.
518-598-6025
http://www.ittagteam.com





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked